/**
 * AgroCapital Modern Design System
 * Centralized CSS Framework for Consistent UI/UX
 * Version: 2.0
 */

/* ============================================================================
   CSS VARIABLES (Design Tokens)
   ============================================================================ */
:root {
  /* Brand Colors */
  --ag-primary: #0c7a3d;
  --ag-primary-dark: #065a2c;
  --ag-primary-light: #11844a;
  --ag-primary-lighter: #d4f1e2;
  
  --ag-secondary: #EC8C25;
  --ag-secondary-dark: #d47a1a;
  --ag-secondary-light: #f5a855;
  
  --ag-accent: #D4AF37;
  --ag-accent-dark: #b8962d;
  
  /* Neutral Colors */
  --ag-white: #ffffff;
  --ag-black: #000000;
  --ag-gray-50: #f8f9fa;
  --ag-gray-100: #f1f3f4;
  --ag-gray-200: #e9ecef;
  --ag-gray-300: #dee2e6;
  --ag-gray-400: #ced4da;
  --ag-gray-500: #adb5bd;
  --ag-gray-600: #6c757d;
  --ag-gray-700: #495057;
  --ag-gray-800: #343a40;
  --ag-gray-900: #212529;
  
  /* Semantic Colors */
  --ag-success: #28a745;
  --ag-success-bg: #d4edda;
  --ag-success-border: #c3e6cb;
  
  --ag-info: #17a2b8;
  --ag-info-bg: #d1ecf1;
  --ag-info-border: #bee5eb;
  
  --ag-warning: #ffc107;
  --ag-warning-bg: #fff3cd;
  --ag-warning-border: #ffeaa7;
  
  --ag-danger: #dc3545;
  --ag-danger-bg: #f8d7da;
  --ag-danger-border: #f5c6cb;
  
  /* Shadows & Elevation */
  --ag-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
  --ag-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  --ag-shadow-md: 0 8px 20px rgba(0, 0, 0, 0.12);
  --ag-shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.15);
  --ag-shadow-xl: 0 24px 60px rgba(0, 0, 0, 0.2);
  
  /* Border Radius */
  --ag-radius-sm: 6px;
  --ag-radius: 12px;
  --ag-radius-md: 16px;
  --ag-radius-lg: 20px;
  --ag-radius-xl: 24px;
  --ag-radius-full: 9999px;
  
  /* Spacing */
  --ag-space-xs: 4px;
  --ag-space-sm: 8px;
  --ag-space-md: 16px;
  --ag-space-lg: 24px;
  --ag-space-xl: 32px;
  --ag-space-2xl: 48px;
  --ag-space-3xl: 64px;
  
  /* Typography */
  --ag-font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  --ag-font-mono: 'Consolas', 'Monaco', 'Courier New', monospace;
  
  --ag-font-size-xs: 0.75rem;     /* 12px */
  --ag-font-size-sm: 0.875rem;    /* 14px */
  --ag-font-size-base: 1rem;      /* 16px */
  --ag-font-size-lg: 1.125rem;    /* 18px */
  --ag-font-size-xl: 1.25rem;     /* 20px */
  --ag-font-size-2xl: 1.5rem;     /* 24px */
  --ag-font-size-3xl: 1.875rem;   /* 30px */
  --ag-font-size-4xl: 2.25rem;    /* 36px */
  --ag-font-size-5xl: 3rem;       /* 48px */
  
  --ag-font-weight-light: 300;
  --ag-font-weight-normal: 400;
  --ag-font-weight-medium: 500;
  --ag-font-weight-semibold: 600;
  --ag-font-weight-bold: 700;
  
  --ag-line-height-tight: 1.25;
  --ag-line-height-normal: 1.5;
  --ag-line-height-relaxed: 1.75;
  
  /* Transitions & Animations */
  --ag-transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --ag-transition: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --ag-transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Z-Index Layers */
  --ag-z-dropdown: 1000;
  --ag-z-sticky: 1020;
  --ag-z-fixed: 1030;
  --ag-z-modal-backdrop: 1040;
  --ag-z-modal: 1050;
  --ag-z-popover: 1060;
  --ag-z-tooltip: 1070;
  --ag-z-notification: 1080;
}

