/* ==========================================================================
   Root Design System
   Layered on top of Bootstrap 5. Defines brand colors, typography and
   shared component styling used across the login page and all 3 portals.
   --brand-* variables below are fallback defaults only — the app overrides
   them at runtime from the Settings > Branding colors (see ColorPalette).
   ========================================================================== */

:root {
  --brand-900: #172a44;
  --brand-800: #1f2c47;
  --brand-700: #1ca893;
  --brand-600: #2bc0a9;
  --brand-500: #4fd1bd;
  --brand-100: #e3f7f3;
  --brand-50: #f2fbf9;

  --ink-900: #0f172a;
  --ink-700: #334155;
  --ink-500: #64748b;
  --ink-300: #cbd5e1;
  --ink-100: #f1f5f9;

  --danger: #dc2626;
  --warning: #d97706;
  --success: #16a085;
  --info: #2563eb;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 45px rgba(10, 61, 51, 0.18);

  --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ---------- Fluid type scale (clamp-based, scales with viewport) ---------- */
html {
  font-size: clamp(13px, 0.76vw + 11px, 15px);
}
body {
  font-family: var(--font-sans);
  color: var(--ink-900);
  background-color: var(--ink-100);
  font-size: clamp(0.8rem, 0.28vw + 0.74rem, 0.9rem);
}
h1 { font-size: clamp(1.5rem, 1.1vw + 1.2rem, 2.25rem); }
h2 { font-size: clamp(1.25rem, 0.9vw + 1rem, 1.75rem); }
h3 { font-size: clamp(1.125rem, 0.6vw + 0.95rem, 1.5rem); }
h4 { font-size: clamp(1.05rem, 0.4vw + 0.92rem, 1.25rem); }
h5 { font-size: clamp(1rem, 0.3vw + 0.9rem, 1.15rem); }
h6 { font-size: clamp(0.9rem, 0.2vw + 0.82rem, 1rem); }

a {
  color: var(--brand-700);
}
a:hover {
  color: var(--brand-800);
}

/* ---------- Buttons ---------- */
.btn-brand {
  background-color: var(--brand-700);
  border-color: var(--brand-700);
  color: #fff;
  font-weight: 600;
  letter-spacing: .2px;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
}
.btn-brand:hover, .btn-brand:focus {
  background-color: var(--brand-800);
  border-color: var(--brand-800);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-outline-brand {
  border-color: var(--brand-700);
  color: var(--brand-700);
  font-weight: 600;
}
.btn-outline-brand:hover {
  background-color: var(--brand-700);
  color: #fff;
}

/* ---------- Auth / Login page ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  background: radial-gradient(circle at 15% 20%, #103d34 0%, #0a2b24 45%, #071e1a 100%);
}
.auth-brand-panel {
  position: relative;
  color: #fff;
  padding: 64px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.auth-brand-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 80% 10%, rgba(28, 191, 156, .35), transparent 45%),
    radial-gradient(circle at 10% 90%, rgba(18, 133, 111, .35), transparent 45%);
  pointer-events: none;
}
.auth-brand-panel .brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: .3px;
}
.auth-brand-panel .brand-mark .logo-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  box-shadow: var(--shadow-md);
}
.auth-brand-panel h1 {
  font-size: 2.35rem;
  font-weight: 800;
  line-height: 1.2;
  max-width: 480px;
}
.auth-brand-panel p.lead-text {
  color: #cfe9e1;
  max-width: 440px;
  font-size: 1rem;
}
.auth-feature-list {
  list-style: none;
  padding: 0;
  margin: 28px 0 0;
  display: grid;
  gap: 14px;
}
.auth-feature-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: #e3f5ef;
  font-size: .92rem;
}
.auth-feature-list .dot {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(28, 191, 156, .22);
  color: var(--brand-500);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
}

.auth-form-panel {
  background-color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.auth-form-card {
  width: 100%;
  max-width: 420px;
}
.auth-form-card h2 {
  font-weight: 800;
  color: var(--ink-900);
}
.auth-form-card .sub {
  color: var(--ink-500);
  font-size: .92rem;
}

/* Portal switch tabs */
.portal-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--ink-100);
  padding: 6px;
  border-radius: var(--radius-md);
  margin-bottom: 28px;
}
.portal-switch .portal-btn {
  border: none;
  background: transparent;
  padding: 10px 6px;
  border-radius: 10px;
  font-size: .82rem;
  font-weight: 700;
  color: var(--ink-500);
  cursor: pointer;
  transition: all .15s ease;
}
.portal-switch .portal-btn.active {
  background: #fff;
  color: var(--brand-800);
  box-shadow: var(--shadow-sm);
}

.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: var(--ink-300);
  padding: .65rem .9rem;
}
.form-select {
  /* Bootstrap reserves the right side for the dropdown arrow icon — don't
     let the shared .form-control padding above shrink it, or the text
     overlaps the arrow. */
  padding-right: 2.25rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand-600);
  box-shadow: 0 0 0 .2rem rgba(22, 160, 133, .15);
}
.form-label {
  font-weight: 600;
  font-size: .85rem;
  color: var(--ink-700);
}

