/* ============================================================
   True North Defence Portal — Stylesheet
   Branding: Dark Navy / Steel Blue / Maple Red
   ============================================================ */

:root {
  --navy-deep:   #0a1628;
  --navy-dark:   #0f1c2e;
  --navy-mid:    #1a2744;
  --navy-light:  #243354;
  --blue-accent: #1d6fa4;
  --blue-hover:  #2d8cc4;
  --blue-light:  #e8f4fd;
  --red-maple:   #c41e3a;
  --red-light:   #fde8eb;
  --white:       #ffffff;
  --gray-50:     #f8fafc;
  --gray-100:    #f1f5f9;
  --gray-200:    #e2e8f0;
  --gray-300:    #cbd5e1;
  --gray-400:    #94a3b8;
  --gray-500:    #64748b;
  --gray-600:    #475569;
  --gray-700:    #334155;
  --gray-800:    #1e293b;
  --green:       #16a34a;
  --green-light: #dcfce7;
  --yellow:      #ca8a04;
  --yellow-light:#fef9c3;
  --text-main:   #1e293b;
  --text-muted:  #64748b;
  --border:      #e2e8f0;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow:      0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:   0 8px 24px rgba(0,0,0,.14);
  --sidebar-w:   260px;
  --topbar-h:    64px;
}

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

html { font-size: 16px; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text-main);
  background: var(--gray-50);
  line-height: 1.6;
}

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

/* ---- PORTAL WRAP ---- */
.portal-wrap {
  display: flex;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--navy-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--navy-light);
}

.sidebar-logo { flex-shrink: 0; }

.sidebar-brand-text { display: flex; flex-direction: column; }
.brand-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--white);
  line-height: 1.2;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.brand-sub {
  font-size: 11px;
  color: var(--blue-accent);
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: var(--gray-400);
  font-size: 14px;
  font-weight: 500;
  transition: all .15s;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--navy-mid);
  color: var(--white);
  text-decoration: none;
}
.nav-item.active {
  background: rgba(29,111,164,.15);
  color: var(--white);
  border-left-color: var(--blue-accent);
}
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--navy-light);
}
.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.user-avatar {
  width: 36px; height: 36px;
  background: var(--blue-accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: var(--white); }
.user-role { font-size: 11px; color: var(--gray-400); }

.logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--gray-400);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 0;
  transition: color .15s;
  text-decoration: none;
}
.logout-btn:hover { color: var(--red-maple); text-decoration: none; }

