/* RWAdmin — admin.css
   Dark-accented, structured, no-nonsense. Clean surfaces with deep authority.
   ─────────────────────────────────────────────────────────────────────────── */

/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Core palette — deep navy anchor, warm off-white surface */
  --ink:         #0d0f1a;
  --ink-soft:    #1c1f33;
  --ink-muted:   #2e3350;
  --ink-faint:   #424769;

  --silver:      #f4f3f0;
  --silver-mid:  #e8e7e3;
  --silver-low:  #d4d3ce;

  --accent:      #3d5af1;   /* royal blue — primary action */
  --accent-soft: #eef0fd;
  --accent-dark: #2a3fcc;

  --amber:       #d97706;
  --amber-soft:  #fef3c7;
  --amber-dark:  #92400e;

  --emerald:     #059669;
  --emerald-soft:#ecfdf5;
  --emerald-dark:#065f46;

  --rose:        #dc2626;
  --rose-soft:   #fef2f2;
  --rose-dark:   #991b1b;

  --sky:         #0284c7;
  --sky-soft:    #e0f2fe;
  --sky-dark:    #0c4a6e;

  /* Layout */
  --sidebar-w:   240px;
  --radius-sm:   4px;
  --radius-md:   6px;
  --radius-lg:   10px;

  /* Typography */
  --font: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  /* Shadows — subtle depth, no drama */
  --shadow-sm:   0 1px 3px rgba(13,15,26,0.08), 0 1px 2px rgba(13,15,26,0.05);
  --shadow-md:   0 4px 12px rgba(13,15,26,0.10), 0 2px 4px rgba(13,15,26,0.06);
  --shadow-ring: 0 0 0 3px rgba(61,90,241,0.18);
}

html {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--silver);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-dark);
}

code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: var(--silver-mid);
  border: 1px solid var(--silver-low);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  color: var(--ink-soft);
}

/* ── Admin Shell Layout ─────────────────────────────────────────────────────── */
.admin-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--ink);
  color: #c8cce0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
}

.sidebar-header {
  padding: 28px 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.sidebar-header h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffffff;
  margin-bottom: 2px;
}

.sidebar-header p {
  font-size: 0.72rem;
  color: #676d8f;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 14px 0;
}

.sidebar-nav a {
  display: block;
  padding: 10px 22px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #8892b4;
  letter-spacing: 0.01em;
  border-left: 3px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  text-decoration: none;
}

.sidebar-nav a:hover {
  color: #e0e4f4;
  background: rgba(255,255,255,0.04);
}

.sidebar-nav a.active {
  color: #ffffff;
  background: rgba(61,90,241,0.12);
  border-left-color: var(--accent);
}

.sidebar-footer {
  padding: 16px 22px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.sidebar-footer a {
  font-size: 0.80rem;
  color: #5c6280;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
}

.sidebar-footer a:hover {
  color: #c8cce0;
}

/* ── Main Content Area ──────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 36px 40px;
  max-width: 100%;
  min-height: 100vh;
}

/* ── Page Header ────────────────────────────────────────────────────────────── */
.page-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--silver-low);
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.page-header p {
  font-size: 0.875rem;
  color: var(--ink-faint);
}

/* ── Stats Grid ─────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 30px;
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--silver-mid);
  border-radius: var(--radius-lg);
  padding: 20px 18px;
  box-shadow: var(--shadow-sm);
}

.stat-card h4 {
  font-size: 0.70rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-faint);
  margin-bottom: 10px;
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.03em;
}

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: #ffffff;
  border: 1px solid var(--silver-mid);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--silver-mid);
  background: #fafaf9;
}

.card-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: -0.01em;
}

.card-body {
  padding: 22px;
}

/* ── Two-column layout ──────────────────────────────────────────────────────── */
.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-bottom: 22px;
}

@media (max-width: 900px) {
  .two-column {
    grid-template-columns: 1fr;
  }
}

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  background: var(--silver);
}

thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.70rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--silver-low);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--silver-mid);
  transition: background 0.1s;
}

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

tbody tr:hover {
  background: #fafaf9;
}

