:root {
  /* Color System - Slate & Indigo */
  --primary: #4f46e5; /* Indigo 600 */
  --primary-hover: #4338ca; /* Indigo 700 */
  --secondary: #64748b; /* Slate 500 */
  --success: #10b981; /* Emerald 500 */
  --danger: #ef4444; /* Red 500 */
  --warning: #f59e0b; /* Amber 500 */
  --info: #3b82f6; /* Blue 500 */

  /* Neutrals */
  --bg-body: #f8fafc; /* Slate 50 */
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9; /* Slate 100 */
  
  --text-main: #0f172a; /* Slate 900 */
  --text-muted: #64748b; /* Slate 500 */
  --text-subtle: #94a3b8; /* Slate 400 */

  --border-color: #e2e8f0; /* Slate 200 */
  --border-focus: #6366f1; /* Indigo 500 */

  /* Spacing & Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  /* Override Bootstrap font variables to match body font-family */
  --bs-body-font-family: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  --bs-font-sans-serif: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

body {
  font-family: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

input, textarea, select, button {
  font-family: inherit;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-main);
  font-weight: 600;
  letter-spacing: -0.025em;
}

.page-title {
  font-weight: 700;
  color: var(--text-main);
}

.numeric {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.text-label {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.35rem;
  display: block;
  opacity: 0.9;
}

.text-value {
  color: var(--text-main);
  font-weight: 500;
  font-size: 1rem;
}

.text-value-lg {
  color: var(--text-main);
  font-weight: 600;
  font-size: 1.375rem;
  letter-spacing: -0.02em;
}

.bg-gradient-subtle {
  background: linear-gradient(145deg, var(--bg-surface) 0%, var(--bg-subtle) 100%);
}

.stat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  transition: all 0.2s ease;
}

.stat-card:hover {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-sm);
}

.text-border {
  color: var(--border-color);
}



.text-muted {
  color: var(--text-muted) !important;
}

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

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

/* Navbar */
.navbar {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.navbar-brand {
  font-weight: 700;
  color: var(--text-main) !important;
  font-size: 1.25rem;
}

.nav-link {
  color: var(--text-muted) !important;
  font-weight: 500;
  padding: 0.5rem 1rem !important;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
  color: var(--primary) !important;
  background-color: var(--bg-subtle);
}

/* Cards */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.card.border-0 {
  border: 0 !important;
}

.card-header {
  background-color: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
  font-weight: 600;
}

/* Forms */
.form-control, .form-select {
  border-color: var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.875rem;
  font-size: 0.95rem;
  color: var(--text-main);
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.form-control:focus, .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-label {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

/* Buttons */
.btn {
  font-weight: 500;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 1px 2px 0 rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}

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

/* Tables */
.table-responsive {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  overflow: hidden;
  overflow-x: auto; /* Ensure horizontal scroll */
}

.table {
  margin-bottom: 0;
  width: 100%;
}

.table thead th {
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.8125rem;
  letter-spacing: 0.05em;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table tbody td {
  padding: 1rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 1rem;
  white-space: nowrap;
}

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

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

/* Badges */
.badge-soft {
  background-color: #e0e7ff;
  color: var(--primary);
  padding: 0.35em 0.65em;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.7rem;
}

/* Login Page specific */
.login-card {
  border: none;
  box-shadow: var(--shadow-lg);
}

/* Utilities */
/* Custom Scrollbar for tables */
.table-responsive::-webkit-scrollbar {
  height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
  background: var(--bg-body);
}

.table-responsive::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
  background-color: #94a3b8;
}

/* Filter Section */
.filter-section {
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
}

/* Additional Utilities */
.text-main {
  color: var(--text-main) !important;
}

.fw-medium {
  font-weight: 500 !important;
}

.text-sm {
  font-size: 0.9375rem;
}

.audit-changes {
  font-family: inherit;
  font-size: 0.75rem;
  line-height: 1.35;
}

.tracking-wider {
  letter-spacing: 0.05em;
}

.cursor-pointer {
  cursor: pointer;
}

.hover-opacity-100 {
  transition: opacity 0.2s;
}

.hover-opacity-100:hover {
  opacity: 1 !important;
}

.hover-primary {
  transition: color 0.15s ease;
}

.hover-primary:hover {
  color: var(--primary) !important;
}

.hover-danger {
  transition: color 0.15s ease;
}

.hover-danger:hover {
  color: var(--danger) !important;
}

/* =========================================
   Task 3 Enhancements: UI Polish & A11y
   ========================================= */

/* 1. Mobile Card View */
@media (max-width: 575.98px) {
  .table-card-view thead {
    display: none;
  }

  .table-card-view tbody tr {
    display: block;
    margin-bottom: 1rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
  }

  .table-card-view tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    text-align: right;
    white-space: normal;
  }

  .table-card-view tbody td:last-child {
    border-bottom: none;
  }

  .table-card-view tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 1rem;
    text-align: left;
    font-size: 0.85rem;
    text-transform: uppercase;
  }

  /* Compact variant (used for wide tables like Orders) */
  .table-card-view.table-card-compact tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.25rem 0.75rem;
    padding: 0.75rem;
  }

  .table-card-view.table-card-compact tbody td {
    padding: 0.35rem 0.25rem;
    border-bottom: none;
    text-align: left;
    justify-content: space-between;
    align-items: baseline;
    min-width: 0;
    white-space: normal;
  }

  .table-card-view.table-card-compact tbody td::before {
    margin-right: 0.5rem;
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
  }

  .table-card-view.table-card-compact tbody td.mobile-full {
    grid-column: 1 / -1;
    padding: 0.25rem 0.25rem 0.75rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--border-color);
  }

  .table-card-view.table-card-compact tbody td.mobile-header::before {
    display: none;
  }

  .table-card-view.table-card-compact tbody td.mobile-hide {
    display: none;
  }

  .table-card-view.table-card-compact .mobile-value {
    flex: 1 1 auto;
    min-width: 0;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .table-card-view.table-card-compact tbody td.mobile-full .mobile-value {
    text-align: left;
  }

  .table-card-view.table-card-compact tbody td.ps-4 {
    padding-left: 0.25rem !important;
  }

  .table-card-view.table-card-compact tbody td.pe-4 {
    padding-right: 0.25rem !important;
  }

  .table-card-view.table-card-compact tbody td.text-end {
    text-align: left;
  }
}

/* 2. Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

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

.btn:focus-visible, 
.form-control:focus-visible, 
.form-select:focus-visible,
a:focus-visible {
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2); /* Matching Indigo ring */
}

/* Button active state */
.btn:active {
  transform: translateY(0);
}

/* Progress bar visual polish */
.progress {
  background-color: var(--bg-subtle);
  border-radius: 999px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

.progress-bar {
  border-radius: 999px;
}
