/* ============================================================
   QAUK Portal — Design System v2
   Layout: fixed sidebar + white content area
   Palette: slate brand + blue accent
   Font: Inter
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --sidebar-width:     228px;

  /* Brand / sidebar */
  --brand:             #0F172A;
  --brand-mid:         #1E293B;
  --brand-light:       #334155;

  /* Accent */
  --accent:            #2563EB;
  --accent-hover:      #1D4ED8;
  --accent-subtle:     #EFF6FF;

  /* Surfaces */
  --page-bg:           #F8FAFC;
  --surface:           #FFFFFF;
  --surface-subtle:    #F1F5F9;

  /* Borders */
  --border:            #E2E8F0;
  --border-strong:     #CBD5E1;

  /* Shadows */
  --shadow-sm:         0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:         0 4px 12px rgba(0,0,0,0.07);

  /* Text */
  --text:              #0F172A;
  --text-muted:        #64748B;
  --text-light:        #94A3B8;

  /* Status */
  --status-positive:     #059669;
  --status-positive-bg:  #ECFDF5;
  --status-neutral:      #475569;
  --status-neutral-bg:   #F1F5F9;
  --status-negative:     #DC2626;
  --status-negative-bg:  #FEF2F2;
  --status-issued:       #2563EB;
  --status-issued-bg:    #EFF6FF;
  --status-warning:      #D97706;
  --status-warning-bg:   #FFFBEB;
}

/* ── Fonts ─────────────────────────────────────────────────── */
@font-face {
  font-family: 'Americana BT';
  src: url("../fonts/americanabt_roman.b7de8bf5f742.ttf") format('truetype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Americana BT';
  src: url("../fonts/americanabt_bold.64868a833c2b.ttf") format('truetype');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Americana BT';
  src: url("../fonts/americanabt_italic.6f6a240a551a.ttf") format('truetype');
  font-weight: 400; font-style: italic; font-display: swap;
}

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

body {
  font-family: 'Inter', 'Montserrat', sans-serif;
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--page-bg);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Inter', 'Montserrat', sans-serif;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.3;
  margin-bottom: 0.35rem;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
h4 { font-size: 0.92rem; }
h5 { font-size: 0.86rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }

/* ── App layout ────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--brand);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.4rem 1.1rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.sidebar-logo {
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #FFFFFF;
  text-decoration: none;
}
.sidebar-logo span {
  font-weight: 400;
  opacity: 0.55;
  margin-left: 0.2em;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.2rem;
  line-height: 1;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.48rem 0.75rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(255,255,255,0.58);
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}
.sidebar-link:hover {
  background: rgba(255,255,255,0.07);
  color: #FFFFFF;
  text-decoration: none;
}
.sidebar-link.active {
  background: rgba(255,255,255,0.11);
  color: #FFFFFF;
  font-weight: 600;
}
.sidebar-link i {
  font-size: 0.9rem;
  flex-shrink: 0;
  opacity: 0.75;
  width: 1rem;
  text-align: center;
}
.sidebar-link.active i { opacity: 1; }

.sidebar-sub {
  padding-left: 2.3rem;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.42);
}
.sidebar-sub:hover { color: rgba(255,255,255,0.8); }
.sidebar-sub.active { color: rgba(255,255,255,0.9); }

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.07);
  margin: 0.5rem 0.4rem;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 0.65rem 0.6rem;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sidebar-user {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  text-decoration: none;
  min-width: 0;
  transition: background 0.1s;
}
.sidebar-user:hover { background: rgba(255,255,255,0.07); text-decoration: none; }

.sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.14);
  color: #FFFFFF;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-info { min-width: 0; }

.sidebar-user-name {
  font-size: 0.76rem;
  font-weight: 600;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.67rem;
  color: rgba(255,255,255,0.42);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sidebar-signout {
  background: none;
  border: none;
  color: rgba(255,255,255,0.38);
  font-size: 0.95rem;
  padding: 0.4rem;
  border-radius: 5px;
  cursor: pointer;
  transition: color 0.1s, background 0.1s;
  flex-shrink: 0;
}
.sidebar-signout:hover {
  color: #FFFFFF;
  background: rgba(255,255,255,0.08);
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1039;
}
.sidebar-overlay.show { display: block; }

/* ── Mobile header ─────────────────────────────────────────── */
.mobile-header {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.mobile-menu-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text);
  cursor: pointer;
  padding: 0.25rem;
}

.mobile-brand {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand);
}

/* ── Main content ──────────────────────────────────────────── */
.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  background: var(--page-bg);
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  padding: 2.5rem 3rem 5rem;
}

.container-box {
  max-width: 100%;
}

/* Unauthenticated pages */
.auth-main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--page-bg);
}

