/* ============================================================
   HIKMA Design System v2
   Non-invasive: NO global resets, NO body overrides.
   Only defines sidebar, top bar, and opt-in utility classes.
   Pages keep their own CSS — this file is purely additive.
   ============================================================ */

/* ── Shared Tokens (available to all pages, never forced) ──── */
:root {
  --hk-navy:          #1b3a6b;
  --hk-navy-dark:     #122a52;
  --hk-navy-light:    #2a4f8f;
  --hk-accent:        #1d6faf;
  --hk-accent-hover:  #155f97;
  --hk-ok:            #2e7d32;
  --hk-ok-bg:         #e8f5e9;
  --hk-warn:          #b45309;
  --hk-warn-bg:       #fef3c7;
  --hk-breach:        #c62828;
  --hk-breach-bg:     #ffebee;
  --hk-sidebar-w:     240px;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.hk-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--hk-sidebar-w);
  background: var(--hk-navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  font-family: 'Source Sans 3', 'Segoe UI', system-ui, sans-serif;
  transition: transform .25s ease;
}

.hk-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
}
.hk-sidebar-overlay.open { display: block; }

.hk-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}

.hk-sidebar-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(255,255,255,.15);
  border: 2px solid rgba(255,255,255,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  flex-shrink: 0;
}

.hk-sidebar-title {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 2px;
  color: #fff;
}

.hk-sidebar-section {
  padding: 6px 20px;
  font-size: 10px;
  color: rgba(255,255,255,.4);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 700;
  margin-top: 10px;
}

.hk-sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hk-sidebar-item {
  display: block;
}

.hk-sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
  border-left: 3px solid transparent;
}

.hk-sidebar-link:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.hk-sidebar-link.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  border-left-color: #fff;
  font-weight: 700;
}

.hk-sidebar-link .icon {
  width: 20px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
}

.hk-sidebar-footer {
  margin-top: auto;
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: 12px;
  flex-shrink: 0;
}

.hk-sidebar-user {
  margin-bottom: 8px;
  font-size: 12px;
  color: rgba(255,255,255,.7);
}
.hk-sidebar-user strong { color: #fff; }

.hk-sidebar-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hk-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
  animation: hk-pulse 2s infinite;
  box-shadow: 0 0 6px #4ade80;
}
@keyframes hk-pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.hk-logout-btn {
  background: rgba(185,28,28,.85);
  border: 1px solid #b91c1c;
  color: #fff;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.hk-logout-btn:hover { background: #b91c1c; }

/* ── Hamburger Button (hidden on desktop) ─────────────────── */
.hk-hamburger {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 6px 10px;
  line-height: 1;
}

/* ── Desktop: push body content right ─────────────────────── */
@media (min-width: 1025px) {
  body.hk-has-sidebar {
    margin-left: var(--hk-sidebar-w) !important;
  }
  .hk-hamburger { display: none !important; }
}

/* ── Mobile/Tablet: sidebar slides in as overlay ──────────── */
@media (max-width: 1024px) {
  .hk-sidebar {
    transform: translateX(-100%);
  }
  .hk-sidebar.open {
    transform: translateX(0);
  }
  .hk-hamburger {
    display: inline-block;
  }
  body.hk-has-sidebar {
    margin-left: 0 !important;
  }
}

/* ── RTL Support ──────────────────────────────────────────── */
[dir="rtl"] .hk-sidebar {
  left: auto;
  right: 0;
}
[dir="rtl"] .hk-sidebar-link {
  border-left: none;
  border-right: 3px solid transparent;
}
[dir="rtl"] .hk-sidebar-link.active {
  border-right-color: #fff;
}
@media (min-width: 1025px) {
  [dir="rtl"] body.hk-has-sidebar {
    margin-left: 0 !important;
    margin-right: var(--hk-sidebar-w) !important;
  }
}
@media (max-width: 1024px) {
  [dir="rtl"] .hk-sidebar {
    transform: translateX(100%);
  }
  [dir="rtl"] .hk-sidebar.open {
    transform: translateX(0);
  }
}

/* ── Print: hide sidebar ──────────────────────────────────── */
@media print {
  .hk-sidebar, .hk-sidebar-overlay, .hk-hamburger { display: none !important; }
  body.hk-has-sidebar { margin-left: 0 !important; margin-right: 0 !important; }
}

/* ── Hide old portal button (sidebar replaces it) ─────────── */
#hikma-portal-btn { display: none !important; }

/* ── Scrollable header nav on tablet/narrow screens ───────── */
@media (max-width: 1200px) {
  .header-right,
  .topbar-right {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap !important;
  }
  .header-right::-webkit-scrollbar,
  .topbar-right::-webkit-scrollbar { display: none; }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs .tab, .tabs-bar .tab, .tab-btn { white-space: nowrap; }
}
