/* ============================================================
   DevisIA by Limogia — Design System
   Dark theme · Mint green accent · Anton display font
   ============================================================ */

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

/* ── VARIABLES ──────────────────────────────────────────────── */
:root {
  --accent:        #00E58C;
  --accent-dark:   #00C47A;
  --accent-dim:    rgba(0, 229, 140, 0.10);
  --accent-glow:   0 0 24px rgba(0, 229, 140, 0.28);
  --accent-glow-sm:0 0 12px rgba(0, 229, 140, 0.20);

  /* Legacy --primary → accent for backward compat */
  --primary:       #00E58C;
  --primary-dark:  #00C47A;
  --primary-light: rgba(0, 229, 140, 0.10);

  --success:       #00E58C;
  --success-light: rgba(0, 229, 140, 0.12);
  --warning:       #F59E0B;
  --warning-light: rgba(245, 158, 11, 0.12);
  --danger:        #FF4444;
  --danger-light:  rgba(255, 68, 68, 0.12);
  --info:          #3B82F6;

  --sidebar-bg:    #080808;
  --sidebar-text:  #888;
  --sidebar-active:#00E58C;
  --sidebar-width: 240px;

  --bg:            #0A0A0A;
  --card-bg:       #111111;
  --surface-2:     #161616;
  --border:        #1E1E1E;
  --border-light:  #141414;
  --border-focus:  #00E58C;

  --text:          #E8E8E8;
  --text-muted:    #666;
  --text-light:    #3A3A3A;

  --radius:        8px;
  --radius-lg:     12px;
  --shadow:        0 1px 4px rgba(0,0,0,0.5);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:     0 8px 40px rgba(0,0,0,0.65);

  --font-display:  'Anton', Impact, 'Arial Narrow', sans-serif;
  --font-body:     'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── RESET ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(255,255,255,0.016) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.016) 1px, transparent 1px);
  background-size: 40px 40px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); text-decoration: none; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; }

/* ── APP LAYOUT ─────────────────────────────────────────────── */

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

/* ── SIDEBAR ─────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-text {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.02em;
  color: #fff;
  line-height: 1;
}
.sidebar-logo .logo-text span { color: var(--accent); }

.sidebar-logo .logo-sub {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: rgba(0,229,140,0.45);
  margin-top: 4px;
}

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

.nav-section { margin-bottom: 24px; }

.nav-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-light);
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-bottom: 2px;
}
.nav-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-left-color: rgba(0,229,140,0.3);
  text-decoration: none;
}
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #000;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--accent-dim);
  border: 1.5px solid rgba(0,229,140,0.4);
  color: var(--accent);
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-info { min-width: 0; }
.user-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── MAIN CONTENT ────────────────────────────────────────────── */

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── TOPBAR ──────────────────────────────────────────────────── */

.topbar {
  height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(10,10,10,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.04em;
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── PAGE CONTENT ─────────────────────────────────────────────── */

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

/* ── CARDS ───────────────────────────────────────────────────── */

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.01);
}

.card-title {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.05em;
  color: var(--text);
}

.card-body { padding: 20px; }

/* ── BUTTONS ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all 0.15s;
  text-decoration: none !important;
  white-space: nowrap;
  font-family: var(--font-body);
  letter-spacing: 0.01em;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent);
  color: #000 !important;
  border-color: var(--accent);
  font-weight: 700;
}
.btn-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  box-shadow: var(--accent-glow);
  color: #000 !important;
}

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text);
}

.btn-success {
  background: var(--success-light);
  color: var(--accent);
  border-color: rgba(0,229,140,0.25);
}
.btn-success:hover {
  background: var(--accent);
  color: #000 !important;
  border-color: var(--accent);
  box-shadow: var(--accent-glow);
}

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
  border-color: rgba(255,68,68,0.25);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
}
.btn-lg {
  padding: 13px 24px;
  font-size: 15px;
}
.btn-full { width: 100%; }

/* ── FORMS ───────────────────────────────────────────────────── */

