/* Fonts loaded via <link> in base.html and login.html */

:root {
  --navy:      #1a3a5c;
  --navy-d:    #122843;
  --navy-l:    #234c78;
  --orange:    #e8a020;
  --orange-d:  #c8871a;
  --orange-l:  #f5b93e;
  --bg:        #f0f2f5;
  --surface:   #ffffff;
  --border:    #e4e8ed;
  --text:      #1a1a1a;
  --text-mute: #6b7280;
  --sb-w:      220px;
}

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

body {
  font-family: 'Inter', 'Segoe UI', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9375rem;
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ── Sidebar ────────────────────────────────────────── */
.app-sidebar {
  width: var(--sb-w);
  background: var(--navy);
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

/* ── Main area (topbar + content) ───────────────────── */
.app-main {
  margin-left: var(--sb-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ── Topbar ─────────────────────────────────────────── */
.app-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--navy);
  margin: 0;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

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

/* ── Sidebar Brand ──────────────────────────────────── */
.sb-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sb-brand-name {
  font-family: 'Playfair Display', serif;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: .2px;
  text-decoration: none;
  display: block;
}
.sb-brand-sub {
  color: rgba(255,255,255,.45);
  font-size: .67rem;
  font-weight: 500;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  margin-top: 3px;
}

/* ── Sidebar Nav ────────────────────────────────────── */
.sb-nav {
  padding: 12px 0;
  flex: 1;
  overflow-y: auto;
}
.sb-nav-label {
  color: rgba(255,255,255,.28);
  font-size: .63rem;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: .75rem 20px .3rem;
}
.sb-nav-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: 11px 20px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: .8125rem;
  font-weight: 400;
  transition: color .15s, background .15s;
  cursor: pointer;
}
.sb-nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,.08);
  text-decoration: none;
}
.sb-nav-item.active {
  color: #fff;
  background: var(--orange);
  font-weight: 600;
}
.sb-nav-item .bi {
  font-size: .95rem;
  width: 1.1rem;
  text-align: center;
  flex-shrink: 0;
}