tbody td {
  padding: 11px 14px;
  color: var(--ink-soft);
  vertical-align: middle;
}

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.form-group small {
  display: block;
  font-size: 0.75rem;
  color: var(--ink-faint);
  margin-top: 4px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--silver-low);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

.form-control:hover {
  border-color: #b0afaa;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-ring);
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
  line-height: 1.55;
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23424769' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: var(--font);
  font-size: 0.845rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  text-decoration: none;
  line-height: 1;
}

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

/* Primary */
.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #ffffff;
}

/* Secondary */
.btn-secondary {
  background: #ffffff;
  color: var(--ink-soft);
  border-color: var(--silver-low);
}
.btn-secondary:hover {
  background: var(--silver);
  border-color: #b0afaa;
  color: var(--ink);
}

/* Warning */
.btn-warning {
  background: var(--amber);
  color: #ffffff;
  border-color: var(--amber);
}
.btn-warning:hover {
  background: var(--amber-dark);
  border-color: var(--amber-dark);
  color: #ffffff;
}

/* Danger */
.btn-danger {
  background: var(--rose);
  color: #ffffff;
  border-color: var(--rose);
}
.btn-danger:hover {
  background: var(--rose-dark);
  border-color: var(--rose-dark);
  color: #ffffff;
}

/* Small variant */
.btn-sm {
  padding: 5px 11px;
  font-size: 0.785rem;
}

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  white-space: nowrap;
  color: #ffffff;
  background: var(--ink-faint);
}

.badge-success {
  background: var(--emerald);
  color: #ffffff;
}

.badge-warning {
  background: var(--amber);
  color: #ffffff;
}

.badge-danger {
  background: var(--rose);
  color: #ffffff;
}

.badge-info {
  background: var(--sky);
  color: #ffffff;
}

.badge-secondary {
  background: var(--silver-low);
  color: var(--ink-faint);
}

/* ── Filters / Tab Nav ──────────────────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 2px;
  margin-bottom: 18px;
  background: var(--silver-mid);
  border: 1px solid var(--silver-low);
  border-radius: var(--radius-md);
  padding: 3px;
  width: fit-content;
}

.filters a {
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-faint);
  border-radius: calc(var(--radius-md) - 1px);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.filters a:hover {
  background: rgba(255,255,255,0.6);
  color: var(--ink-soft);
}

.filters a.active {
  background: #ffffff;
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ── Pagination ─────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  padding-top: 18px;
  border-top: 1px solid var(--silver-mid);
  margin-top: 18px;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  font-size: 0.845rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-weight: 500;
}

.pagination a {
  color: var(--ink-soft);
  border-color: var(--silver-low);
  background: #ffffff;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.pagination a:hover {
  background: var(--silver);
  border-color: #b0afaa;
  color: var(--ink);
}

.pagination .current {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
}

.pagination .disabled {
  color: var(--silver-low);
  background: transparent;
  cursor: not-allowed;
}

/* ── Alerts / Flash Messages ────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-bottom: 16px;
  border-left: 3px solid;
  font-weight: 500;
}

.alert-success {
  background: var(--emerald-soft);
  color: var(--emerald-dark);
  border-left-color: var(--emerald);
}

.alert-error, .alert-danger {
  background: var(--rose-soft);
  color: var(--rose-dark);
  border-left-color: var(--rose);
}

.alert-warning {
  background: var(--amber-soft);
  color: var(--amber-dark);
  border-left-color: var(--amber);
}

.alert-info {
  background: var(--sky-soft);
  color: var(--sky-dark);
  border-left-color: var(--sky);
}

/* ── Detail Sections ────────────────────────────────────────────────────────── */
.detail-section {
  margin-bottom: 30px;
}

.detail-section:last-child {
  margin-bottom: 0;
}

.detail-section h4 {
  font-size: 0.70rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--ink-faint);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--silver-mid);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.detail-item label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin-bottom: 5px;
}

.detail-item .value {
  font-size: 0.895rem;
  color: var(--ink-soft);
  line-height: 1.5;
  word-break: break-word;
}

/* ── Actions bar ────────────────────────────────────────────────────────────── */
.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--silver-mid);
  flex-wrap: wrap;
}