.form-group { margin-bottom: 16px; }
.form-group.mb-0 { margin-bottom: 0; }
.form-group.mt-3 { margin-top: 16px; }

label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 13px;
  background: #0D0D0D;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,229,140,0.1);
}
.form-control::placeholder { color: var(--text-light); }
.form-control:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: rgba(255,255,255,0.02);
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

textarea.form-control { resize: vertical; min-height: 80px; }
.form-control-sm { padding: 7px 10px; font-size: 13px; }

.form-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}

.required { color: var(--accent); }

/* ── VOICE INPUT (Web Speech API) ───────────────────────────── */

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.field-label-row label { margin-bottom: 0; }

/* Voice controls reserve a complete bottom row inside the textarea. */
.voice-textarea { position: relative; }
.voice-textarea > textarea.form-control { padding-bottom: 76px; min-height: 180px; resize: vertical; }
.voice-textarea-controls { position: absolute; bottom: 12px; right: 12px; display: flex; gap: 8px; }
.voice-control { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 14px; border-radius: 24px; border: 1px solid var(--accent); background: var(--surface-2); color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; }
.voice-control svg { width: 20px; height: 20px; flex-shrink: 0; }
.voice-control.voice-agent { background: var(--accent); color: #052719; font-weight: 600; }
.voice-control:hover { box-shadow: var(--accent-glow-sm); }
.voice-control:focus-visible, .voice-panel button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.voice-control:disabled { opacity: .5; cursor: not-allowed; }
.voice-control[data-state="listening"] { animation: voicePulse 1.8s ease-in-out infinite; }
.voice-control[data-state="processing"] svg { animation: voiceProcessing 1s ease-in-out infinite alternate; }
.voice-control[data-state="speaking"] { box-shadow: 0 0 0 3px var(--accent-dim); }
.voice-control[data-state="error"] { border-color: var(--danger); }
.voice-panel { position: relative; margin: 16px 0 24px; padding: 16px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--card-bg); max-height: 50vh; overflow-y: auto; }
.voice-panel[hidden], [data-confirmation][hidden], .overdue-summary[hidden] { display: none; }
.voice-panel-head, .voice-panel-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.voice-panel-head [data-status] { color: var(--accent); flex: 1; }
.voice-panel [data-reply] { margin: 12px 0; white-space: pre-wrap; }
.voice-panel-tools label { font-size: 12px; }
.voice-invoices { display: grid; gap: 6px; max-height: 160px; overflow: auto; }
.overdue-summary { margin-bottom: 20px; padding: 16px; border-left: 3px solid var(--warning); background: var(--surface-2); border-radius: var(--radius); }
.overdue-summary p { margin-bottom: 8px; }
.reminder-dialog { width: min(620px, calc(100vw - 24px)); max-height: 90vh; overflow: auto; padding: 24px; background: var(--card-bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); margin: auto; }
.reminder-dialog::backdrop { background: #0009; }
@keyframes voiceProcessing { to { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .voice-control[data-state] { animation: none; } .voice-control[data-state] svg { animation: none; } }
@media (max-width: 600px) {
  .voice-control { padding: 10px; font-size: 12px; gap: 5px; }
  .voice-textarea-controls { right: 8px; gap: 6px; }
  .chat-input-inner { flex-wrap: wrap; }
  .chat-input-inner textarea { flex-basis: 100%; }
  .voice-panel { padding: 12px; }
  .step-indicator .step { min-width: 0; padding: 10px 8px; gap: 6px; font-size: 12px; }
}

@keyframes voicePulse {
  0%   { box-shadow: 0 0 0 0 rgba(0,229,140,0.55); }
  70%  { box-shadow: 0 0 0 12px rgba(0,229,140,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,229,140,0); }
}

.form-grid { display: grid; gap: 16px; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── ALERTS ──────────────────────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
  border-left: 3px solid;
  line-height: 1.5;
}
.alert-error   { background: var(--danger-light);  color: #FF7070; border-color: var(--danger);  }
.alert-success { background: var(--success-light); color: var(--accent); border-color: var(--accent); }
.alert-warning { background: var(--warning-light); color: var(--warning); border-color: var(--warning); }
.alert-info    { background: rgba(59,130,246,0.1); color: #60A5FA; border-color: #3B82F6; }

/* ── TABLES ──────────────────────────────────────────────────── */

.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--border-light); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody td { padding: 13px 16px; color: var(--text); vertical-align: middle; }

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }

/* ── BADGES ──────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.badge-brouillon {
  background: rgba(255,255,255,0.05);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-envoye {
  background: rgba(0,229,140,0.1);
  color: var(--accent);
  border: 1px solid rgba(0,229,140,0.25);
}
.badge-accepte {
  background: rgba(0,229,140,0.18);
  color: #00FF9D;
  border: 1px solid rgba(0,229,140,0.35);
}
.badge-refuse {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(255,68,68,0.3);
}
.badge-emise {
  background: rgba(0,229,140,0.1);
  color: var(--accent);
  border: 1px solid rgba(0,229,140,0.25);
}
.badge-payee {
  background: rgba(0,229,140,0.18);
  color: #00FF9D;
  border: 1px solid rgba(0,229,140,0.35);
}
.badge-en_retard {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(255,68,68,0.3);
}

/* Source badges */
.badge-source {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.badge-source.grille {
  background: rgba(0,229,140,0.1);
  color: var(--accent);
  border: 1px solid rgba(0,229,140,0.22);
}
.badge-source.estime {
  background: rgba(245,158,11,0.1);
  color: var(--warning);
  border: 1px solid rgba(245,158,11,0.22);
}

/* ── AUTH PAGES ──────────────────────────────────────────────── */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.auth-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

/* subtle top accent line */
.auth-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo .logo,
.logo {
  font-family: var(--font-display);
  font-size: 38px;
  letter-spacing: 0.02em;
  color: #fff;
  line-height: 1;
}
.auth-logo .logo span,
.logo span { color: var(--accent); }

.logo-by {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: rgba(0,229,140,0.45);
  margin-top: 3px;
  font-family: var(--font-body);
}

.auth-logo p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 10px;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.04em;
  color: var(--text);
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--text-muted);
}
.auth-footer a { color: var(--accent); font-weight: 600; }

/* ── STATS GRID ──────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
  border-color: rgba(0,229,140,0.2);
  box-shadow: 0 0 0 1px rgba(0,229,140,0.06);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon.blue   { background: var(--accent-dim); }
.stat-icon.green  { background: rgba(0,229,140,0.15); }
.stat-icon.yellow { background: rgba(245,158,11,0.1); }
.stat-icon.red    { background: rgba(255,68,68,0.1); }

.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: 0.02em;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 500;
}

/* ── DEVIS EDITOR ────────────────────────────────────────────── */

.devis-editor {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}

.devis-totals { display: flex; flex-direction: column; gap: 0; }

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: var(--text-muted);
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}
.total-row:last-child { border-bottom: none; }

