@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600;9..40,700&family=DM+Serif+Display&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Colors */
  --color-primary:        #2D7A3A;
  --color-primary-hover:  #245F2E;
  --color-primary-light:  #EAF4EC;
  --color-accent:         #4CAF50;
 
  --color-surface:        #FFFFFF;
  --color-background:     #F7F8F6;
  --color-sidebar:        #1C2B1E;
  --color-sidebar-text:   #C8D9CA;
  --color-sidebar-active: #2D7A3A;
 
  --color-text-primary:   #1A1F1B;
  --color-text-secondary: #6B7A6D;
  --color-text-muted:     #9AA89C;
 
  --color-border:         #E4EAE5;
  --color-danger:         #C0392B;
  --color-warning:        #E67E22;
  --color-info:           #2980B9;
  --color-success:        #27AE60;
 
  --color-pending:        #F39C12;
  --color-approved:       #27AE60;
  --color-rejected:       #C0392B;
  --color-dispensed:      #2980B9;

  /* Typography */
  --font-display: "DM Serif Display", serif;
  --font-body:    "DM Sans", sans-serif;
  --font-mono:    "JetBrains Mono", monospace;

  /* Sizes */
  --text-xs:   11px;
  --text-sm:   13px;
  --text-base: 15px;
  --text-lg:   17px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  30px;
  --text-4xl:  38px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-btn: 0 2px 8px rgba(45,122,58,0.25);
}

/* Base Styles */
body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text-primary);
  background-color: var(--color-background);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
}

h1, h2, h3, .font-display {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--color-text-primary);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); font-family: var(--font-body); font-weight: 600; }

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: all 0.2s ease;
}

a:hover {
  color: var(--color-primary-hover);
}

.text-muted { color: var(--color-text-muted) !important; font-size: var(--text-sm); }
.text-secondary { color: var(--color-text-secondary) !important; }
.font-mono { font-family: var(--font-mono) !important; }

/* Loader Skeleton */
.skeleton-loader {
  animation: pulse 1.5s infinite ease-in-out;
  background-color: #e2e8f0;
  border-radius: 4px;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

/* Entrance Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.5s ease forwards;
}

/* Full Screen Loader */
.loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  visibility: hidden;
  opacity: 0;
  transition: all 0.3s ease;
}

.loader-overlay.show {
  visibility: visible;
  opacity: 1;
}

.loader-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-primary-light);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Buttons */
.btn {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--text-base);
  border-radius: 8px;
  padding: 10px 20px;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background-color: var(--color-primary);
  color: white;
  box-shadow: var(--shadow-btn);
}

.btn-primary:hover, .btn-primary:focus {
  background-color: var(--color-primary-hover);
  color: white;
  box-shadow: 0 4px 12px rgba(45,122,58,0.35);
}

.btn-secondary {
  background-color: transparent;
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background-color: var(--color-background);
  color: var(--color-text-primary);
  border-color: var(--color-text-muted);
}

.btn-danger {
  background-color: var(--color-danger);
  color: white;
}

.btn-danger:hover {
  background-color: #a93226;
  color: white;
}

.btn-icon {
  padding: 8px;
  border-radius: 8px;
}

.btn-block {
  width: 100%;
}

/* Inputs */
.form-control, .form-select {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: var(--text-base);
  color: var(--color-text-primary);
  transition: all 0.2s ease;
  background-color: var(--color-surface);
}

.form-control:focus, .form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px var(--color-primary-light);
  outline: none;
}

.form-label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-weight: 500;
  margin-bottom: 6px;
}

.form-control::placeholder {
  color: var(--color-text-muted);
}

/* Cards */
.card-custom {
  background-color: var(--color-surface);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 24px;
  border: none;
  margin-bottom: 24px;
  transition: box-shadow 0.3s ease;
}

.card-custom:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.card-header-custom {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 16px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  margin: 0;
}

/* App Layout */
.app-wrapper {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background-color: var(--color-sidebar);
  color: var(--color-sidebar-text);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  z-index: 1040;
}

.sidebar-brand {
  height: 70px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: white;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-brand svg {
  margin-right: 12px;
  color: var(--color-primary);
}

.sidebar-nav {
  padding: 20px 0;
  overflow-y: auto;
  flex: 1;
}

.nav-section {
  text-transform: uppercase;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  letter-spacing: 1px;
  padding: 16px 24px 8px;
  font-weight: 600;
}

.nav-item {
  margin-bottom: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 10px 24px;
  color: var(--color-sidebar-text);
  transition: all 0.2s ease;
  font-size: var(--text-sm);
  font-weight: 500;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  margin-right: 12px;
  opacity: 0.8;
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: white;
  background-color: rgba(255,255,255,0.05);
}

.nav-link.active {
  background-color: var(--color-sidebar-active);
  color: white;
  border-left: 3px solid white;
}

.nav-link.active svg {
  opacity: 1;
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Topbar */
.topbar {
  height: 70px;
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 10;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
}

.breadcrumb {
  margin: 0;
  padding: 0;
  background: transparent;
  font-size: var(--text-sm);
}

.breadcrumb-item a {
  color: var(--color-text-secondary);
}

.breadcrumb-item.active {
  color: var(--color-text-primary);
  font-weight: 500;
}

.breadcrumb-item + .breadcrumb-item::before {
  content: ">";
  color: var(--color-text-muted);
  font-size: 10px;
}

.topbar-right {
  gap: 20px;
}

.notification-btn {
  background: transparent;
  border: none;
  position: relative;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 5px;
}

.notification-badge {
  position: absolute;
  top: 0;
  right: 2px;
  width: 8px;
  height: 8px;
  background-color: var(--color-danger);
  border-radius: 50%;
  border: 2px solid var(--color-surface);
  box-sizing: content-box;
}

.user-dropdown {
  display: flex;
  align-items: center;
  cursor: pointer;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-sm);
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-primary);
  line-height: 1.2;
}

