/* ============================================================
   Koulourades Dashboard — Dual Logicom
   Color palette: Steel Blue #4B9CC8 / Dark Navy #1a2d42
   ============================================================ */

:root {
  --primary:        #4B9CC8;
  --primary-dark:   #2d7aaa;
  --primary-light:  #e8f3fb;
  --sidebar-bg:     #1a2d42;
  --sidebar-hover:  #243d57;
  --sidebar-active: #2d5278;
  --sidebar-text:   #c8d8e8;
  --sidebar-muted:  #6e8fa8;
  --topbar-height:  60px;
  --sidebar-width:  240px;
  --bg:             #f0f3f8;
  --card-bg:        #ffffff;
  --border:         #dee2e6;
  --text:           #2d3748;
  --muted:          #718096;
  --green:          #27ae60;
  --orange:         #f39c12;
  --red:            #e74c3c;
  --teal:           #17a2b8;
}

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

body {
  font-family: 'Roboto', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 0.925rem;
  margin: 0;
}

a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

.fw-500 { font-weight: 500; }

/* ── Layout ───────────────────────────────────────────────── */
.wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 1040;
  transition: width 0.28s cubic-bezier(.4,0,.2,1), transform 0.28s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}

.sidebar-header {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.sidebar-logo-link {
  display: block;
  width: 100%;
}
.sidebar-logo-full {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}
.sidebar-logo-icon {
  display: none;
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 6px;
}

.sidebar-nav {
  list-style: none;
  padding: 8px 0;
  margin: 0;
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav .nav-section {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--sidebar-muted);
  padding: 16px 18px 4px;
  font-weight: 700;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 0;
  transition: background .15s, color .15s;
  font-size: 0.9rem;
}

.sidebar-nav .nav-link i { font-size: 1rem; flex-shrink: 0; }
.sidebar-nav .nav-link:hover  { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--sidebar-active); color: #fff; border-left: 3px solid var(--primary); }

.sidebar-footer {
  padding: 12px 18px;
  font-size: 0.75rem;
  color: #fff;
}

/* Collapse button at bottom of sidebar */
.sidebar-collapse-wrap {
  border-top: 1px solid rgba(255,255,255,.07);
  padding: 4px 8px;
}
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 0.875rem;
  transition: background .15s, color .15s;
}
.sidebar-collapse-btn:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-collapse-btn i { font-size: 1rem; flex-shrink: 0; }

/* Collapsed sidebar */
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .sidebar-logo-full { display: none; }
.sidebar.collapsed .sidebar-logo-icon { display: block; margin: 0 auto; }
.sidebar.collapsed .sidebar-logo-link { width: auto; }
.sidebar.collapsed .sidebar-header { padding: 10px 8px; display: flex; justify-content: center; }
.sidebar.collapsed .nav-section,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .collapse-label,
.sidebar.collapsed .sidebar-footer { display: none; }
.sidebar.collapsed .nav-link { justify-content: center; padding: 10px; }
.sidebar.collapsed .nav-link i { font-size: 1.2rem; }
.sidebar.collapsed .sidebar-collapse-btn { justify-content: center; padding: 8px; }
.sidebar.collapsed .sidebar-collapse-wrap { padding: 4px; }
/* margin-left on .main-content is set exclusively by app.js (desktop only) */

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

/* ── Main content ─────────────────────────────────────────── */
.main-content {
  margin-left: 0;
  flex: 1;
  min-width: 0;          /* prevent flex item from expanding beyond parent */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.28s cubic-bezier(.4,0,.2,1);
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.sidebar-toggle {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--muted);
  cursor: pointer;
  display: none;
  padding: 4px 6px;
  border-radius: 6px;
}
.sidebar-toggle:hover { background: var(--bg); }

.topbar-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

@media (max-width: 991.98px) {
  .topbar-title {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: calc(100vw - 160px); /* leave room for toggle btn + user dropdown */
  }
}

.topbar-user-btn {
  color: var(--text);
  text-decoration: none;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Content area ─────────────────────────────────────────── */
.content-area {
  padding: 24px;
  flex: 1;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  min-width: 0;
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.card-body { padding: 18px; }

/* ── Stat cards ───────────────────────────────────────────── */
.stat-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  border-top: 4px solid transparent;
}

.stat-blue   { border-top-color: var(--primary); }
.stat-green  { border-top-color: var(--green);   }
.stat-orange { border-top-color: var(--orange);  }
.stat-teal   { border-top-color: var(--teal);    }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.stat-blue   .stat-icon { background: rgba(75,156,200,.12); color: var(--primary); }
.stat-green  .stat-icon { background: rgba(39,174,96,.12);  color: var(--green);   }
.stat-orange .stat-icon { background: rgba(243,156,18,.12); color: var(--orange);  }
.stat-teal   .stat-icon { background: rgba(23,162,184,.12); color: var(--teal);    }

.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; color: var(--text); }
.stat-label { font-size: 0.78rem; color: var(--muted); margin-top: 3px; }