/* ============================================================================
   GLOBAL RESET & BASE STYLES
   ============================================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--ag-font-family);
  font-size: var(--ag-font-size-base);
  font-weight: var(--ag-font-weight-normal);
  line-height: var(--ag-line-height-normal);
  color: var(--ag-gray-900);
  background-color: var(--ag-gray-50);
  overflow-x: hidden;
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

/* Loading Spinner */
.ag-loader {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid var(--ag-gray-200);
  border-top-color: var(--ag-primary);
  border-radius: 50%;
  animation: ag-spin 0.8s linear infinite;
}

.ag-loader-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.ag-loader-lg {
  width: 60px;
  height: 60px;
  border-width: 6px;
}

@keyframes ag-spin {
  to { transform: rotate(360deg); }
}

/* Loading Overlay */
.ag-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--ag-z-modal);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--ag-transition), visibility var(--ag-transition);
}

.ag-loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Modern Card Component */
.ag-card {
  background: var(--ag-white);
  border-radius: var(--ag-radius);
  padding: var(--ag-space-lg);
  box-shadow: var(--ag-shadow);
  transition: transform var(--ag-transition), box-shadow var(--ag-transition);
}

.ag-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--ag-shadow-lg);
}

.ag-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--ag-space-md);
  padding-bottom: var(--ag-space-md);
  border-bottom: 1px solid var(--ag-gray-200);
}

.ag-card-title {
  font-size: var(--ag-font-size-xl);
  font-weight: var(--ag-font-weight-semibold);
  color: var(--ag-gray-900);
}

.ag-card-body {
  color: var(--ag-gray-700);
}

/* Modern Button System */
.ag-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ag-space-sm);
  padding: 12px 24px;
  font-size: var(--ag-font-size-base);
  font-weight: var(--ag-font-weight-medium);
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
  border: none;
  border-radius: var(--ag-radius);
  transition: all var(--ag-transition);
  position: relative;
  overflow: hidden;
}

.ag-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.ag-btn:hover::before {
  width: 300px;
  height: 300px;
}

.ag-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* Button Variants */
.ag-btn-primary {
  background: linear-gradient(135deg, var(--ag-primary), var(--ag-primary-light));
  color: var(--ag-white);
  box-shadow: 0 4px 15px rgba(12, 122, 61, 0.3);
}

.ag-btn-primary:hover {
  background: linear-gradient(135deg, var(--ag-primary-dark), var(--ag-primary));
  box-shadow: 0 6px 20px rgba(12, 122, 61, 0.4);
  transform: translateY(-2px);
}

.ag-btn-secondary {
  background: linear-gradient(135deg, var(--ag-secondary), var(--ag-secondary-light));
  color: var(--ag-white);
  box-shadow: 0 4px 15px rgba(236, 140, 37, 0.3);
}

.ag-btn-secondary:hover {
  background: linear-gradient(135deg, var(--ag-secondary-dark), var(--ag-secondary));
  box-shadow: 0 6px 20px rgba(236, 140, 37, 0.4);
  transform: translateY(-2px);
}

.ag-btn-outline {
  background: transparent;
  color: var(--ag-primary);
  border: 2px solid var(--ag-primary);
}

.ag-btn-outline:hover {
  background: var(--ag-primary);
  color: var(--ag-white);
}

.ag-btn-ghost {
  background: transparent;
  color: var(--ag-primary);
}

.ag-btn-ghost:hover {
  background: var(--ag-primary-lighter);
}

/* Button Sizes */
.ag-btn-sm {
  padding: 8px 16px;
  font-size: var(--ag-font-size-sm);
}

.ag-btn-lg {
  padding: 16px 32px;
  font-size: var(--ag-font-size-lg);
}

/* Input & Form Controls */
.ag-input {
  display: block;
  width: 100%;
  padding: 12px 16px;
  font-size: var(--ag-font-size-base);
  font-weight: var(--ag-font-weight-normal);
  line-height: 1.5;
  color: var(--ag-gray-900);
  background-color: var(--ag-white);
  background-clip: padding-box;
  border: 2px solid var(--ag-gray-300);
  border-radius: var(--ag-radius);
  transition: border-color var(--ag-transition), box-shadow var(--ag-transition);
}