/* Messages */
.messages-wrap {
  padding: 1rem 3rem 0;
}

/* Impersonation bar */
.impersonate-bar {
  background: var(--status-warning-bg);
  border-bottom: 1px solid #FDE68A;
  color: #92400E;
  font-size: 0.83rem;
  padding: 0.6rem 3rem;
  text-align: center;
}
.impersonate-bar a {
  color: #92400E;
  font-weight: 600;
  text-decoration: underline;
}

/* ── Page headers ──────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

/* Catch Bootstrap's inline page headers */
.d-flex.justify-content-between.align-items-center.mb-3,
.d-flex.justify-content-between.align-items-center.mb-4 {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.75rem !important;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: none;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.card-body {
  padding: 1.75rem;
}

.card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--brand);
}

/* Remove Bootstrap coloured card borders */
.card.border-danger,
.card.border-warning,
.card.border-info,
.card.border-primary,
.card.border-secondary {
  border: none !important;
  box-shadow: var(--shadow-sm) !important;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  font-family: 'Inter', 'Montserrat', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: 6px;
  padding: 0.48rem 1rem;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  border-width: 1px;
}

.btn-primary {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.18);
}

.btn-secondary {
  background-color: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover {
  background-color: var(--surface-subtle);
  border-color: var(--border-strong);
  color: var(--brand);
}

.btn-outline-secondary {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-muted);
}
.btn-outline-secondary:hover {
  background-color: var(--surface-subtle);
  border-color: var(--border-strong);
  color: var(--brand);
}

.btn-outline-primary {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}
.btn-outline-primary:hover {
  background-color: var(--accent);
  color: #FFFFFF;
}