/* ── Tables ───────────────────────────────────────────────── */
.table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  background: #f8fafc;
  white-space: nowrap;
}
.table td { vertical-align: middle; font-size: 0.88rem; }
.table-hover tbody tr:hover { background: var(--primary-light); }
.store-link { color: var(--text); font-weight: 500; }
.store-link:hover { color: var(--primary); }

/* ── Badges ───────────────────────────────────────────────── */
.badge { font-size: 0.7rem; font-weight: 600; padding: 3px 8px; border-radius: 20px; }
.badge-active     { background: rgba(39,174,96,.15);   color: #1e8449; }
.badge-inactive   { background: rgba(243,156,18,.15);  color: #c87f10; }
.badge-upcoming   { background: rgba(23,162,184,.15);  color: #0d7a8c; }
.badge-terminated { background: rgba(231,76,60,.15);   color: #b03a2e; }
.badge-yes  { background: rgba(39,174,96,.12);  color: #1e8449; font-size: .7rem; }
.badge-no   { background: rgba(231,76,60,.12);  color: #b03a2e; font-size: .7rem; }
.badge-admin  { background: rgba(75,156,200,.18); color: var(--primary-dark); }
.badge-editor { background: rgba(23,162,184,.15); color: #0d7a8c; }
.badge-viewer { background: #e9ecef; color: #6c757d; }
.badge-secondary { background: #e9ecef; color: #6c757d; }

/* ── Equipment tags ───────────────────────────────────────── */
.equip-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: .3px;
}
.equip-elzab,
.equip-ics,
.equip-other,
.equip-tag { color: var(--text); }

/* ── Category pill ────────────────────────────────────────── */
.category-pill {
  display: inline-block;
  font-size: 0.72rem;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 20px;
  padding: 2px 9px;
  font-weight: 500;
  white-space: nowrap;
}

/* ── Info list (key–value pairs) ──────────────────────────── */
.info-list {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 4px 12px;
  margin: 0;
}
.info-list dt { font-weight: 600; font-size: 0.8rem; color: var(--muted); align-self: start; padding-top: 3px; }
.info-list dd { margin: 0; font-size: 0.88rem; word-break: break-word; padding-bottom: 4px; border-bottom: 1px solid #f0f3f8; }

/* ── Small buttons ────────────────────────────────────────── */
.btn-xs { font-size: 0.75rem; padding: 2px 7px; }

/* ── Breadcrumb ───────────────────────────────────────────── */
.breadcrumb { font-size: 0.83rem; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Form ─────────────────────────────────────────────────── */
.form-label { font-weight: 500; font-size: 0.85rem; margin-bottom: 4px; }
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 .2rem rgba(75,156,200,.2);
}
.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

/* ── Pagination ───────────────────────────────────────────── */
.page-link { color: var(--primary); }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* ── Stat card links ──────────────────────────────────────── */
.stat-card-link { text-decoration: none; display: block; }
.stat-card-link:hover .stat-card { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.1); transition: all .2s; }
.stat-card { transition: all .2s; }

/* ============================================================
   Login Page
   ============================================================ */
body.login-page {
  background: linear-gradient(135deg, #0f1e2e 0%, #1a3550 50%, #243d57 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-card {
  background: #fff;
  border-radius: 14px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  width: 100%;
}

.login-logo-wrap {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo {
  max-width: 200px;
  height: auto;
}

.login-title {
  font-size: 1.35rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
  color: var(--text);
}

.login-subtitle {
  font-size: 0.82rem;
  text-align: center;
  color: var(--muted);
  margin-bottom: 28px;
}

.btn-login {
  padding: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: .3px;
}

.login-footer {
  margin-top: 20px;
  color: rgba(255,255,255,.45);
  font-size: 0.78rem;
  text-align: center;
}

/* ── Table sort ───────────────────────────────────────────── */
.sort-link {
  color: var(--muted);
  text-decoration: none;
  display: block;
  white-space: nowrap;
}
.sort-link:hover { color: var(--primary); }
.sort-link.sort-active { color: var(--primary-dark); }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { background: #eef2f7; }

/* ── Alert tweaks ─────────────────────────────────────────── */
.alert { border-radius: 8px; font-size: 0.88rem; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 991.98px) {
  .sidebar-toggle { display: flex; align-items: center; }
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
    height: 100vh;
    height: 100dvh; /* dynamic viewport height — accounts for mobile browser chrome */
    overflow-y: auto;
    overflow-x: hidden;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .sidebar-collapse-wrap { display: none; }
}

@media (max-width: 575.98px) {
  .content-area { padding: 14px; }
  .login-card { padding: 28px 20px; }
  .info-list { grid-template-columns: 110px 1fr; }
  .stat-value { font-size: 1.5rem; }
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
html, body { overflow-x: hidden; max-width: 100%; }
.wrapper { overflow-x: hidden; max-width: 100%; }
.content-area { overflow-x: hidden; }
