/* =====================================================
   PROJECT INFRASTRUCTURE PORTAL — CUSTOM STYLES
   ===================================================== */

/* ---- CSS Variables ---- */
:root {
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 60px;
  --sidebar-bg: #1a1f2e;
  --sidebar-text: #a8b3cf;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: rgba(28, 150, 197, 0.18);
  --sidebar-active-border: #1C96C5;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
  --navbar-height: 60px;
  --primary: #1C96C5;
  --primary-dark: #1580aa;
  --body-bg: #f4f6fb;
  --card-radius: 10px;
  --transition: 0.22s ease;
}

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

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--body-bg);
  color: #1e293b;
  font-size: 14px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* =====================================================
   LAYOUT WRAPPER
   ===================================================== */
.wrapper {
  min-height: 100vh;
}

/* =====================================================
   SIDEBAR
   ===================================================== */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition);
  z-index: 200;
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.brand-icon {
  /* width: 34px; */
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-icon img {
  width: 100%;
  height: 34px;
  object-fit: fill;
}
.brand-text {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition);
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-nav ul { list-style: none; padding: 0; margin: 0; }
.sidebar-nav .nav-item { margin: 1px 8px; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--sidebar-text);
  border-radius: 7px;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.sidebar-nav .nav-link:hover {
  background: var(--sidebar-hover-bg);
  color: #fff;
}
.sidebar-nav .nav-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active);
  border-left: 3px solid var(--sidebar-active-border);
  padding-left: 9px;
}
.nav-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.nav-label {
  transition: opacity var(--transition);
}

/* Section labels */
.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(168, 179, 207, 0.45);
  padding: 14px 20px 4px;
  list-style: none;
}

/* Footer */
.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.btn-sidebar-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: none;
  border: none;
  color: var(--sidebar-text);
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.btn-sidebar-logout:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

/* Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 199;
}

/* =====================================================
   COLLAPSED SIDEBAR
   ===================================================== */
.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}
.sidebar-collapsed .brand-text,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .nav-section-label,
.sidebar-collapsed .btn-sidebar-logout span {
  opacity: 0;
  pointer-events: none;
  width: 0;
  overflow: hidden;
}
.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding: 20px 0;
}
.sidebar-collapsed .sidebar-nav .nav-item {
  margin: 1px 6px;
}
.sidebar-collapsed .sidebar-nav .nav-link {
  justify-content: center;
  padding: 10px;
}
.sidebar-collapsed .sidebar-nav .nav-link.active {
  border-left: none;
  border-bottom: 3px solid var(--sidebar-active-border);
}
.sidebar-collapsed .sidebar-footer {
  display: flex;
  justify-content: center;
}
.sidebar-collapsed .btn-sidebar-logout {
  justify-content: center;
  padding: 10px;
}

/* =====================================================
   MAIN CONTENT
   ===================================================== */
