/* Modern responsive and accessible styles */
:root { 
  color-scheme: light dark;
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --secondary-color: #64748b;
  --success-color: #059669;
  --warning-color: #d97706;
  --error-color: #dc2626;
  --background: #f8fafc;
  --surface: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

* { 
  box-sizing: border-box; 
}

body { 
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; 
  margin: 0; 
  background: var(--background); 
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 14px;
}

/* Header and Footer */
header, footer { 
  background: var(--gradient);
  color: #fff; 
  padding: 16px 20px;
  box-shadow: var(--shadow);
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header strong {
  font-size: 1.25rem;
  font-weight: 600;
}

header a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  transition: color 0.2s;
}

header a:hover {
  color: #fff;
}

footer {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.875rem;
  opacity: 0.8;
}

/* Layout */
main { 
  padding: 24px 16px;
  min-height: calc(100vh - 140px);
}

.container { 
  max-width: 1200px; 
  margin: 0 auto; 
}

/* Cards */
.card { 
  background: var(--surface); 
  border-radius: 12px; 
  box-shadow: var(--shadow);
  padding: 24px; 
  margin-bottom: 20px;
  border: 1px solid var(--border);
  transition: box-shadow 0.2s, transform 0.2s;
}

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

.card h2, .card h3 {
  margin-top: 0;
  color: var(--text-primary);
  font-weight: 600;
}

.card h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.card h3 {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

/* Forms */
label {
  display: block;
  margin-bottom: 4px;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.875rem;
}

input, select, button, textarea { 
  font: inherit; 
  padding: 12px 16px; 
  width: 100%; 
  margin: 8px 0 16px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-size: 14px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input[type="email"], input[type="password"], input[type="text"], input[type="time"] {
  background: var(--surface);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 16px;
  padding-right: 40px;
  background-color: var(--surface);
}

/* Buttons */
button { 
  background: var(--primary-color); 
  color: #fff; 
  border: none; 
  border-radius: 8px; 
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.2s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:hover { 
  background: var(--primary-hover);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  background: var(--secondary-color);
  cursor: not-allowed;
  transform: none;
}

/* Button loading state */
button.loading {
  position: relative;
}
button.loading::after {
  content: '';
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.6);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Tables */
.table { 
  width: 100%; 
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table th, .table td { 
  padding: 12px 16px; 
  border-bottom: 1px solid var(--border); 
  text-align: left; 
}

.table th {
  background: var(--primary-light);
  font-weight: 600;
  color: var(--primary-color);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table tr:hover {
  background: rgba(37, 99, 235, 0.02);
}

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

/* Alerts */
.alert { 
  padding: 16px 20px; 
  border-radius: 8px; 
  margin: 16px 0;
  border-left: 4px solid;
  font-weight: 500;
}

/* Toasts */
.toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}
.toast {
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  background: var(--surface);
  border-left: 4px solid var(--border);
  color: var(--text-primary);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.info { 
  border-left-color: #3b82f6; 
  background: #eff6ff; /* light blue tint for better visibility */
  color: #1e40af; /* stronger readable blue text */
}
.toast.success { 
  border-left-color: #22c55e; 
  background: #f0fdf4; /* light green tint */
  color: #166534; /* strong green text */
}
.toast.warn { 
  border-left-color: #f59e0b; 
  background: #fffbeb; /* light amber tint */
  color: #92400e; /* strong amber text */
}
.toast.error { 
  border-left-color: #ef4444; 
  background: #fef2f2; /* light red tint */
  color: #991b1b; /* strong red text */
}

.alert.info { 
  background: #eff6ff; 
  color: #1e40af;
  border-left-color: #3b82f6;
}

.alert.warn { 
  background: #fffbeb; 
  color: #92400e;
  border-left-color: #f59e0b;
}

.alert.error { 
  background: #fef2f2; 
  color: #991b1b;
  border-left-color: #ef4444;
}

.alert.success { 
  background: #f0fdf4; 
  color: #166534;
  border-left-color: #22c55e;
}

.alert svg {
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

/* Table responsiveness */
.table-responsive { overflow-x: auto; }
.table-responsive .table { min-width: 720px; }

/* Login Page Specific */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient);
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header h1 {
  color: var(--text-primary);
  font-size: 1.875rem;
  font-weight: 700;
  margin: 0 0 8px 0;
}

.login-header p {
  color: var(--text-secondary);
  margin: 0;
  font-size: 0.875rem;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-form button {
  margin-top: 8px;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.login-footer a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
}

.login-footer a:hover {
  text-decoration: underline;
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary-color);
  transition: transform 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-card h3 {
  margin: 0 0 8px 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
  margin: 0;
}

.stat-card .stat-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 4px 0 0 0;
  font-weight: 500;
}

.stat-card-warning {
  border-left-color: #eab308; /* subtle amber */
  background: var(--surface); /* remove gradient for better readability */
}

.stat-card-warning .stat-value {
  color: var(--text-primary); /* keep strong readability */
}

.stat-card-warning h3 {
  color: var(--text-secondary);
}

/* small list inside stat card */
.stat-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0 0;
}
.stat-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  padding: 2px 0;
}
.stat-list a {
  color: var(--text-primary);
}

/* Action Buttons */
.action-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.action-buttons button {
  padding: 16px 24px;
  font-size: 1rem;
  font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
  main {
    padding: 16px 12px;
  }
  
  .card {
    padding: 20px 16px;
  }
  
  .login-card {
    padding: 32px 24px;
  }
  
  header .container {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
  
  .table {
    font-size: 0.875rem;
  }
  
  .table th, .table td {
    padding: 8px 12px;
  }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --background: #0f172a;
    --surface: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #334155;
  }
  /* Dark mode toast visibility */
  .toast {
    background: var(--surface);
    color: var(--text-primary);
  }
  .toast.info { background: rgba(59, 130, 246, 0.15); }
  .toast.success { background: rgba(34, 197, 94, 0.15); }
  .toast.warn { background: rgba(245, 158, 11, 0.15); }
  .toast.error { background: rgba(239, 68, 68, 0.15); }
  
  .login-container {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  }
  
  .stat-card {
    border-left-color: #3b82f6;
  }
}