/* CRAI Reports Design System — shares the dashboard (app.css) palette & type */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;900&display=swap');

:root {
  --paper: #f4f0e8;
  --paper2: #faf7f1;
  --card: #fffdf9;
  --ink: #1b2030;
  --ink2: #4a4f60;
  --muted: #7c8092;
  --line: #e3ddd0;
  --line2: #ece6d9;
  --coral: #df4f33;
  --coral-bg: #fbe6df;
  --teal: #0c8276;
  --teal-bg: #d9eee9;
  --amber: #cf971f;
  --amber-bg: #f7eccf;
  --navy: #22304e;
  --plum: #7a4a8c;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(27, 32, 48, 0.05), 0 8px 24px rgba(27, 32, 48, 0.06);
  --shadow-lg: 0 4px 12px rgba(27, 32, 48, 0.08), 0 24px 60px rgba(27, 32, 48, 0.14);
  /* Same UI font as the dashboard; system fallbacks keep it right offline. */
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  /* Match the dashboard's subtle corner tints */
  background-image:
    radial-gradient(circle at 12% 8%, rgba(223, 79, 51, 0.04), transparent 38%),
    radial-gradient(circle at 88% 4%, rgba(12, 130, 118, 0.05), transparent 42%);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--coral); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 var(--space-md); color: var(--ink); font-weight: 600; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 var(--space-md); color: var(--ink2); }

/* Layout */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-brand {
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand h1 { color: #fff; font-size: 1.25rem; margin: 0; }
.sidebar-brand span { color: rgba(255,255,255,0.6); font-size: 0.8rem; }
.sidebar-nav { flex: 1; padding: var(--space-md) 0; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.7rem var(--space-lg);
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 0.95rem;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
  text-decoration: none;
}
.sidebar-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
}
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: var(--space-md) var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.page-body { padding: var(--space-xl); flex: 1; }

/* Auth layout */
.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  /* Inherits the body paper + radial tints so it reads as part of the dashboard */
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2xl);
}
.auth-brand { text-align: center; margin-bottom: var(--space-xl); }
.auth-brand .logo {
  width: 52px; height: 52px;
  /* Same navy → coral gradient mark as the dashboard header logo */
  background: linear-gradient(135deg, var(--navy), var(--coral));
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  font-size: 1.2rem;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow);
  margin-bottom: var(--space-md);
}
.auth-brand h1 { font-size: 1.5rem; margin-bottom: var(--space-xs); }
.auth-brand p { margin: 0; font-size: 0.9rem; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--space-lg);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--line2);
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow);
}
.stat-card .label { font-size: 0.85rem; color: var(--muted); margin-bottom: var(--space-xs); }
.stat-card .value { font-size: 2rem; font-weight: 700; color: var(--ink); }
.stat-card.teal .value { color: var(--teal); }
.stat-card.coral .value { color: var(--coral); }
.stat-card.amber .value { color: var(--amber); }
.stat-card.plum .value { color: var(--plum); }

/* Forms */
.form-group { margin-bottom: var(--space-lg); }
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: var(--space-sm);
}
.form-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper2);
  color: var(--ink);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus {
  outline: none;
  /* Coral focus ring — same as the dashboard's filter inputs */
  border-color: var(--coral);
  box-shadow: 0 0 0 3px var(--coral-bg);
}
.form-input.error { border-color: var(--coral); }
.form-error { color: var(--coral); font-size: 0.8rem; margin-top: var(--space-xs); }
.form-hint { color: var(--muted); font-size: 0.8rem; margin-top: var(--space-xs); }
.input-group { position: relative; }
.input-group .form-input { padding-right: 2.75rem; }
.input-toggle {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.35rem;
  font-size: 0.8rem;
}
.input-toggle:hover { color: var(--ink); }
.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.9rem;
  color: var(--ink2);
}
.form-check input { accent-color: var(--teal); }

/* Password strength */
.strength-bar {
  height: 4px;
  background: var(--line2);
  border-radius: 2px;
  margin-top: var(--space-sm);
  overflow: hidden;
}
.strength-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.2s, background 0.2s;
  width: 0;
}
.strength-label { font-size: 0.75rem; color: var(--muted); margin-top: var(--space-xs); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  text-decoration: none;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #0a6f65; }
.btn-secondary { background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover:not(:disabled) { background: var(--line2); }
.btn-danger { background: var(--coral); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c9442b; }
.btn-ghost { background: transparent; color: var(--ink2); border: 1px solid transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--paper2); }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* Alerts */
.alert {
  padding: var(--space-md);
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
}
.alert-error { background: var(--coral-bg); color: #8b2e1c; border: 1px solid #f0c4b8; }
.alert-error a { color: #065a52; font-weight: 600; }
.alert-success { background: var(--teal-bg); color: #065a52; border: 1px solid #b5ddd6; }
.alert-info { background: var(--amber-bg); color: #7a5a0f; border: 1px solid #e8d9a0; }
.alert[hidden] { display: none !important; }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-admin { background: var(--plum); color: #fff; }
.badge-user { background: var(--teal-bg); color: var(--teal); }
.badge-active { background: var(--teal-bg); color: var(--teal); }
.badge-disabled { background: var(--coral-bg); color: var(--coral); }

/* Table */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.data-table th,
table.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--line2);
}
table.data-table th {
  background: var(--paper2);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
table.data-table tr:hover td { background: var(--paper2); }
.table-actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; }

/* Spinner */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner.dark {
  border-color: var(--line);
  border-top-color: var(--teal);
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(244, 240, 232, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.loading-overlay .spinner { width: 36px; height: 36px; border-width: 3px; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(27, 32, 48, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: var(--space-lg);
}
.modal-backdrop[hidden] { display: none !important; }
.modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  padding: var(--space-xl);
}
.modal h3 { margin-bottom: var(--space-md); }
.modal-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
  margin-top: var(--space-xl);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--muted);
}
.empty-state svg { margin-bottom: var(--space-md); opacity: 0.4; }

/* Profile */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
}
.profile-field label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: var(--space-xs); }
.profile-field .value { font-size: 1rem; color: var(--ink); font-weight: 500; }

/* Utilities */
.text-muted { color: var(--muted); }
.text-center { text-align: center; }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-lg { margin-bottom: var(--space-lg); }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
[hidden] { display: none !important; }

/* Responsive */
@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .sidebar-nav { display: flex; overflow-x: auto; padding: var(--space-sm); }
  .sidebar-nav a { white-space: nowrap; padding: 0.5rem 1rem; }
  .page-body { padding: var(--space-md); }
  .auth-card { padding: var(--space-xl); }
}