.user-role {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Page Content */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* Tables */
.table-custom {
  width: 100%;
  margin-bottom: 0;
  color: var(--color-text-primary);
  border-collapse: separate;
  border-spacing: 0;
}

.table-custom th {
  font-size: var(--text-xs);
  text-transform: uppercase;
  color: var(--color-text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--color-border);
  padding: 12px 16px;
  background-color: var(--color-surface);
  letter-spacing: 0.5px;
}

.table-custom td {
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  font-size: var(--text-base);
}

.table-custom tbody tr {
  transition: background-color 0.2s ease;
}

.table-custom tbody tr:hover {
  background-color: var(--color-background);
}

/* Badges */
.badge-status {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: var(--text-xs);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-status::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 6px;
}

.badge-pending {
  background-color: rgba(243, 156, 18, 0.1);
  color: var(--color-pending);
}
.badge-pending::before { background-color: var(--color-pending); }

.badge-approved, .badge-success {
  background-color: rgba(39, 174, 96, 0.1);
  color: var(--color-approved);
}
.badge-approved::before, .badge-success::before { background-color: var(--color-approved); }

.badge-rejected, .badge-danger {
  background-color: rgba(192, 57, 43, 0.1);
  color: var(--color-rejected);
}
.badge-rejected::before, .badge-danger::before { background-color: var(--color-rejected); }

.badge-dispensed, .badge-info {
  background-color: rgba(41, 128, 185, 0.1);
  color: var(--color-dispensed);
}
.badge-dispensed::before, .badge-info::before { background-color: var(--color-dispensed); }

/* Quantity Controls */
.qty-control {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
}

.qty-btn {
  background: var(--color-surface);
  border: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: all 0.2s ease;
}

.qty-btn:hover {
  background: var(--color-background);
  color: var(--color-text-primary);
}

.qty-input {
  width: 50px;
  height: 32px;
  border: none;
  border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  outline: none;
  padding: 0;
}

/* Authentication Layout */
.auth-wrapper {
  display: flex;
  min-height: 100vh;
}

.auth-banner {
  flex: 1;
  background-color: var(--color-sidebar);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.auth-banner::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(45,122,58,0.9) 0%, rgba(28,43,30,0.9) 100%);
  z-index: 1;
}

.auth-banner-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.5;
}

.auth-banner-content {
  position: relative;
  z-index: 2;
  color: white;
  text-align: center;
  padding: 40px;
}

.auth-banner-content h1 {
  color: white;
  margin-bottom: 16px;
}

.auth-form-container {
  flex: 1;
  max-width: 500px;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px;
}

.auth-logo {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  color: var(--color-primary);
  margin-bottom: 40px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Auth password strength */
.password-strength {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.strength-bar {
  flex: 1;
  height: 4px;
  background-color: var(--color-border);
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* Layout Utilities classes */
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.gap-4 { gap: 24px; }
.flex-1 { flex: 1; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  color: var(--color-text-muted);
  margin-bottom: 24px;
  opacity: 0.5;
}

/* Print CSS */
@media print {
  .sidebar, .topbar, .btn:not(.btn-print), .no-print {
    display: none !important;
  }
  .main-content, .page-content {
    padding: 0;
    margin: 0;
    overflow: visible;
  }
  .card-custom {
    box-shadow: none;
    border: 1px solid #ddd;
  }
  body {
    background: white;
  }
}

/* Responsiveness */
.mobile-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--color-text-primary);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  margin-right: 16px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.5);
  z-index: 1030;
  opacity: 0;
  transition: opacity 0.3s ease;
}

@media (max-width: 1199px) { /* Tablet */
  .sidebar { width: 80px; }
  .sidebar-brand span, .nav-link span, .nav-section { display: none; }
  .sidebar-brand svg, .nav-link svg { margin-right: 0; margin: 0 auto; }
  .sidebar:hover { width: 240px; position: absolute; height: 100%; box-shadow: var(--shadow-md); }
  .sidebar:hover .sidebar-brand span, .sidebar:hover .nav-link span, .sidebar:hover .nav-section { display: block; }
  .sidebar:hover .sidebar-brand svg, .sidebar:hover .nav-link svg { margin-right: 12px; margin-left: 0; }
}

@media (max-width: 767px) { /* Mobile */
  .auth-wrapper { flex-direction: column; }
  .auth-banner { display: none; } /* Simplified top banner for mobile */
  .auth-form-container { max-width: 100%; padding: 30px 20px; }
  
  .mobile-toggle { display: block; }
  .sidebar { 
    position: fixed; 
    left: -240px; 
    top: 0; 
    bottom: 0; 
    width: 240px; 
    transition: left 0.3s ease;
  }
  .sidebar.show { left: 0; }
  .sidebar-overlay.show { display: block; opacity: 1; }
  
  /* Reset tablet hover logic on mobile */
  .sidebar:hover { width: 240px; }
  .sidebar-brand span, .nav-link span, .nav-section { display: block; }
  .sidebar-brand svg, .nav-link svg { margin-right: 12px; }
  
  .page-content { padding: 16px; }
}