/* ---- MAIN CONTENT ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- TOP BAR ---- */
.top-bar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.sidebar-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.sidebar-toggle span {
  display: block;
  width: 22px; height: 2px;
  background: var(--gray-600);
  border-radius: 2px;
}
.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy-mid);
  flex: 1;
}
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge-alert {
  background: var(--red-maple);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.badge-alert:hover { background: #a31830; color: #fff; text-decoration: none; }

/* ---- CONTENT AREA ---- */
.content-area {
  padding: 28px;
  flex: 1;
}

/* ---- FLASH MESSAGES ---- */
.flash {
  margin: 0 28px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  border-left: 4px solid;
}
.flash-success { background: var(--green-light);  color: #15803d; border-color: var(--green); }
.flash-error   { background: var(--red-light);    color: #9b1c2e; border-color: var(--red-maple); }
.flash-info    { background: var(--blue-light);   color: #1d4e89; border-color: var(--blue-accent); }
.flash-warning { background: var(--yellow-light); color: #854d0e; border-color: var(--yellow); }

/* ---- CARDS ---- */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}
.card-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy-mid);
}
.card-body { padding: 24px; }
.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ---- DASHBOARD STAT CARDS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 32px; font-weight: 700; color: var(--navy-mid); line-height: 1; }
.stat-sub   { font-size: 12px; color: var(--text-muted); }
.stat-icon  { width: 40px; height: 40px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; }
.stat-icon-blue  { background: var(--blue-light);  color: var(--blue-accent); }
.stat-icon-green { background: var(--green-light); color: var(--green); }
.stat-icon-red   { background: var(--red-light);   color: var(--red-maple); }
.stat-icon-gray  { background: var(--gray-100);    color: var(--gray-600); }

/* ---- TABLES ---- */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
thead th {
  background: var(--gray-50);
  color: var(--gray-600);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }
tbody td { padding: 12px 16px; vertical-align: middle; }
.td-actions { display: flex; gap: 6px; align-items: center; }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn-primary   { background: var(--blue-accent); color: #fff; }
.btn-primary:hover   { background: var(--blue-hover); color: #fff; }
.btn-danger      { background: var(--red-maple); color: #fff; }
.btn-danger:hover      { background: #a31830; color: #fff; }
.btn-warning     { background: #d97706; color: #fff; border-color: transparent; }
.btn-warning:hover     { background: #b45309; color: #fff; }

/* ── Danger zone (edit pages) ──────────────────────────────── */
.danger-zone {
  margin-top: 32px;
  padding: 16px 20px;
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  background: #fff5f5;
}
.danger-zone-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--red-maple);
  margin-bottom: 12px;
}
.danger-zone-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.btn-success   { background: var(--green); color: #fff; }
.btn-success:hover   { background: #15803d; color: #fff; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--gray-200); color: var(--gray-800); }
.btn-outline   { background: transparent; color: var(--blue-accent); border: 1px solid var(--blue-accent); }
.btn-outline:hover   { background: var(--blue-light); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* ---- BADGES ---- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.badge-green  { background: var(--green-light);  color: #15803d; }
.badge-red    { background: var(--red-light);    color: #9b1c2e; }
.badge-yellow { background: var(--yellow-light); color: #854d0e; }
.badge-gray   { background: var(--gray-100);     color: var(--gray-600); }
.badge-blue   { background: var(--blue-light);   color: var(--blue-accent); }

/* ---- FORMS ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.form-full { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}
.form-label .req { color: var(--red-maple); margin-left: 2px; }

.form-control {
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-main);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
  width: 100%;
}
.form-control:focus {
  outline: none;
  border-color: var(--blue-accent);
  box-shadow: 0 0 0 3px rgba(29,111,164,.12);
}
.form-control[readonly] { background: var(--gray-50); color: var(--gray-600); }
select.form-control { cursor: pointer; }
textarea.form-control { min-height: 90px; resize: vertical; }

.form-hint { font-size: 12px; color: var(--text-muted); }
.form-error { font-size: 12px; color: var(--red-maple); }

.form-section {
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.form-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.form-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy-mid);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  margin-top: 24px;
}

/* ---- AUTH PAGES ---- */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--navy-deep) 0%, var(--navy-mid) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  padding: 40px;
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}
.auth-logo-text .brand-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--navy-mid);
  text-transform: uppercase;
  letter-spacing: .5px;
  display: block;
}
.auth-logo-text .brand-sub {
  font-size: 12px;
  color: var(--blue-accent);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.auth-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy-mid);
  margin-bottom: 6px;
}
.auth-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 28px;
}
.auth-divider {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin: 20px 0;
  position: relative;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }
.auth-footer { text-align: center; margin-top: 24px; font-size: 13px; color: var(--text-muted); }

/* ---- DETAIL VIEW (key-value pairs) ---- */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.detail-row {
  display: contents;
}
.detail-label, .detail-value {
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.detail-label {
  font-weight: 600;
  color: var(--gray-600);
  padding-right: 20px;
  width: 40%;
}
.detail-value { color: var(--text-main); }
.detail-full {
  grid-column: 1 / -1;
  border-bottom: 1px solid var(--border);
  padding: 11px 0;
}

/* ---- TABS ---- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}
.tab-btn {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab-btn:hover { color: var(--navy-mid); }
.tab-btn.active { color: var(--blue-accent); border-bottom-color: var(--blue-accent); }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state svg { opacity: .3; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ---- MISC UTILITIES ---- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center  { display: flex; align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-right { text-align: right; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.text-red    { color: var(--red-maple); }
.text-green  { color: var(--green); }
.text-blue   { color: var(--blue-accent); }

.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  border-left: 4px solid;
  margin-bottom: 20px;
}
.alert-info    { background: var(--blue-light);   color: #1d4e89; border-color: var(--blue-accent); }
.alert-warning { background: var(--yellow-light); color: #854d0e; border-color: var(--yellow); }
.alert-danger  { background: var(--red-light);    color: #9b1c2e; border-color: var(--red-maple); }
.alert-success { background: var(--green-light);  color: #15803d; border-color: var(--green); }

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.breadcrumb a { color: var(--blue-accent); }
.breadcrumb-sep { color: var(--gray-300); }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content-area { padding: 20px; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .auth-box { padding: 28px 20px; }
}