.total-ttc {
  font-size: 18px !important;
  padding-top: 14px !important;
}
.total-ttc span,
.total-ttc strong {
  color: var(--accent) !important;
  font-weight: 800 !important;
}

.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── LIGNES TABLE ─────────────────────────────────────────────── */

.lignes-table { width: 100%; border-collapse: collapse; }

.lignes-table thead th {
  padding: 10px 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.lignes-table .col-qte,
.lignes-table .col-pu,
.lignes-table .col-montant { text-align: right; }

.lignes-table tbody tr { border-bottom: 1px solid var(--border-light); }
.lignes-table tbody tr:hover { background: rgba(255,255,255,0.015); }
.lignes-table tbody td { padding: 8px 12px; vertical-align: middle; }

.col-designation { min-width: 240px; }
.col-qte    { width: 80px; }
.col-unite  { width: 80px; }
.col-pu     { width: 100px; }
.col-montant{ width: 110px; }
.col-actions{ width: 70px; }

.ligne-input {
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 5px;
  color: var(--text);
  font-size: 13px;
  padding: 5px 8px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
.ligne-input:hover { border-color: var(--border); }
.ligne-input:focus {
  border-color: var(--accent);
  background: rgba(0,229,140,0.04);
  box-shadow: 0 0 0 2px rgba(0,229,140,0.08);
}

.montant-cell {
  font-weight: 700;
  color: var(--accent);
  font-size: 13px;
}

.btn-save-tarif {
  opacity: 0;
  transition: opacity 0.15s;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  padding: 4px 6px;
  border-radius: 4px;
}
.btn-save-tarif:hover { background: var(--accent-dim); }
.ligne-row:hover .btn-save-tarif { opacity: 1; }

/* ── MODAL ───────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
  position: relative;
  overflow: hidden;
}

.modal::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0,229,140,0.4), transparent);
}

@keyframes modalIn {
  from { transform: translateY(-12px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 6px;
  line-height: 1;
  border-radius: 4px;
  transition: all 0.15s;
}
.modal-close:hover { color: var(--text); background: rgba(255,255,255,0.06); }

.modal-body { padding: 22px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,0.01);
}

/* ── AI PANEL ────────────────────────────────────────────────── */

.ai-panel {
  background: var(--card-bg);
  border: 1px solid rgba(0,229,140,0.18);
  border-radius: var(--radius-lg);
  padding: 28px;
  position: relative;
  overflow: hidden;
}

.ai-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.ai-badge {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(0,229,140,0.25);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 3px 10px;
  border-radius: 20px;
}

/* ── STEP INDICATOR ──────────────────────────────────────────── */

.step-indicator {
  display: flex;
  gap: 0;
  margin-bottom: 32px;
}

.step {
  flex: 1;
  padding: 12px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  position: relative;
}
.step:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.step:last-child  { border-radius: 0 var(--radius) var(--radius) 0; }
.step.active {
  background: var(--accent-dim);
  border-color: rgba(0,229,140,0.3);
  color: var(--accent);
}
.step.done {
  background: rgba(0,229,140,0.05);
  border-color: rgba(0,229,140,0.15);
  color: rgba(0,229,140,0.55);
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
  color: var(--text-muted);
}
.step.active .step-num { background: var(--accent); color: #000; }
.step.done .step-num   { background: rgba(0,229,140,0.25); color: var(--accent); }

/* ── EMPTY STATE ─────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.3; filter: grayscale(1); }

/* ── SPINNER / LOADING ───────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(0,229,140,0.15);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner-dark {
  border-color: rgba(255,255,255,0.08);
  border-top-color: var(--text-muted);
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(8px);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── UTILITIES ───────────────────────────────────────────────── */

.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.mt-3 { margin-top: 16px; }
.mb-0 { margin-bottom: 0 !important; }

/* ── INFO BANNER ─────────────────────────────────────────────── */

.info-banner {
  background: rgba(0,229,140,0.04);
  border: 1px solid rgba(0,229,140,0.12);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.info-banner .icon { font-size: 24px; flex-shrink: 0; opacity: 0.7; }

/* ── CATEGORY TABS ───────────────────────────────────────────── */

.cat-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.cat-tab {
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  color: var(--text-muted);
  transition: all 0.15s;
}
.cat-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}
.cat-tab.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  box-shadow: var(--accent-glow-sm);
}
.cat-tab.main_oeuvre.active { background: var(--accent); border-color: var(--accent); color: #000; }
.cat-tab.fourniture.active  { background: #10B981; border-color: #10B981; color: #000; }
.cat-tab.deplacement.active { background: var(--warning); border-color: var(--warning); color: #000; }

.cat-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}
.cat-badge.main_oeuvre { background: var(--accent-dim);            color: var(--accent); }
.cat-badge.fourniture  { background: rgba(16,185,129,0.1);         color: #10B981; }
.cat-badge.deplacement { background: rgba(245,158,11,0.1);         color: var(--warning); }

/* ── METIER GRID ─────────────────────────────────────────────── */

.metiers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 10px;
  margin-top: 6px;
}

.metier-checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
  background: #0D0D0D;
}
.metier-checkbox-item:hover { border-color: rgba(0,229,140,0.3); background: var(--accent-dim); }
.metier-checkbox-item input[type="checkbox"] { display: none; }
.metier-checkbox-item.checked {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}
.metier-checkbox-item .metier-icon { font-size: 18px; flex-shrink: 0; }
.metier-checkbox-item .metier-label { font-size: 13px; line-height: 1.3; }

.metier-autre-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: #0D0D0D;
}
.metier-autre-row:hover { border-color: rgba(0,229,140,0.3); }
.metier-autre-row input[type="checkbox"] { display: none; }
.metier-autre-row.checked { border-color: var(--accent); background: var(--accent-dim); }

.metier-autre-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  min-width: 0;
}
.metier-autre-input::placeholder { font-weight: 400; color: var(--text-muted); }

.metier-selector {
  background: var(--card-bg);
  border: 1px solid rgba(0,229,140,0.18);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.metier-selector label {
  font-weight: 700;
  font-size: 11px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0;
}
.metier-selector select { flex: 1; min-width: 180px; }

.metier-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(0,229,140,0.2);
}
.metier-badge.universal {
  background: rgba(255,255,255,0.04);
  color: var(--text-muted);
  border-color: var(--border);
}

/* ── LOGO UPLOAD ─────────────────────────────────────────────── */

.logo-preview {
  width: 100px;
  height: 100px;
  border-radius: var(--radius);
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s;
  background: #0D0D0D;
}
.logo-preview:hover { border-color: var(--accent); }
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.logo-placeholder { font-size: 32px; color: var(--text-light); opacity: 0.5; }

/* ── RESPONSIVE ─────────────────────────────────────────────── */

@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .devis-editor { grid-template-columns: 1fr 260px; }
}