.ag-input:focus {
  color: var(--ag-gray-900);
  background-color: var(--ag-white);
  border-color: var(--ag-primary);
  outline: 0;
  box-shadow: 0 0 0 4px rgba(12, 122, 61, 0.1);
}

.ag-input::placeholder {
  color: var(--ag-gray-500);
}

/* Alert Component */
.ag-alert {
  padding: 16px 20px;
  border-radius: var(--ag-radius);
  border-left: 4px solid;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: var(--ag-space-md);
}

.ag-alert-success {
  background: var(--ag-success-bg);
  border-color: var(--ag-success);
  color: #155724;
}

.ag-alert-info {
  background: var(--ag-info-bg);
  border-color: var(--ag-info);
  color: #0c5460;
}

.ag-alert-warning {
  background: var(--ag-warning-bg);
  border-color: var(--ag-warning);
  color: #856404;
}

.ag-alert-danger {
  background: var(--ag-danger-bg);
  border-color: var(--ag-danger);
  color: #721c24;
}

/* Badge Component */
.ag-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-size: var(--ag-font-size-xs);
  font-weight: var(--ag-font-weight-semibold);
  line-height: 1;
  border-radius: var(--ag-radius-full);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ag-badge-primary {
  background: var(--ag-primary-lighter);
  color: var(--ag-primary-dark);
}

.ag-badge-success {
  background: var(--ag-success-bg);
  color: var(--ag-success);
}

.ag-badge-warning {
  background: var(--ag-warning-bg);
  color: var(--ag-warning);
}

.ag-badge-danger {
  background: var(--ag-danger-bg);
  color: var(--ag-danger);
}

/* Modern Table */
.ag-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--ag-white);
  border-radius: var(--ag-radius);
  overflow: hidden;
  box-shadow: var(--ag-shadow);
}

.ag-table thead {
  background: linear-gradient(135deg, var(--ag-primary), var(--ag-primary-light));
  color: var(--ag-white);
}

.ag-table th {
  padding: 16px 20px;
  font-weight: var(--ag-font-weight-semibold);
  text-align: left;
  font-size: var(--ag-font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ag-table tbody tr {
  border-bottom: 1px solid var(--ag-gray-200);
  transition: background-color var(--ag-transition);
}

.ag-table tbody tr:hover {
  background-color: var(--ag-gray-50);
}

.ag-table tbody tr:last-child {
  border-bottom: none;
}

.ag-table td {
  padding: 16px 20px;
  color: var(--ag-gray-700);
}

/* Modal/Dialog */
.ag-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--ag-z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--ag-space-lg);
}

.ag-modal.active {
  display: flex;
}

.ag-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.ag-modal-content {
  position: relative;
  background: var(--ag-white);
  border-radius: var(--ag-radius-lg);
  box-shadow: var(--ag-shadow-xl);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: ag-modal-slide-up 0.3s ease-out;
}

@keyframes ag-modal-slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Skeleton Loader */
.ag-skeleton {
  background: linear-gradient(
    90deg,
    var(--ag-gray-200) 25%,
    var(--ag-gray-100) 50%,
    var(--ag-gray-200) 75%
  );
  background-size: 200% 100%;
  animation: ag-skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--ag-radius-sm);
}

@keyframes ag-skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Toast Notification */
.ag-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  min-width: 300px;
  max-width: 400px;
  background: var(--ag-white);
  border-radius: var(--ag-radius);
  box-shadow: var(--ag-shadow-xl);
  padding: 16px 20px;
  z-index: var(--ag-z-notification);
  animation: ag-toast-slide-in 0.3s ease-out;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

@keyframes ag-toast-slide-in {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Smooth Page Transition */
.ag-page-transition {
  animation: ag-fade-in 0.5s ease-out;
}

@keyframes ag-fade-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive Typography */
@media (max-width: 768px) {
  html {
    font-size: 14px;
  }
  
  .ag-card {
    padding: var(--ag-space-md);
  }
  
  .ag-btn {
    padding: 10px 20px;
  }
}

/* Print Styles */
@media print {
  .ag-no-print {
    display: none !important;
  }
  
  .ag-card {
    box-shadow: none;
    border: 1px solid var(--ag-gray-300);
  }
}

/* Accessibility */
.ag-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus Visible */
*:focus-visible {
  outline: 2px solid var(--ag-primary);
  outline-offset: 2px;
}