.main-content {
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =====================================================
   TOP NAVBAR
   ===================================================== */
.top-navbar {
  height: var(--navbar-height);
  background: #fff;
  border-bottom: 1px solid #e8ecf3;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.sidebar-toggle {
  color: #64748b !important;
  transition: color var(--transition);
}
.sidebar-toggle:hover { color: var(--primary) !important; }

/* Avatar */
.avatar-circle {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

/* =====================================================
   PAGE BODY
   ===================================================== */
.page-body {
  flex: 1;
  padding-top: 20px;
}

/* =====================================================
   PAGE HEADER
   ===================================================== */
.page-header {
  margin-bottom: 20px;
}
.page-title {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
}
.breadcrumb {
  font-size: 12px;
}
.breadcrumb-item a {
  color: var(--primary);
  text-decoration: none;
}
.breadcrumb-item a:hover { text-decoration: underline; }

/* =====================================================
   STAT CARDS
   ===================================================== */
.stat-card {
  border-radius: var(--card-radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.15s, box-shadow 0.15s;
  color: #fff;
  text-decoration: none;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.13);
}
.stat-icon {
  width: 48px;
  height: 48px;
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}
.stat-label {
  font-size: 12px;
  opacity: 0.88;
  margin-top: 3px;
}

/* Stat card colour variants */
.stat-blue    { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-green   { background: linear-gradient(135deg, #22c55e, #16a34a); }
.stat-purple  { background: linear-gradient(135deg, #a855f7, #7c3aed); }
.stat-orange  { background: linear-gradient(135deg, #f97316, #ea580c); }
.stat-red     { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-yellow  { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-teal    { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.stat-indigo  { background: linear-gradient(135deg, #6366f1, #4f46e5); }

/* =====================================================
   CARDS
   ===================================================== */
.card {
  border-radius: var(--card-radius) !important;
}
.card-header {
  border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
  font-size: 14px;
}

/* =====================================================
   TABLES
   ===================================================== */
.table th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  white-space: nowrap;
}
.table td { font-size: 13.5px; }
.table-hover tbody tr:hover { background: #f8faff; }

/* =====================================================
   BADGES
   ===================================================== */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 5px;
}

/* =====================================================
   BUTTONS
   ===================================================== */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}
.btn-xs {
  padding: 2px 7px;
  font-size: 11px;
  border-radius: 4px;
}

/* =====================================================
   FORMS
   ===================================================== */
.form-control, .form-select {
  font-size: 13.5px;
  border-color: #e2e8f0;
  border-radius: 7px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.form-label { color: #374151; }
.form-text  { font-size: 11.5px; }
.input-group-text {
  border-color: #e2e8f0;
  font-size: 13px;
}

/* =====================================================
   PAGINATION
   ===================================================== */
.page-link {
  font-size: 13px;
  border-radius: 6px !important;
  border-color: #e2e8f0;
  color: #374151;
  padding: 5px 11px;
}
.page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
}
.page-item.disabled .page-link { color: #cbd5e1; }

/* =====================================================
   EMPTY STATES
   ===================================================== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
}
.empty-state i { display: block; margin-bottom: 12px; }

/* =====================================================
   FLASH ALERTS
   ===================================================== */
#flash-container .alert {
  border: none;
  border-radius: 8px;
  font-size: 13.5px;
}
.alert-success {
  background: #f0fdf4;
  color: #166534;
}
.alert-danger {
  background: #fef2f2;
  color: #991b1b;
}

/* =====================================================
   NAV TABS
   ===================================================== */
.nav-tabs {
  border-bottom: 2px solid #e8ecf3;
  gap: 4px;
}
.nav-tabs .nav-link {
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 8px 14px;
  border-radius: 0;
  transition: color var(--transition), border-color var(--transition);
}
.nav-tabs .nav-link:hover { color: var(--primary); }
.nav-tabs .nav-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: none;
  font-weight: 600;
}

/* =====================================================
   LOGIN PAGE
   ===================================================== */
.login-body {
  background: linear-gradient(135deg, #1a1f2e 0%, #2d3561 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-wrapper {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 36px 36px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.35);
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand-icon {
  width: 70px;
  height: 70px;
  background: #fff;
  border: 2px solid #e8ecf3;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}
.login-brand-name {
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}
.login-brand-sub {
  font-size: 12.5px;
  color: #94a3b8;
  margin: 0;
}

/* =====================================================
   UTILITY
   ===================================================== */
.x-small   { font-size: 11.5px; }
.font-monospace { font-family: 'SFMono-Regular', Consolas, monospace !important; }
.white-pre { white-space: pre-wrap; }

/* Colour helpers */
.text-purple { color: #a855f7 !important; }
.text-indigo { color: #6366f1 !important; }
.text-teal   { color: #14b8a6 !important; }
.text-orange { color: #f97316 !important; }

/* =====================================================
   SCROLLBAR (webkit)
   ===================================================== */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }

/* =====================================================
   RESPONSIVE — MOBILE
   ===================================================== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    height: 100vh;
    transition: left var(--transition);
    z-index: 300;
  }
  .sidebar-mobile-open .sidebar {
    left: 0;
  }
  .sidebar-mobile-open .sidebar-overlay {
    display: block;
  }
  .main-content {
    width: 100%;
  }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 22px; }
  .login-card { padding: 28px 22px; }
  .page-body { padding-top: 14px; }
}

@media (max-width: 480px) {
  .top-navbar { padding: 0 14px; }
  .page-body { padding: 14px 0 0; }
}
