/* ==================================================================
   Twilight Solar Inventory — design system
   A "twilight → solar" theme: deep indigo dusk tones in the sidebar/
   brand surfaces, a warm amber accent standing in for the sun, and a
   calm, professional light workspace for the actual data-entry work.
   ================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --sidebar-width: 252px;
  --sidebar-width-collapsed: 76px;
  --topbar-height: 64px;

  /* Brand */
  --brand-primary: #4f46e5;
  --brand-primary-dark: #4338ca;
  --brand-primary-darker: #3730a3;
  --brand-primary-light: #eef2ff;
  --brand-accent: #f59e0b;
  --brand-accent-dark: #d97706;

  /* Sidebar (twilight sky) */
  --sidebar-from: #181633;
  --sidebar-to: #322d6b;
  --sidebar-text: rgba(255, 255, 255, 0.78);
  --sidebar-text-strong: #ffffff;

  /* Semantic */
  --color-success: #16a34a;
  --color-danger: #dc2626;
  --color-warning: #f59e0b;
  --color-info: #0891b2;

  /* Neutrals / surfaces */
  --bg: #f4f5fb;
  --surface: #ffffff;
  --border: #e7e8f1;
  --border-strong: #d8d9ea;
  --text: #14162b;
  --text-muted: #6b7086;
  --text-faint: #9498ab;

  /* Shape */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(20, 22, 43, 0.05);
  --shadow-sm: 0 2px 8px rgba(20, 22, 43, 0.06);
  --shadow-md: 0 8px 24px rgba(20, 22, 43, 0.08);
  --shadow-lg: 0 16px 40px rgba(20, 22, 43, 0.14);

  /* Bootstrap variable bridge — keeps components that reference these in sync */
  --bs-body-font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --bs-primary: var(--brand-primary);
  --bs-primary-rgb: 79, 70, 229;
  --bs-border-radius: var(--radius-sm);
  --bs-border-radius-lg: var(--radius-md);
  --bs-body-color: var(--text);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  background-color: var(--bg);
  font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4, h5, h6 { font-weight: 700; letter-spacing: -0.01em; }

::selection { background: var(--brand-primary-light); color: var(--brand-primary-darker); }

/* Slim, unobtrusive scrollbars everywhere (Chromium/Firefox) */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-pill); }
*::-webkit-scrollbar-track { background: transparent; }

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ==================================================================
   Sidebar
   ================================================================== */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(165deg, var(--sidebar-from) 0%, var(--sidebar-to) 100%);
  color: var(--sidebar-text);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
  z-index: 1040;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--sidebar-text-strong);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand .brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--brand-accent), #fbbf24);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.brand-logo {
  height: 32px !important;
  width: 32px !important;
  max-height: 32px !important;
  max-width: 32px !important;
  object-fit: contain;
  flex-shrink: 0;
}

.login-logo {
  height: 60px !important;
  width: 60px !important;
  max-height: 60px !important;
  max-width: 60px !important;
  object-fit: contain;
}

.sidebar-nav {
  padding: 14px 10px;
  flex: 1;
}

.sidebar-nav .nav-heading {
  padding: 18px 12px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.38);
  white-space: nowrap;
}

.sidebar-nav .nav-item { margin-bottom: 2px; }

.sidebar-nav .nav-link {
  color: var(--sidebar-text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
  position: relative;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-nav .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; flex-shrink: 0; }

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

.sidebar-nav .nav-link.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 600;
}

.sidebar-nav .nav-link.active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, var(--brand-accent), #fbbf24);
}

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-collapse-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--sidebar-text);
  border-radius: var(--radius-sm);
  padding: 8px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.sidebar-collapse-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

/* ---- Collapsed state (desktop only) ---- */
.app-wrapper.sidebar-collapsed .sidebar {
  width: var(--sidebar-width-collapsed);
}
.app-wrapper.sidebar-collapsed .sidebar-brand span,
.app-wrapper.sidebar-collapsed .sidebar-nav .nav-heading,
.app-wrapper.sidebar-collapsed .sidebar-nav .nav-link span,
.app-wrapper.sidebar-collapsed .sidebar-collapse-btn span {
  display: none;
}
.app-wrapper.sidebar-collapsed .sidebar-nav .nav-link {
  justify-content: center;
  padding: 12px;
}
.app-wrapper.sidebar-collapsed .sidebar-nav .nav-link.active::before {
  left: 0;
}
.app-wrapper.sidebar-collapsed .sidebar-collapse-btn i { transform: rotate(180deg); }

/* ==================================================================
   Main content / topbar
   ================================================================== */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.page-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.page-content {
  padding: 24px;
  flex: 1;
}

.page-footer {
  padding: 16px 24px;
  color: var(--text-faint);
  font-size: 0.82rem;
  text-align: center;
}

.topbar-user .dropdown-toggle {
  color: var(--text);
  padding: 6px 10px 6px 6px;
  border-radius: var(--radius-pill);
  transition: background-color 0.15s ease;
}
.topbar-user .dropdown-toggle:hover { background: var(--bg); }
.topbar-user .dropdown-toggle::after { display: none; }

/* ==================================================================
   Avatars & status
   ================================================================== */
.avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;
  flex-shrink: 0;
}
.avatar-circle.avatar-sm { width: 26px; height: 26px; font-size: 0.68rem; }
.avatar-circle.avatar-lg { width: 52px; height: 52px; font-size: 1.05rem; }

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.status-online { background: var(--color-success); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18); }
.status-offline { background: var(--text-faint); }