@media (max-width: 900px) {
  .devis-editor { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .sidebar { transform: translateX(-240px); transition: transform 0.3s; }
  .sidebar.open { transform: translateX(0); width: 240px; }
  .main-content { margin-left: 0; }
  .page-content { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
  .form-grid.cols-2, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  /* Téléphone (site mobile et appli Android) : rien ne dépasse de l'écran.
     Les titres et les boutons passent à la ligne au lieu de pousser la page. */
  .topbar { height: auto; min-height: 64px; flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
  .topbar-actions { flex-wrap: wrap; gap: 8px; }
  .topbar-actions .btn { padding: 8px 12px; font-size: 13px; }
  .card-header { flex-wrap: wrap; gap: 10px; }
  .card-header > .d-flex { flex-wrap: wrap; width: 100%; }
  .card-header > .d-flex .form-control { flex: 1 1 140px; min-width: 0; width: auto; }
  body .devis-header-card { flex-wrap: wrap; gap: 14px; padding: 18px; }
  body .devis-header-card > * { min-width: 0; }
  body .devis-header-card > :last-child { flex-wrap: wrap; }
}
/* Colonnes de l'éditeur de devis : un tableau large défile dans son cadre
   au lieu d'élargir toute la page. */
.devis-editor > * { min-width: 0; }

@media (max-width: 480px) {
  .auth-card { padding: 24px; }
  .stats-grid { grid-template-columns: 1fr; }
}

/* ── TOAST ──────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}

.toast {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  border-left: 3px solid var(--accent);
  font-size: 14px;
  animation: toastIn 0.25s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.toast.success { border-left-color: var(--accent); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info    { border-left-color: #3B82F6; }

@keyframes toastIn {
  from { transform: translateX(100px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}


/* Champs du profil à compléter avant facturation. */
.form-control.profile-field-missing {
  border: 2px solid #ff7070;
  background-color: rgba(255, 68, 68, 0.08);
  scroll-margin-block: 100px;
}
.form-control.profile-field-missing:focus {
  border-color: #ff7070;
  box-shadow: 0 0 0 3px rgba(255, 112, 112, 0.22);
}
.profile-field-hint {
  color: #ff9292;
  font-size: 13px;
  margin: 6px 0 0;
}