/* ── Sidebar Footer ─────────────────────────────────── */
.sb-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sb-user {
  display: flex;
  align-items: center;
  gap: .625rem;
  margin-bottom: .5rem;
}
.sb-user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(232,160,32,.2);
  color: var(--orange-l);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  font-weight: 600;
  flex-shrink: 0;
  text-transform: uppercase;
}
.sb-user-email {
  color: rgba(255,255,255,.45);
  font-size: .72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sb-logout {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: rgba(255,255,255,.35);
  font-size: .78rem;
  text-decoration: none;
  transition: color .15s;
}
.sb-logout:hover { color: rgba(255,255,255,.7); text-decoration: none; }

/* ── Cards ──────────────────────────────────────────── */
.card {
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  box-shadow: 0 1px 6px rgba(0,0,0,.06) !important;
  background: var(--surface);
}
.card-header {
  background: var(--surface) !important;
  border-bottom: 1px solid var(--border) !important;
  padding: .875rem 1.125rem !important;
  display: flex;
  align-items: center;
}
.card-header h6 {
  font-weight: 600;
  font-size: .8375rem;
  color: var(--navy);
  margin: 0;
}
.card-body { padding: 1.125rem !important; }

/* ── Buttons ────────────────────────────────────────── */
.btn-primary {
  background: var(--orange) !important;
  border-color: var(--orange) !important;
  color: #fff !important;
  font-weight: 500;
  font-size: .8375rem;
  transition: background .15s, box-shadow .15s;
}
.btn-primary:hover {
  background: var(--orange-d) !important;
  border-color: var(--orange-d) !important;
  box-shadow: 0 4px 14px rgba(232,160,32,.3) !important;
}
.btn-primary:focus {
  box-shadow: 0 0 0 3px rgba(232,160,32,.25) !important;
}
.btn-outline-primary {
  color: var(--navy) !important;
  border-color: var(--navy) !important;
  font-size: .8375rem;
  font-weight: 500;
}
.btn-outline-primary:hover {
  background: var(--navy) !important;
  color: #fff !important;
}
.btn-outline-secondary {
  font-size: .8375rem;
}
.btn {
  border-radius: 6px;
}
.btn-sm {
  font-size: .78rem !important;
}

/* ── Forms ──────────────────────────────────────────── */
.form-control, .form-select {
  border: 1px solid #dde3ea;
  border-radius: 6px;
  font-size: .8375rem;
  padding: .5rem .75rem;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(232,160,32,.15);
  outline: none;
}
.form-control:disabled {
  background: #f5f6f8;
  color: var(--text-mute);
}
.form-label {
  font-size: .78rem;
  font-weight: 600;
  color: #555;
  margin-bottom: .3rem;
  letter-spacing: .1px;
}
.form-control-sm, .form-select-sm {
  font-size: .78rem;
  padding: .3rem .6rem;
  border-radius: 5px;
}
.form-text { font-size: .78rem; color: var(--text-mute); }

/* ── Tables ─────────────────────────────────────────── */
.table {
  font-size: .845rem;
  color: var(--text);
}
.table thead th {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-mute);
  border-bottom: 2px solid var(--border);
  padding: 11px 16px;
  background: #fafafa;
  white-space: nowrap;
}
.table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid #f5f5f5;
  vertical-align: middle;
}
.table-hover tbody tr:hover td { background: #f5f8fc !important; }

/* ── Badges ─────────────────────────────────────────── */
.badge {
  font-weight: 500;
  font-size: .7rem;
  letter-spacing: .3px;
  padding: .3em .65em;
  border-radius: 10px;
}

/* ── Alerts ─────────────────────────────────────────── */
.alert {
  border-radius: 8px;
  border: none;
  font-size: .875rem;
}
.alert-success { background: #f0faf5; color: #1a6640; border-left: 3px solid #27ae60; }
.alert-danger  { background: #fef2f2; color: #7f1d1d; border-left: 3px solid #dc2626; }
.alert-warning { background: #fffbeb; color: #78350f; border-left: 3px solid #f59e0b; }
.alert-info    { background: #eff6ff; color: #1e40af; border-left: 3px solid #3b82f6; }

/* ── Schema thumbnails ──────────────────────────────── */
.schema-thumb {
  width: 64px; height: 80px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  cursor: zoom-in;
  transition: box-shadow .15s, border-color .15s;
}
.schema-thumb:hover {
  box-shadow: 0 0 0 2px var(--orange);
  border-color: var(--orange);
}

/* ── Drop zone ──────────────────────────────────────── */
.drop-zone {
  border: 2px dashed #b0c4de;
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: #f8faff;
}
.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--navy);
  background: #eef4ff;
}

/* ── Stat cards (dashboard) ─────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.stat-label {
  font-size: .72rem;
  color: var(--text-mute);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 600;
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.1;
}
.stat-sub {
  font-size: .75rem;
  color: var(--text-mute);
  margin-top: 4px;
}
.stat-sub.up   { color: #27ae60; }
.stat-sub.down { color: #e74c3c; }

/* ── Totaux block ───────────────────────────────────── */
.totaux-card .totaux-row {
  display: flex;
  justify-content: space-between;
  padding: .5rem 0;
  font-size: .875rem;
  color: var(--text-mute);
  border-bottom: 1px solid var(--border);
}
.totaux-card .totaux-row:last-child { border-bottom: none; }
.totaux-card .totaux-row.ttc {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  padding-top: .75rem;
}
.totaux-card .totaux-row.ttc span:last-child { color: var(--orange-d); }

/* ── Page-header fallback (kept for backwards compat) ── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
.page-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  line-height: 1.2;
}
.page-subtitle {
  color: var(--text-mute);
  font-size: .8rem;
  margin: .2rem 0 0;
}

/* ── Stat chips (liste devis) ───────────────────────── */
.stat-chips {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.stat-chip {
  background: white;
  border-radius: 8px;
  padding: 10px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  font-size: .8125rem;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
}
.stat-chip strong {
  font-size: 1rem;
  color: var(--navy);
}
.chip-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Filters bar ────────────────────────────────────── */
.filters-bar {
  background: white;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  border: 1px solid var(--border);
}

/* ── Login page ─────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  background-image:
    radial-gradient(circle at 20% 50%, rgba(232,160,32,.07) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(232,160,32,.05) 0%, transparent 40%);
}
.login-wrapper {
  width: 100%;
  max-width: 400px;
  padding: 1rem;
}
.login-card {
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.4);
}
.login-header {
  background: linear-gradient(150deg, var(--navy) 0%, var(--navy-d) 100%);
  color: #fff;
  text-align: center;
  padding: 2.25rem 1.5rem 2rem;
  position: relative;
  overflow: hidden;
}
.login-header::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 130px; height: 130px;
  border-radius: 50%;
  background: rgba(232,160,32,.07);
}
.login-header::after {
  content: '';
  position: absolute;
  bottom: -25px; left: -25px;
  width: 90px; height: 90px;
  border-radius: 50%;
  background: rgba(232,160,32,.05);
}
.login-brand-icon {
  width: 52px; height: 52px;
  background: rgba(232,160,32,.15);
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: .875rem;
  position: relative;
}
.login-brand-icon .bi { font-size: 1.5rem; color: var(--orange-l); }
.login-header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 1.45rem;
  font-weight: 600;
  margin: 0 0 .3rem;
  position: relative;
}
.login-header p {
  color: rgba(255,255,255,.5);
  margin: 0; font-size: .83rem;
  position: relative;
}
.login-gold-line {
  width: 36px; height: 2px;
  background: var(--orange);
  margin: .9rem auto 0;
  border-radius: 1px;
  position: relative;
}
.login-body { padding: 2rem; }

/* ── Utilities ──────────────────────────────────────── */
.text-gold   { color: var(--orange-d) !important; }
.text-orange { color: var(--orange) !important; }
.text-navy   { color: var(--navy) !important; }

/* ── Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccd0d8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #adb3bc; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
