@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600&family=DM+Sans:wght@300;400;500&display=swap');

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

:root {
  --gold: #C9A84C;
  --gold-light: #F0D98C;
  --dark: #1A1A1A;
  --surface: #F8F7F4;
  --card: #FFFFFF;
  --border: #E4E0D6;
  --text: #1A1A1A;
  --muted: #767267;
  --accent: #1E3A5F;
  --accent-light: #E8EFF7;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--surface);
  color: var(--text);
}

a { text-decoration: none; color: inherit; }

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

/* ---------- TOPBAR ---------- */
.topbar { background: var(--accent); padding: 0 1.5rem; display: flex; align-items: center; justify-content: space-between; height: 56px; flex-shrink: 0; }
.logo { font-family: 'Playfair Display', serif; color: #fff; font-size: 18px; font-weight: 600; letter-spacing: .5px; display: flex; align-items: center; gap: 8px; }
.logo-icon { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--gold); }
.topnav { display: flex; gap: 4px; }
.topnav button { background: transparent; border: none; color: rgba(255,255,255,.75); font-family: 'DM Sans', sans-serif; font-size: 13px; padding: 6px 14px; border-radius: 6px; cursor: pointer; transition: all .15s; }
.topnav button.active, .topnav button:hover { background: rgba(255,255,255,.15); color: #fff; }
.topbar-user { display: flex; align-items: center; gap: 10px; position: relative; }
.topbar-username { color: rgba(255,255,255,.85); font-size: 13px; }
.user-badge { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 500; color: #fff; cursor: pointer; }
.user-dropdown { display: none; position: absolute; top: 44px; right: 0; background: var(--card); border: 1px solid var(--border); border-radius: 10px; min-width: 160px; overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 200; }
.user-dropdown.open { display: block; }
.user-dropdown a { display: block; padding: 10px 14px; font-size: 13px; color: var(--text); }
.user-dropdown a:hover { background: var(--surface); }

/* ---------- LAYOUT ---------- */
.main { display: flex; flex: 1; }
.sidebar { width: 210px; background: var(--card); border-right: 1px solid var(--border); padding: 1rem 0; flex-shrink: 0; display: flex; flex-direction: column; }
.sidebar-logo-wrap { padding: 0 .75rem 1rem; }
.sidebar-logo { width: 100%; max-height: 60px; object-fit: contain; border-radius: 6px; display: block; }
.sidebar-section { padding: 0 .75rem; margin-bottom: 1.5rem; }
.sidebar-label { font-size: 10px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; padding: 0 .75rem; margin-bottom: .5rem; }
.sidebar-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--muted); margin-bottom: 2px; transition: all .12s; }
.sidebar-item:hover { background: var(--accent-light); color: var(--accent); }
.sidebar-item.active { background: var(--accent-light); color: var(--accent); font-weight: 500; }
.sidebar-icon { font-size: 14px; width: 18px; text-align: center; }
.badge { background: var(--gold-light); color: #8a6d1c; font-size: 10px; font-weight: 500; padding: 2px 7px; border-radius: 10px; margin-left: auto; }
.content { flex: 1; padding: 1.5rem; max-width: 100%; overflow-x: hidden; }

.goal-widget { background: var(--accent-light); border-radius: 10px; padding: 12px; margin-top: 1rem; }
.goal-label { font-size: 11px; font-weight: 500; color: var(--accent); margin-bottom: 4px; }
.goal-value { font-size: 18px; font-weight: 500; color: var(--text); }
.goal-track { height: 4px; background: var(--border); border-radius: 2px; margin-top: 6px; }
.goal-fill { height: 100%; background: var(--accent); border-radius: 2px; }
.goal-sub { font-size: 10px; color: var(--muted); margin-top: 4px; }

/* ---------- COMMON ---------- */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 10px; }
.page-title { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 600; color: var(--text); }
.btn-primary { background: var(--accent); color: #fff; border: none; padding: 9px 18px; border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: all .15s; }
.btn-primary:hover { background: #16304F; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); padding: 8px 16px; border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: 13px; cursor: pointer; transition: all .15s; }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: #FCEBEB; color: #A32D2D; border: 1px solid #f2c9c9; padding: 8px 16px; border-radius: 8px; font-size: 13px; cursor: pointer; }
.btn-danger:hover { background: #f8d7d7; }

.section-title { font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 1rem; }

.flash { padding: 10px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 1rem; }
.flash-success { background: #EAF3DE; color: #3B6D11; }
.flash-error { background: #FCEBEB; color: #A32D2D; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 1.5rem; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.25rem; }
.kpi-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kpi-value { font-size: 24px; font-weight: 500; color: var(--text); margin-bottom: 2px; }
.kpi-sub { font-size: 11px; color: var(--muted); }
.kpi-trend { color: #3B6D11; font-size: 11px; font-weight: 500; }
.kpi-trend.down { color: #A32D2D; }

/* ---------- TABLES ---------- */
.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
thead tr { background: var(--surface); border-bottom: 1px solid var(--border); }
th { font-size: 11px; font-weight: 500; color: var(--muted); text-align: left; padding: 10px 16px; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
td { padding: 12px 16px; font-size: 13px; color: var(--text); border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface); }

.status { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.status-dot { width: 5px; height: 5px; border-radius: 50%; }
.s-confirmee { background: #EAF3DE; color: #3B6D11; } .s-confirmee .status-dot { background: #639922; }
.s-en_attente { background: #FAEEDA; color: #854F0B; } .s-en_attente .status-dot { background: #BA7517; }
.s-annulee { background: #FCEBEB; color: #A32D2D; } .s-annulee .status-dot { background: #E24B4A; }
.s-livree { background: #E6F1FB; color: #185FA5; } .s-livree .status-dot { background: #378ADD; }

.action-btns { display: flex; gap: 6px; }
.icon-btn { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 12px; color: var(--muted); transition: all .12s; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn.danger:hover { border-color: #E24B4A; color: #A32D2D; }

/* ---------- VEHICLES ---------- */
.vehicles-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.vehicle-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; transition: all .15s; position: relative; }
.vehicle-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.vehicle-img { height: 140px; display: flex; align-items: center; justify-content: center; font-size: 48px; background: var(--surface); position: relative; overflow: hidden; }
.vehicle-img img { width: 100%; height: 100%; object-fit: cover; }
.vehicle-badge { position: absolute; top: 8px; right: 8px; background: var(--gold); color: #fff; font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.vehicle-badge.disponible { background: #3B6D11; }
.vehicle-badge.reserve { background: #854F0B; }
.vehicle-badge.vendu { background: #6b6b6b; }
.vehicle-info { padding: 12px; }
.vehicle-name { font-family: 'Playfair Display', serif; font-size: 14px; font-weight: 600; color: var(--text); }
.vehicle-model { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.vehicle-price { font-size: 16px; font-weight: 500; color: var(--accent); }
.vehicle-price span { font-size: 11px; font-weight: 400; color: var(--muted); }
.vehicle-specs { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.spec-tag { background: var(--surface); border: 1px solid var(--border); font-size: 10px; padding: 2px 8px; border-radius: 10px; color: var(--muted); }
.vehicle-actions { display: flex; gap: 6px; padding: 0 12px 12px; }

.filters { display: flex; gap: 8px; margin-bottom: 1.25rem; flex-wrap: wrap; }
.filter-btn { background: var(--card); border: 1px solid var(--border); color: var(--muted); padding: 6px 14px; border-radius: 20px; font-size: 12px; cursor: pointer; transition: all .12s; font-family: 'DM Sans', sans-serif; }
.filter-btn.active, .filter-btn:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

/* ---------- FORMS ---------- */
.form-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; max-width: 640px; }
.form-row { margin-bottom: 1rem; }
.form-label { font-size: 12px; font-weight: 500; color: var(--muted); display: block; margin-bottom: 5px; }
.form-input, select.form-input, textarea.form-input { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-family: 'DM Sans', sans-serif; font-size: 13px; color: var(--text); background: var(--card); outline: none; transition: border-color .12s; }
.form-input:focus { border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.form-error { color: #A32D2D; font-size: 12px; margin-top: 4px; }
.form-help { color: var(--muted); font-size: 11px; margin-top: 4px; }
.current-image { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.current-image img { width: 60px; height: 45px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

/* ---------- CLIENTS ---------- */
.search-bar { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin-bottom: 1.25rem; }
.search-bar input { border: none; background: transparent; font-family: 'DM Sans', sans-serif; font-size: 13px; color: var(--text); outline: none; flex: 1; }
.clients-list { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.client-row { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); gap: 12px; transition: background .1s; }
.client-row:last-child { border-bottom: none; }
.client-row:hover { background: var(--surface); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 500; flex-shrink: 0; background: var(--accent-light); color: var(--accent); }
.client-info { flex: 1; min-width: 0; }
.client-name { font-size: 13px; font-weight: 500; color: var(--text); }
.client-detail { font-size: 12px; color: var(--muted); }
.client-stats { text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---------- DASHBOARD ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.chart-bar-wrap { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.bar-label { width: 70px; color: var(--muted); flex-shrink: 0; }
.bar-track { flex: 1; height: 8px; background: var(--surface); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--accent); }
.bar-val { width: 36px; text-align: right; color: var(--text); font-weight: 500; flex-shrink: 0; }

.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: 12px; padding-bottom: 1.25rem; position: relative; }
.timeline-item::before { content: ''; position: absolute; left: 17px; top: 34px; bottom: 0; width: 1px; background: var(--border); }
.timeline-item:last-child::before { display: none; }
.tl-icon { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; border: 1px solid var(--border); background: var(--card); }
.tl-body { flex: 1; padding-top: 6px; }
.tl-title { font-size: 13px; font-weight: 500; color: var(--text); }
.tl-time { font-size: 11px; color: var(--muted); }

/* ---------- LOGIN ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--surface); padding: 1rem; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 2.5rem; width: 380px; max-width: 100%; text-align: center; }
.login-logo { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 1rem; display: block; object-fit: cover; }
.login-title { font-family: 'Playfair Display', serif; font-size: 20px; font-weight: 600; margin-bottom: .25rem; }
.login-sub { font-size: 12px; color: var(--muted); margin-bottom: 1.75rem; }
.login-card .form-row { text-align: left; }
.login-card .btn-primary { width: 100%; justify-content: center; margin-top: .5rem; }

/* ---------- PLANNING ---------- */
.planning-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.planning-weekday { font-size: 11px; font-weight: 500; color: var(--muted); text-transform: uppercase; text-align: center; padding: 6px 0; }
.planning-cell { background: var(--card); border: 1px solid var(--border); border-radius: 8px; min-height: 90px; padding: 6px; }
.planning-cell.empty { background: transparent; border: none; }
.planning-cell.today { border-color: var(--accent); background: var(--accent-light); }
.planning-daynum { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.planning-event { display: block; font-size: 10px; padding: 2px 6px; border-radius: 6px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.planning-event.s-en_attente { background: #FAEEDA; color: #854F0B; }
.planning-event.s-confirmee { background: #EAF3DE; color: #3B6D11; }
.planning-event.s-livree { background: #E6F1FB; color: #185FA5; }
.planning-event.s-annulee { background: #FCEBEB; color: #A32D2D; text-decoration: line-through; }

/* ---------- GALERIE VEHICULE ---------- */
.gallery-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.gallery-item { position: relative; width: 80px; height: 60px; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.gallery-item .gallery-delete { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 4px; font-size: 10px; padding: 1px 5px; cursor: pointer; }

/* ---------- IMPRESSION BON DE COMMANDE ---------- */
.print-sheet { max-width: 720px; margin: 0 auto; background: var(--card); padding: 2.5rem; }
.print-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--accent); padding-bottom: 1rem; margin-bottom: 1.5rem; }
.print-header img { height: 40px; }
.print-title { font-family: 'Playfair Display', serif; font-size: 20px; font-weight: 600; }
.print-section { margin-bottom: 1.25rem; }
.print-section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 8px; }
.print-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.print-total { display: flex; justify-content: space-between; font-size: 16px; font-weight: 600; margin-top: 10px; }
.print-signatures { display: flex; justify-content: space-between; margin-top: 3rem; }
.signature-box { width: 45%; border-top: 1px solid var(--text); padding-top: 6px; font-size: 11px; color: var(--muted); text-align: center; }
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}

/* ---------- HISTORIQUE ---------- */
.history-item { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.history-item:last-child { border-bottom: none; }

.equip-checklist { max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--surface); }
.equip-checkbox { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 2px; cursor: pointer; }
.equip-checkbox input { flex-shrink: 0; }

/* ---------- USERS ---------- */
.role-tag { font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.role-admin { background: var(--gold-light); color: #8a6d1c; }
.role-vendeur { background: var(--accent-light); color: var(--accent); }
.status-inactive { color: var(--muted); font-style: italic; }

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .vehicles-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topnav { display: none; }
}