/* ── Empty State ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
}

.empty-state p {
  font-size: 0.895rem;
  color: var(--ink-faint);
  font-weight: 500;
}

/* ── Login Page ─────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(61,90,241,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(61,90,241,0.05) 0%, transparent 55%);
}

.login-box {
  width: 100%;
  max-width: 380px;
  background: #ffffff;
  border: 1px solid var(--silver-mid);
  border-radius: var(--radius-lg);
  padding: 38px 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35), 0 4px 16px rgba(0,0,0,0.15);
}

.login-box h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-bottom: 24px;
}

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13,15,26,0.55);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

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

.modal {
  background: #ffffff;
  border: 1px solid var(--silver-mid);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--silver-mid);
  background: #fafaf9;
}

.modal-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.modal-body {
  padding: 22px;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--silver-mid);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #fafaf9;
}

/* ── Row highlight states (deadline urgency) ────────────────────────────────── */
/* Overdue rows */
tbody tr[style*="fef2f2"] td {
  color: var(--rose-dark);
}

/* ── Mobile Responsive Styles ────────────────────────────────────────────────── */

/* Mobile menu toggle button */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 101;
  width: 44px;
  height: 44px;
  background: var(--ink);
  border: none;
  border-radius: var(--radius-md);
  color: #ffffff;
  font-size: 1.2rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.mobile-menu-toggle:hover {
  background: var(--ink-soft);
}

/* Tablet and mobile breakpoints */
@media (max-width: 768px) {
  /* Sidebar becomes overlay on mobile */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: 260px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Show mobile menu toggle */
  .mobile-menu-toggle {
    display: flex;
  }

  /* Main content takes full width */
  .main-content {
    margin-left: 0;
    padding: 72px 16px 24px;
    min-height: 100vh;
  }

  /* Page header adjustments */
  .page-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
  }

  .page-header h2 {
    font-size: 1.25rem;
  }

  /* Stats grid - 2 columns on tablet */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
  }

  .stat-card {
    padding: 16px 14px;
  }

  .stat-card .value {
    font-size: 1.5rem;
  }

  /* Cards */
  .card-header {
    padding: 14px 16px;
  }

  .card-body {
    padding: 16px;
  }

  /* Tables - ensure horizontal scroll */
  .table-container {
    margin: 0 -16px;
    padding: 0 16px;
    width: calc(100% + 32px);
  }

  table {
    font-size: 0.8rem;
  }

  thead th,
  tbody td {
    padding: 10px 12px;
  }

  /* Filters wrap on mobile */
  .filters {
    flex-wrap: wrap;
    width: 100%;
  }

  .filters a {
    padding: 8px 12px;
    font-size: 0.78rem;
  }

  /* Detail grid - single column */
  .detail-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  /* Form controls full width */
  .form-control {
    font-size: 16px; /* Prevent zoom on iOS */
  }

  /* Buttons stack on small screens */
  .card-header .btn,
  .actions .btn {
    width: 100%;
    justify-content: center;
  }

  .actions {
    flex-direction: column;
    gap: 8px;
  }

  /* Modal full screen on mobile */
  .modal {
    max-width: calc(100% - 32px);
    margin: 16px;
  }

  /* Login box adjustment */
  .login-box {
    margin: 16px;
    padding: 28px 24px;
  }
}

/* Small phone breakpoint */
@media (max-width: 480px) {
  /* Stats grid - single column */
  .stats-grid {
    grid-template-columns: 1fr;
  }

  /* Table cells more compact */
  thead th,
  tbody td {
    padding: 8px 10px;
    font-size: 0.75rem;
  }

  /* Hide less important columns on very small screens */
  .table-hide-mobile {
    display: none;
  }

  /* Two column becomes single */
  .two-column {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* Page header */
  .page-header h2 {
    font-size: 1.1rem;
  }

  .page-header p {
    font-size: 0.8rem;
  }

  /* Badges smaller */
  .badge {
    padding: 2px 6px;
    font-size: 0.65rem;
  }

  /* Pagination more compact */
  .pagination a,
  .pagination span {
    min-width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13, 15, 26, 0.5);
  z-index: 99;
}

.sidebar-overlay.active {
  display: block;
}

@media (max-width: 768px) {
  .sidebar-overlay.active {
    display: block;
  }
}