/* ==================================================================
   Cards / stat cards
   ================================================================== */
.card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-md) var(--radius-md) 0 0 !important;
  padding: 14px 18px;
}

.card-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  height: 100%;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  margin-bottom: 12px;
}

.stat-card .stat-value {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.stat-card .stat-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  margin-top: 2px;
}

/* ==================================================================
   Tables
   ================================================================== */
.table thead th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom-width: 1px;
  border-color: var(--border);
  background: #fafafe;
  white-space: nowrap;
}

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

.table > tbody > tr:hover > * {
  background-color: #f8f8fd;
}

.low-stock-row, .low-stock-row:hover > * {
  background-color: #fff5f2 !important;
}

/* ==================================================================
   Buttons
   ================================================================== */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.5rem 1rem;
  transition: transform 0.06s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.btn-sm { padding: 0.32rem 0.65rem; font-size: 0.8rem; border-radius: 7px; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--brand-primary-dark);
  border-color: var(--brand-primary-dark);
}
.btn-primary:active { background: var(--brand-primary-darker) !important; border-color: var(--brand-primary-darker) !important; }

.btn-outline-primary {
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.btn-outline-primary:hover, .btn-outline-primary:focus {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
}

.btn-success { background: var(--color-success); border-color: var(--color-success); }
.btn-success:hover { background: #128a3e; border-color: #128a3e; }

.btn-outline-warning:hover { color: #fff; }

.btn-check:checked + .btn, .btn.active { box-shadow: none; }

/* ==================================================================
   Badges, alerts, forms
   ================================================================== */
.badge { font-weight: 600; letter-spacing: 0.01em; border-radius: var(--radius-pill); padding: 0.4em 0.7em; }

.text-bg-primary { background-color: var(--brand-primary) !important; }
.text-primary { color: var(--brand-primary) !important; }
.bg-primary { background-color: var(--brand-primary) !important; }
.border-primary { border-color: var(--brand-primary) !important; }

.alert {
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: var(--border-strong);
  padding: 0.5rem 0.75rem;
  font-size: 0.92rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.form-label { font-weight: 600; font-size: 0.86rem; color: var(--text); margin-bottom: 0.35rem; }
.form-text { color: var(--text-faint); }

.form-check-input:checked {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15); }

.list-group-item { border-color: var(--border); }

.dropdown-menu {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  padding: 8px;
}
.dropdown-item { border-radius: var(--radius-sm); padding: 8px 10px; font-size: 0.88rem; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--brand-primary-light); color: var(--brand-primary-darker); }
.dropdown-item.active, .dropdown-item:active { background: var(--brand-primary); }

.page-link { color: var(--brand-primary); }
.page-item.active .page-link { background-color: var(--brand-primary); border-color: var(--brand-primary); }

/* ==================================================================
   Item photos
   ================================================================== */
.item-thumb {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
}

.item-photo {
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg);
}

.photo-preview-current {
  width: 90px;
  height: 90px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* ==================================================================
   Login page — split panel
   ================================================================== */
.login-page {
  min-height: 100vh;
  display: flex;
}

.login-panel-brand {
  flex: 1.1;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 56px;
  color: #fff;
  background:
    radial-gradient(1100px circle at 15% 0%, rgba(245, 158, 11, 0.35), transparent 45%),
    linear-gradient(160deg, var(--sidebar-from) 0%, var(--sidebar-to) 70%, #4338ca 130%);
  overflow: hidden;
}

.login-panel-brand::after {
  content: "";
  position: absolute;
  right: -120px;
  bottom: -120px;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.45), transparent 70%);
}

.login-brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 1.15rem;
  position: relative;
  z-index: 1;
}

.login-brand-mark .brand-mark {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--brand-accent), #fbbf24);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.4);
}

.login-tagline {
  position: relative;
  z-index: 1;
  max-width: 420px;
}

.login-tagline h2 { font-size: 1.9rem; font-weight: 800; line-height: 1.25; margin-bottom: 14px; }
.login-tagline p { color: rgba(255, 255, 255, 0.72); font-size: 0.98rem; }

.login-feature-list { list-style: none; padding: 0; margin: 28px 0 0; position: relative; z-index: 1; }
.login-feature-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.92rem;
}
.login-feature-list i {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--brand-accent);
}

.login-panel-brand-footer {
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.8rem;
}

.login-panel-form {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: var(--surface);
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.login-card .login-logo-wrap {
  display: none;
}

.login-card h4 { font-weight: 800; }

@media (max-width: 991.98px) {
  .login-panel-brand { display: none; }
  .login-panel-form { padding: 32px 20px; }
  .login-card .login-logo-wrap { display: block; }
}

/* ==================================================================
   403 / error states
   ================================================================== */
.empty-state { padding: 48px 16px; text-align: center; color: var(--text-muted); }
.empty-state i { font-size: 3rem; color: var(--text-faint); }

/* ==================================================================
   Responsive — mobile sidebar drawer
   ================================================================== */
@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    left: -280px;
    z-index: 1050;
    width: 268px;
    transition: left 0.2s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.show {
    left: 0;
  }
  .sidebar-collapse-btn { display: none; }
  .page-content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .page-title { font-size: 1.1rem; }
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 30, 0.45);
  z-index: 1045;
}
.sidebar-backdrop.show { display: block; }