.btn-success {
  background-color: var(--status-positive);
  border-color: var(--status-positive);
  color: #FFFFFF;
}
.btn-success:hover { background-color: #047857; border-color: #047857; color: #FFFFFF; }

.btn-danger {
  background-color: var(--status-negative);
  border-color: var(--status-negative);
  color: #FFFFFF;
}
.btn-danger:hover { background-color: #B91C1C; border-color: #B91C1C; color: #FFFFFF; }

.btn-outline-danger {
  background: transparent;
  border-color: var(--status-negative);
  color: var(--status-negative);
}
.btn-outline-danger:hover { background-color: var(--status-negative); color: #FFFFFF; }

.btn-warning {
  background-color: var(--status-warning);
  border-color: var(--status-warning);
  color: #FFFFFF;
}
.btn-warning:hover { background-color: #B45309; border-color: #B45309; color: #FFFFFF; }

.btn-info {
  background-color: var(--status-issued);
  border-color: var(--status-issued);
  color: #FFFFFF;
}
.btn-info:hover { background-color: var(--accent-hover); border-color: var(--accent-hover); color: #FFFFFF; }

.btn-sm {
  font-size: 0.76rem;
  padding: 0.28rem 0.65rem;
  border-radius: 5px;
}

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  font-family: 'Inter', 'Montserrat', sans-serif;
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.28em 0.6em;
  border-radius: 4px;
}

.badge.bg-success,
.badge.bg-info.text-dark {
  background-color: var(--status-positive-bg) !important;
  color: var(--status-positive) !important;
}
.badge.bg-secondary,
.badge.bg-light,
.badge.bg-primary {
  background-color: var(--status-neutral-bg) !important;
  color: var(--status-neutral) !important;
}
.badge.bg-danger,
.badge.bg-warning.text-dark {
  background-color: var(--status-negative-bg) !important;
  color: var(--status-negative) !important;
}
.badge.bg-warning:not(.text-dark) {
  background-color: var(--status-warning-bg) !important;
  color: var(--status-warning) !important;
}
.badge.bg-info:not(.text-dark) {
  background-color: var(--status-issued-bg) !important;
  color: var(--status-issued) !important;
}
.badge.rounded-pill.bg-danger  { background-color: var(--status-negative) !important; color: #FFFFFF !important; }
.badge.rounded-pill.bg-warning { background-color: var(--status-warning)  !important; color: #FFFFFF !important; }
.badge.rounded-pill.bg-info,
.badge.rounded-pill.bg-primary,
.badge.rounded-pill.bg-secondary { background-color: var(--accent) !important; color: #FFFFFF !important; }

/* ── Tables ────────────────────────────────────────────────── */
.table {
  font-size: 0.86rem;
  color: var(--text);
  border-color: var(--border);
  --bs-table-striped-bg: transparent;
  --bs-table-hover-bg:   #F8FAFC;
}

/* Override table-bordered to horizontal-only */
.table-bordered,
.table-bordered > :not(caption) > * {
  border-width: 0;
}
.table-bordered > :not(caption) > * > * {
  border-width: 0 0 1px 0;
  border-color: var(--border);
}

.table th,
.table-light th {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: transparent;
  border-bottom: 2px solid var(--border) !important;
  border-top: none;
  padding: 0.75rem 1rem;
  white-space: nowrap;
}

.table td {
  padding: 0.8rem 1rem;
  vertical-align: middle;
  border-color: var(--border);
}

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

/* DataTables */
table.dataTable thead th {
  background: transparent;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--border);
}

table.dataTable.no-footer { border-bottom: 1px solid var(--border); }

div.dataTables_wrapper div.dataTables_length label,
div.dataTables_wrapper div.dataTables_filter label,
div.dataTables_wrapper div.dataTables_info,
div.dataTables_wrapper div.dataTables_paginate {
  font-size: 0.78rem;
  color: var(--text-muted);
}

div.dataTables_wrapper div.dataTables_paginate .paginate_button.current,
div.dataTables_wrapper div.dataTables_paginate .paginate_button.current:hover {
  background: var(--accent);
  color: #FFFFFF !important;
  border-color: var(--accent);
  border-radius: 5px;
}

div.dataTables_wrapper div.dataTables_paginate .paginate_button:hover {
  background: var(--surface-subtle);
  color: var(--brand) !important;
  border-color: var(--border);
  border-radius: 5px;
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-control, .form-select {
  font-size: 0.88rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  padding: 0.5rem 0.8rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
  outline: none;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
  display: block;
}

.form-text { font-size: 0.78rem; color: var(--text-muted); }

.input-group-text {
  font-size: 0.88rem;
  background: var(--surface-subtle);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  border-radius: 6px;
}

.form-styled { display: grid; gap: 1.25rem; }

/* ── Fieldsets ─────────────────────────────────────────────── */
fieldset.border {
  border: 1px solid var(--border) !important;
  border-radius: 8px;
  padding: 1.5rem !important;
}
fieldset legend {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0 0.5rem;
}

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
  font-size: 0.86rem;
  border-radius: 7px;
  border: 1px solid transparent;
  border-left: 3px solid;
  padding: 0.85rem 1rem;
}

.alert-success {
  background: var(--status-positive-bg);
  border-left-color: var(--status-positive);
  color: #065F46;
  border-color: #A7F3D0;
}
.alert-warning {
  background: var(--status-warning-bg);
  border-left-color: var(--status-warning);
  color: #92400E;
  border-color: #FDE68A;
}
.alert-danger {
  background: var(--status-negative-bg);
  border-left-color: var(--status-negative);
  color: #991B1B;
  border-color: #FECACA;
}
.alert-info {
  background: var(--accent-subtle);
  border-left-color: var(--accent);
  color: #1E40AF;
  border-color: #BFDBFE;
}

/* ── Tabs ──────────────────────────────────────────────────── */
.nav-tabs {
  border-bottom: 1px solid var(--border);
  gap: 0.15rem;
}
.nav-tabs .nav-link {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  border: none;
  border-radius: 6px 6px 0 0;
  padding: 0.55rem 0.9rem;
  text-decoration: none;
  transition: color 0.12s, background 0.12s;
}
.nav-tabs .nav-link:hover { color: var(--brand); background: var(--surface-subtle); }
.nav-tabs .nav-link.active {
  color: var(--brand);
  background: var(--surface);
  border-bottom: 2px solid var(--accent);
  font-weight: 700;
}

/* ── Utility ───────────────────────────────────────────────── */
.text-muted  { color: var(--text-muted) !important; }
.text-light  { color: var(--text-light) !important; }
hr           { border-color: var(--border); opacity: 1; }
.dropdown-divider { border-color: var(--border); }
.small, small { font-size: 0.8rem; }

/* ── Filter inputs ─────────────────────────────────────────── */
.d-flex.gap-2.flex-wrap.mb-2 .form-control,
.d-flex.gap-2.flex-wrap.mb-2 .form-select {
  font-size: 0.8rem;
  padding: 0.33rem 0.65rem;
}

/* ── Section label ─────────────────────────────────────────── */
.section-label,
h5.text-uppercase.text-muted.fw-semibold {
  font-size: 0.68rem !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.1em;
  color: var(--text-light) !important;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-toggle { display: flex; }
  .mobile-header  { display: flex; }
  .app-main       { margin-left: 0; }
  main            { padding: 1.5rem 1.25rem 4rem; }
  .messages-wrap  { padding: 0.75rem 1.25rem 0; }
  .d-flex.justify-content-between.align-items-center.mb-3,
  .d-flex.justify-content-between.align-items-center.mb-4 {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.75rem;
  }
}