/* ---------- App shell (dashboards) ---------- */
.app-sidebar {
  width: 264px;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--brand-900), #0a2b24);
  color: #d7ece5;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 1030;
  transition: transform .2s ease;
}
.app-sidebar .brand {
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 800;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.app-sidebar .brand .logo-badge {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .85rem;
}
.app-sidebar nav {
  padding: 16px 12px;
  overflow-y: auto;
  flex: 1;
}
.app-sidebar .nav-section-title {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #6fa896;
  padding: 14px 12px 6px;
}
.app-sidebar .nav-link {
  color: #cfe6de;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 2px;
  font-size: .93rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-sidebar .nav-link:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
}
.app-sidebar .nav-link.active {
  background: var(--brand-700);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.app-sidebar .nav-link .badge-count {
  margin-left: auto;
}
.app-sidebar .sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.app-main {
  margin-left: 264px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-topbar {
  background: #fff;
  border-bottom: 1px solid var(--ink-100);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1020;
}
.app-content {
  padding: 28px;
  flex: 1;
}

/* Bootstrap's default .dropdown-menu z-index (1000) sits BELOW the
   sidebar (1030) and sticky topbar (1020) above — any dropdown opened
   near either would render underneath them, looking hidden/overlapped.
   Always keep dropdowns on top of the app chrome. */
.dropdown-menu {
  z-index: 1050;
}

@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.show { transform: translateX(0); }
  .app-main { margin-left: 0; }
}

/* ---------- Cards / stat tiles ---------- */
.stat-tile {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--ink-100);
  height: 100%;
}
.stat-tile .stat-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  margin-bottom: 12px;
}
.stat-tile .stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--ink-900);
  line-height: 1;
}
.stat-tile .stat-label {
  color: var(--ink-500);
  font-size: .82rem;
  margin-top: 4px;
}
a.stat-tile {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s ease, transform .15s ease;
}
a.stat-tile:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,.1);
  transform: translateY(-2px);
}

.card-surface {
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid var(--ink-100);
  box-shadow: var(--shadow-sm);
}
.card-surface .card-header {
  background: transparent;
  border-bottom: 1px solid var(--ink-100);
  font-weight: 700;
  padding: 16px 22px;
}
.card-surface .card-body {
  padding: 22px;
}

/* ---------- Pagination (brand-colored Bootstrap 5) ---------- */
.pagination {
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}
.page-link {
  border: 1px solid var(--ink-100);
  color: var(--ink-700);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .85rem;
  padding: .45rem .8rem;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.page-link:hover {
  background: var(--brand-50);
  color: var(--brand-800);
  border-color: var(--brand-100);
}
.page-link:focus {
  box-shadow: 0 0 0 .2rem var(--brand-100);
  z-index: 1;
}
.page-item.active .page-link {
  background: var(--brand-700);
  border-color: var(--brand-700);
  color: #fff;
}
.page-item.disabled .page-link {
  color: var(--ink-300);
  background: #fff;
  border-color: var(--ink-100);
}

.table thead th {
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-500);
  border-bottom-width: 1px;
  font-weight: 700;
}
.table {
  font-size: .92rem;
}
.table td, .table th {
  vertical-align: middle;
}

.badge-status {
  font-size: .72rem;
  font-weight: 700;
  padding: .4em .7em;
  border-radius: 999px;
  text-transform: capitalize;
}
.badge-new { background: #e0edff; color: #1d4ed8; }
.badge-packing_pending { background: #fef3c7; color: #b45309; }
.badge-packing_approved { background: #dcfce7; color: #15803d; }
.badge-in_production { background: #ede9fe; color: #6d28d9; }
.badge-dispatched { background: #cffafe; color: #0e7490; }
.badge-delivered { background: #d1fae5; color: #047857; }
.badge-cancelled { background: #fee2e2; color: #b91c1c; }
.badge-pending { background: #fef3c7; color: #b45309; }
.badge-approved { background: #dcfce7; color: #15803d; }
.badge-rejected { background: #fee2e2; color: #b91c1c; }
.badge-received { background: #dcfce7; color: #15803d; }
.badge-ordered { background: #e0edff; color: #1d4ed8; }
.badge-delayed { background: #fee2e2; color: #b91c1c; }
.badge-not_started { background: var(--ink-100); color: var(--ink-500); }
.badge-in_design { background: #e0edff; color: #1d4ed8; }
.badge-submitted_for_approval { background: #fef3c7; color: #b45309; }

.priority-high { color: var(--danger); font-weight: 700; }
.priority-normal { color: var(--info); font-weight: 600; }
.priority-low { color: var(--ink-500); font-weight: 600; }

.nav-tabs .nav-link {
  font-weight: 600;
  color: var(--ink-500);
  border: none;
  border-bottom: 2px solid transparent;
}
.nav-tabs .nav-link.active {
  color: var(--brand-800);
  border-bottom-color: var(--brand-700);
  background: transparent;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-500);
}

.avatar-circle {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--brand-100);
  color: var(--brand-800);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: .85rem;
}

/* ---------- Spreadsheet-style master tracking table ---------- */
.sheet-table {
  font-size: .84rem;
  border-collapse: separate;
  border-spacing: 0;
}
.sheet-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--ink-100);
  white-space: nowrap;
  font-size: .72rem;
  padding: 8px 10px;
  border-bottom: 2px solid var(--ink-300);
}
.sheet-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--ink-100);
}
.sheet-table tbody tr:hover {
  background: var(--brand-50);
}
.sheet-table tr.row-new {
  background: #fffbea;
}
.sheet-table tr.row-new:hover {
  background: #fff6d1;
}
.sheet-table tr.row-overdue {
  background: #fef2f2;
}
.sheet-table tr.row-overdue:hover {
  background: #fde3e3;
}
