/* ============================================================
   QUORIA PARTNER PORTAL — Shared Styles
   ============================================================ */

:root {
  --primary:   #17324C;
  --accent:    #17324C;
  --gold:      #FBB724;
  --gold-dark: #E5A510;
  --surface:   #FFFFFF;
  --bg:        #F4F6F8;
  --muted:     #6B7A8D;
  --line:      #E2E8EF;
  --danger:    #D93025;
  --success:   #1A7A4A;
  --warn:      #E8860A;
  --info:      #1565C0;

  --radius:    10px;
  --radius-lg: 16px;
  --shadow:    0 2px 12px rgba(23,50,76,.08);
  --shadow-lg: 0 8px 32px rgba(23,50,76,.14);

  /* Statut colors */
  --s-brouillon:        #6B7A8D;
  --s-soumis:           #1565C0;
  --s-en_analyse:       #6A1FB5;
  --s-accorde:          #1A7A4A;
  --s-refuse:           #D93025;
  --s-pieces_manquantes:#E8860A;
  --s-contrat_signe:    #00796B;
  --s-livre:            #2E7D32;
  --s-paye:             #1A5C2A;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--primary);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

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

.sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--primary);
  display: flex;
  flex-direction: column;
  padding: 0;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 24px 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  text-decoration: none;
}

.sidebar-brand .logo {
  font-family: 'Sora', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

.sidebar-brand .logo span { color: var(--gold); }

.sidebar-brand .tagline {
  font-size: 11px;
  color: rgba(255,255,255,.45);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,.3);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 24px 6px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all .15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.sidebar-nav a.active { color: #fff; background: rgba(251,183,36,.12); border-left-color: var(--gold); }
.sidebar-nav a .icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,.1);
}

.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.user-avatar {
  width: 34px; height: 34px;
  background: var(--gold);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--primary);
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: #fff; }
.user-company { font-size: 11px; color: rgba(255,255,255,.45); }

.btn-logout {
  width: 100%;
  padding: 8px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  color: rgba(255,255,255,.6);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.btn-logout:hover { background: rgba(255,255,255,.14); color: #fff; }

.main-content {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 17px; font-weight: 700; color: var(--primary); }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.page-body { padding: 32px; flex: 1; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  border: 1px solid var(--line);
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 8px;
}

/* ── Stat cards ─────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px; }
.stat-value { font-family: 'Sora', sans-serif; font-size: 28px; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-card.gold .stat-value { color: var(--gold-dark); }
.stat-card.green .stat-value { color: var(--success); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #1e4060; }
.btn-gold { background: var(--gold); color: var(--primary); }
.btn-gold:hover { background: var(--gold-dark); }
.btn-outline { background: transparent; border: 1.5px solid var(--line); color: var(--primary); }
.btn-outline:hover { border-color: var(--primary); background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b71c1c; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Badges statut ──────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }

.badge-brouillon        { background: #F0F2F5; color: var(--s-brouillon); }
.badge-soumis           { background: #E3F0FF; color: var(--s-soumis); }
.badge-en_analyse       { background: #F3E8FF; color: var(--s-en_analyse); }
.badge-accorde          { background: #E6F4EC; color: var(--s-accorde); }
.badge-refuse           { background: #FEECEB; color: var(--s-refuse); }
.badge-pieces_manquantes{ background: #FEF3E2; color: var(--s-pieces_manquantes); }
.badge-contrat_signe    { background: #E0F5F3; color: var(--s-contrat_signe); }
.badge-livre            { background: #E8F5E9; color: var(--s-livre); }
.badge-paye             { background: #D4EDDA; color: var(--s-paye); }

/* ── Table ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
thead tr { background: var(--bg); border-bottom: 2px solid var(--line); }
th { padding: 12px 16px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; text-align: left; white-space: nowrap; }
td { padding: 14px 16px; font-size: 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFBFC; }
tbody tr { cursor: pointer; transition: background .1s; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.span-2 { grid-column: span 2; }
.field.span-3 { grid-column: span 3; }
label { font-size: 13px; font-weight: 600; color: var(--primary); }
label .req { color: var(--danger); margin-left: 2px; }
input, select, textarea {
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  color: var(--primary);
  background: var(--surface);
  transition: border-color .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
input.error, select.error, textarea.error { border-color: var(--danger); }
textarea { resize: vertical; min-height: 100px; }
.field-hint { font-size: 12px; color: var(--muted); }

/* ── File upload ────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  background: var(--bg);
}
.upload-zone:hover { border-color: var(--primary); background: #EEF2F7; }
.upload-zone input[type=file] { display: none; }
.upload-icon { font-size: 28px; margin-bottom: 8px; }
.upload-label { font-size: 14px; font-weight: 600; color: var(--primary); }
.upload-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.file-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.file-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
}
.file-item-name { font-weight: 500; }
.file-item-size { color: var(--muted); font-size: 12px; }
.file-remove { background: none; border: none; cursor: pointer; color: var(--danger); font-size: 16px; padding: 2px; }

/* ── Toast notifications ────────────────────────────────────── */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: slideIn .25s ease;
  max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.info    { background: var(--info); }
.toast.warn    { background: var(--warn); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Auth pages ─────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 48px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo .logo { font-family: 'Sora', sans-serif; font-size: 32px; font-weight: 800; color: var(--primary); }
.auth-logo .logo span { color: var(--gold); }
.auth-logo .sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.auth-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.auth-sub { font-size: 14px; color: var(--muted); margin-bottom: 28px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-link { font-size: 13px; color: var(--muted); text-align: center; margin-top: 16px; }
.auth-link a { color: var(--primary); font-weight: 600; text-decoration: none; }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}
.alert.show { display: block; }
.alert-error { background: #FEECEB; color: var(--danger); border: 1px solid #FCCAC7; }
.alert-success { background: #E6F4EC; color: var(--success); border: 1px solid #A8D8B9; }
.alert-info { background: #E3F0FF; color: var(--info); border: 1px solid #90C2FF; }
.alert-warn { background: #FEF3E2; color: var(--warn); border: 1px solid #F9D78E; }

/* ── Historique ─────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: 14px; padding-bottom: 20px; position: relative; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 28px;
  bottom: 0;
  width: 2px;
  background: var(--line);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  z-index: 1;
}
.timeline-content { flex: 1; padding-top: 4px; }
.timeline-title { font-size: 14px; font-weight: 600; }
.timeline-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.timeline-comment { font-size: 13px; color: var(--muted); margin-top: 6px; background: var(--bg); padding: 8px 12px; border-radius: 8px; }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-title { font-size: 18px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.empty-sub { font-size: 14px; margin-bottom: 24px; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr; }
  .field.span-2, .field.span-3 { grid-column: span 1; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-body { padding: 16px; }
}
