/* =====================================================
   FIGMA THEME (Tokens + Component Specs)
   Source: design-tokens.json + component-specs.json
   ===================================================== */

:root{
  --transition-fast: 0.2s;
  --transition-ease: cubic-bezier(0.4, 0.0, 0.2, 1);
  --focus-ring-width: 3px;
}
body.material-body{
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}


body.material-body[data-theme="light"]{
  --bg-page: #ffffff;
  --bg-page-gradient: linear-gradient(to bottom right, #f1f5f9, #e5e7eb, #e2e8f0);
  --header-gradient: linear-gradient(to right, #1e293b, #0f172a, #111827);
  --text-primary: #030213;
  --text-secondary: #717182;
  --text-muted: #717182;
  --text-inverse: #ffffff;

  --brand-primary: #030213;
  --brand-secondary: #f0f0f5;
  --brand-accent: #e9ebef;
  --brand-danger: #d4183d;
  --brand-warning: #f59e0b;
  --brand-success: #10b981;
  --brand-info: #3b82f6;

  --surface-card: #ffffff;
  --surface-card-alt: #f3f3f5;
  --surface-input: #f3f3f5;
  --surface-sidebar: #fafafa;

  --border-default: rgba(0, 0, 0, 0.1);
  --border-subtle: #ececf0;
  --border-strong: #cbced4;

  --sidebar-bg: #fafafa;
  --sidebar-fg: #030213;
  --sidebar-accent: #f8f8f8;
  --sidebar-accent-fg: #363636;
  --sidebar-active-bg: #030213;
  --sidebar-active-fg: #fafafa;
  --sidebar-border: #ebebeb;
  --ring: #b5b5b5;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px 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);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-elevated: 0 8px 16px rgba(0, 0, 0, 0.12);

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-pill: 9999px;
}


body.material-body[data-theme="dark"]{
  --bg-page: #252525;
  --bg-page-gradient: linear-gradient(to bottom right, #1f2937, #111827, #0f172a);
  --header-gradient: linear-gradient(to right, #1e293b, #0f172a, #111827);
  --text-primary: #fafafa;
  --text-secondary: #b5b5b5;
  --text-muted: #b5b5b5;
  --text-inverse: #363636;

  --brand-primary: #fafafa;
  --brand-secondary: #454545;
  --brand-accent: #454545;
  --brand-danger: #653239;
  --brand-warning: #78350f;
  --brand-success: #065f46;
  --brand-info: #1e40af;

  --surface-card: #252525;
  --surface-card-alt: #363636;
  --surface-input: #454545;
  --surface-sidebar: #363636;

  --border-default: #454545;
  --border-subtle: #383838;
  --border-strong: #5a5a5a;

  --sidebar-bg: #363636;
  --sidebar-fg: #fafafa;
  --sidebar-accent: #454545;
  --sidebar-accent-fg: #fafafa;
  --sidebar-active-bg: #7c5fde;
  --sidebar-active-fg: #fafafa;
  --sidebar-border: #454545;
  --ring: #707070;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-elevated: 0 8px 16px rgba(0, 0, 0, 0.6);

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-pill: 9999px;
}


body.material-body[data-theme="light"]{
  background: var(--bg-page-gradient);
  color: var(--text-primary);
}
body.material-body[data-theme="dark"]{
  background: var(--bg-page-gradient);
  color: var(--text-primary);
}


/* ===== Layout ===== */
.app-shell{ display:flex; min-height:100vh; }
.sidebar{
  width:256px;
  min-height:100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  border-right:1px solid var(--sidebar-border);
  transition: transform var(--transition-fast) var(--transition-ease);
}
.sidebar .sidebar-header{ padding:16px; }
.brand-logo{ height:34px; width:auto; border-radius: var(--radius-sm); }
.brand-title{ font-weight:600; color: var(--sidebar-fg); }
.brand-subtitle{ font-size:12px; color: var(--text-secondary); }
.sidebar-menu{ list-style:none; padding: 0 12px 16px; margin:0; display:flex; flex-direction:column; gap:4px;}
.sidebar-section-title{
  padding: 14px 10px 6px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .75;
  color: var(--sidebar-fg);
  user-select: none;
}
.sidebar-section-title:first-child{ padding-top: 10px; }
.sidebar-divider{ height:1px; background: var(--sidebar-border); margin:12px 0; opacity:.8; }

/* -----------------------------
   Admin Log Viewer
   ----------------------------- */
.crs-log-viewer{
  border:1px solid rgba(255,255,255,0.12);
  border-radius:14px;
  background:rgba(0,0,0,0.22);
  overflow:hidden;
}

.crs-log-pre{
  margin:0;
  padding:14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size:12px;
  line-height:1.45;
  max-height:65vh;
  overflow:auto;
  color:rgba(255,255,255,0.92);
}

@media (max-width: 768px){
  .crs-log-pre{ max-height:55vh; }
}
.menu-item{
  display:flex; align-items:center; gap:10px;
  padding:8px 12px;
  border-radius:6px;
  color: var(--sidebar-fg);
  text-decoration:none;
  transition: background var(--transition-fast) var(--transition-ease), color var(--transition-fast) var(--transition-ease);
}
.menu-item:hover{ background: var(--sidebar-accent); color: var(--sidebar-accent-fg); }
.menu-item.active{ background: var(--sidebar-active-bg); color: var(--sidebar-active-fg); }
.menu-item:focus-visible{ outline:none; box-shadow: 0 0 0 var(--focus-ring-width) rgba(181,181,181,0.5); }

.content-wrap{ flex:1; display:flex; flex-direction:column; }
.material-nav{
  height:72px;
  padding:16px;
  background: var(--header-gradient);
  color:#ffffff;
  border-bottom:1px solid #334155;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  display:flex;
  align-items:center;
}
.page-title-main{ font-size:18px; font-weight:600; color:#ffffff; }
.page-title-sub{ font-size:12px; color: rgba(255,255,255,0.75); }
.user-pill{
  display:flex; align-items:center; gap:8px;
  padding:6px 10px;
  border-radius: 9999px;
  background: rgba(255,255,255,0.1);
  border:1px solid rgba(255,255,255,0.2);
}
.user-pill .role-badge{
  font-size:12px;
  padding:2px 8px;
  border-radius:6px;
  background: rgba(255,255,255,0.15);
}

.content-area{ padding:24px; }
@media (max-width: 768px){
  .sidebar{ position:fixed; left:0; top:0; z-index:1040; transform: translateX(-110%); }
  .sidebar.open{ transform: translateX(0); box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); }
  .content-area{ padding:16px; }
}
#sidebar-overlay{
  display:none;
  position:fixed;
  inset:0;
  background: rgba(0,0,0,0.35);
  z-index:1030;
}


/* ===== Cards ===== */
.card, .material-card{
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  box-shadow: none;
}
.card:hover, .material-card:hover{ box-shadow: var(--shadow-card); }
.card-header{
  background: transparent;
  border-bottom: none;
  padding:24px 24px 0 24px;
}
.card-body{ padding: 16px 24px 24px 24px; }




/* ===== Quick Action Cards (Dashboard shortcuts) ===== */
a.quick-action{
  display:block;
  padding: 14px 16px;
  color: var(--text-primary);
  text-decoration: none;
}
a.quick-action:visited{ color: var(--text-primary); }
a.quick-action:hover{
  color: var(--text-primary);
  background: var(--surface-card-alt);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}
a.quick-action:active{ transform: translateY(0); }
a.quick-action .text-muted{ color: var(--text-muted) !important; }
a.quick-action .fw-bold{ letter-spacing: 0.2px; }
/* ===== Buttons (override Bootstrap) ===== */
.btn{
  border-radius: var(--radius-md);
  transition: background var(--transition-fast) var(--transition-ease), transform var(--transition-fast) var(--transition-ease), box-shadow var(--transition-fast) var(--transition-ease);
}
.btn:focus{ box-shadow:none; }
.btn:focus-visible{
  outline:none;
  box-shadow: 0 0 0 var(--focus-ring-width) rgba(181,181,181,0.5);
}
.btn-primary{
  background: var(--brand-primary);
  border-color: transparent;
  color: #ffffff;
}
.btn-primary:hover{ background: rgba(3,2,19,0.9); border-color: transparent; }
.btn-primary:active{ background: rgba(3,2,19,0.8) !important; border-color: transparent !important; }
.btn-secondary{
  background: var(--brand-secondary);
  border-color: transparent;
  color: var(--brand-primary);
}
.btn-secondary:hover{ background: rgba(240,240,245,0.8); }
.btn-outline-secondary{
  background: transparent;
  border-color: var(--border-default);
  color: var(--brand-primary);
}
.btn-outline-secondary:hover{ background: var(--brand-accent); border-color: var(--border-default); }
.btn-danger{
  background: var(--brand-danger);
  border-color: transparent;
}
.btn-danger:hover{ background: rgba(212,24,61,0.9); border-color: transparent; }


/* ===== Inputs ===== */
.form-control, .form-select, textarea{
  background: var(--surface-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--brand-primary);
  min-height:36px;
}
.form-control::placeholder{ color: var(--text-secondary); }
.form-control:focus, .form-select:focus, textarea:focus{
  border-color: var(--ring);
  outline: none;
  box-shadow: 0 0 0 var(--focus-ring-width) rgba(181,181,181,0.5);
}
.form-control:disabled, .form-select:disabled, textarea:disabled{
  opacity: 0.6;
}


/* ===== Tables ===== */
.table{ color: var(--brand-primary); }
.table thead th{
  font-weight:500;
  border-bottom: 1px solid var(--border-default);
  padding:8px;
  height:40px;
}
.table tbody td{
  border-bottom: 1px solid var(--border-default);
  padding:8px;
}
.table tbody tr:hover{ background: var(--surface-card-alt); }


/* ===== Alerts / Toast ===== */
.alert{
  border-radius: var(--radius-md);
  border:1px solid var(--border-default);
}
#toast-container{
  position: fixed;
  top: 90px;
  right: 16px;
  z-index: 1060;
  display:flex;
  flex-direction:column;
  gap: 10px;
}
.toast-item{
  min-width: 356px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  box-shadow: var(--shadow-lg);
}
.toast-item.success{ background: var(--brand-success); color:#fff; border-color: transparent; }
.toast-item.error{ background: var(--brand-danger); color:#fff; border-color: transparent; }
.toast-item.warning{ background: var(--brand-warning); color:#fff; border-color: transparent; }


/* Compatibility: legacy class names */
.btn-material{
  background: var(--sidebar-active-bg);
  border-color: transparent;
  color: var(--sidebar-active-fg);
  border-radius: var(--radius-md);
}
.btn-material:hover{ filter: brightness(1.05); color: var(--sidebar-active-fg); }


/* =========================
   Pagination (Figma spec)
   ========================= */
.crs-pagination-nav{
  display:flex;
  justify-content:flex-end;
}
.crs-pagination{
  gap: 4px;
}
.crs-pagination .page-link{
  width: 36px;
  height: 36px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary, #030213);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 14px;
  line-height: 1;
  transition: background var(--transition-fast) var(--transition-ease),
              border-color var(--transition-fast) var(--transition-ease);
}
.crs-pagination .page-item.disabled .page-link{
  opacity: 0.5;
  pointer-events: none;
}
.crs-pagination .page-link:hover{
  background: var(--brand-accent, #e9ebef);
}
.crs-pagination .page-item.active .page-link{
  background: var(--surface-card, #ffffff);
  border-color: var(--border-default, rgba(0,0,0,0.1));
}

/* Wider prev/next buttons */
.crs-pagination .page-link[aria-label="Previous"],
.crs-pagination .page-link[aria-label="Next"]{
  width: auto;
  padding: 8px 10px;
}

/* =========================
   Dialog / Modal (Figma spec)
   ========================= */
.crs-modal .modal-content{
  border-radius: 8px;
  border: 1px solid var(--border-default, rgba(0,0,0,0.1));
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  background: var(--surface-card, #fff);
  color: var(--text-primary, #030213);
}
.crs-modal .modal-header{
  border-bottom: none;
  padding: 16px 24px 8px 24px;
}
.crs-modal .modal-body{
  padding: 0 24px 16px 24px;
  color: var(--text-secondary, #717182);
}
.crs-modal .modal-footer{
  border-top: none;
  padding: 0 24px 24px 24px;
  gap: 8px;
}
.crs-modal .modal-title{
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
}


/* ===== Auth (Login/Forgot/OTP/Reset) ===== */
.auth-shell{
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  background: var(--bg-page-gradient);
}
.auth-card{
  width: 100%;
  max-width: 980px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: color-mix(in srgb, var(--surface-card) 86%, transparent);
  box-shadow: var(--shadow-lg, 0 20px 40px rgba(0,0,0,0.35));
}
.auth-card--split{
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  min-height: 520px;
}
.auth-hero{
  position: relative;
  padding: 44px 44px 36px;
  border-right: 1px solid var(--border-default);
  background:
    radial-gradient(800px 400px at 0% 0%, rgba(124,95,222,0.35), transparent 60%),
    radial-gradient(600px 300px at 100% 100%, rgba(124,95,222,0.18), transparent 55%),
    linear-gradient(135deg, rgba(17,24,39,0.6), rgba(15,23,42,0.8));
}
body.material-body[data-theme="light"] .auth-hero{
  background:
    radial-gradient(800px 400px at 0% 0%, rgba(124,95,222,0.18), transparent 60%),
    radial-gradient(600px 300px at 100% 100%, rgba(124,95,222,0.12), transparent 55%),
    linear-gradient(135deg, rgba(241,245,249,0.9), rgba(226,232,240,0.95));
}
.auth-hero-inner{
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 26px;
}
.auth-hero-brand{
  display: flex;
  align-items: center;
  gap: 12px;
}
.auth-hero-logo{
  height: 44px;
  width: 44px;
  object-fit: contain;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  padding: 6px;
  border: 1px solid rgba(255,255,255,0.08);
}
body.material-body[data-theme="light"] .auth-hero-logo{
  background: rgba(3,2,19,0.04);
  border-color: rgba(3,2,19,0.08);
}
.auth-hero-name{
  font-weight: 700;
  font-size: 18px;
  color: var(--text-primary);
}
.auth-hero-tagline{
  font-size: 12px;
  color: var(--text-muted);
}
.auth-hero-title{
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.auth-hero-subtitle{
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 44ch;
}
.auth-hero-points{
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 13px;
}
.auth-hero-points i{
  color: var(--sidebar-active-bg);
  margin-right: 10px;
}
.auth-hero-footnote{
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--border-default) 65%, transparent);
}
.auth-panel{
  padding: 34px 34px 22px;
  background: var(--surface-card);
  display: flex;
  flex-direction: column;
}
.auth-header{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.auth-title{
  font-weight: 800;
  font-size: 18px;
  color: var(--text-primary);
}
.auth-subtitle{
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.auth-body h3{
  font-weight: 800;
  letter-spacing: -0.01em;
}
.auth-footer{
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-default);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.auth-theme-toggle{
  border-color: color-mix(in srgb, var(--border-default) 70%, transparent) !important;
  color: var(--text-primary) !important;
}
@media (max-width: 992px){
  .auth-card--split{ grid-template-columns: 1fr; min-height: unset; }
  .auth-hero{ display: none; }
  .auth-panel{ padding: 28px 18px 18px; }
  .auth-card{ max-width: 520px; }
}



/* ===== Bootstrap utility color alignment (prevents invisible text on theme toggle) ===== */
body.material-body .text-muted{ color: var(--text-muted) !important; }
body.material-body .text-secondary,
body.material-body .text-body-secondary{ color: var(--text-secondary) !important; }
body.material-body .text-body{ color: var(--text-primary) !important; }
body.material-body .text-dark{ color: var(--text-primary) !important; }
body.material-body .text-light{ color: var(--text-inverse) !important; }
body.material-body .form-label{ color: var(--text-primary) !important; }

/* Links */
body.material-body a{ color: inherit; }
body.material-body a:hover{ color: var(--brand-info); }
body.material-body a.auth-link{ color: var(--brand-info) !important; text-decoration: none; }
body.material-body a.auth-link:hover{ text-decoration: underline; }

/* Make Bootstrap striped tables compatible with themes */
body.material-body .table-striped > tbody > tr:nth-of-type(odd) > *{
  background-color: color-mix(in srgb, var(--surface-card-alt) 55%, transparent) !important;
  color: inherit;
}

/* Table header contrast */
body.material-body[data-theme="dark"] .table thead th{ color: var(--text-secondary) !important; }
