/* ═══════════════════════════════════════════════════════════
   L'Atelier Go — Feuille de style principale
   ═══════════════════════════════════════════════════════════ */

:root {
  --sidebar-w : 240px;
  --primary   : #4f46e5;
  --primary-dk: #4338ca;
  --primary-lt: #eef2ff;
  --secondary : #f97316;
  --success   : #22c55e;
  --warning   : #f59e0b;
  --danger    : #ef4444;
  --info      : #3b82f6;
  --sidebar   : #0f172a;
  --dark      : #1e293b;
  --text      : #334155;
  --text-lt   : #64748b;
  --border    : #e2e8f0;
  --bg        : #f8fafc;
  --white     : #ffffff;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

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

/* ─── Overlay mobile ─────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}
.sidebar-overlay.open { display: block; }

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  color: #cbd5e1;
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  transition: transform .25s ease;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.sidebar-logo h1 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
}

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 12px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  padding: 7px 10px;
}
.sidebar-search svg { color: #64748b; flex-shrink: 0; }
.sidebar-search input {
  background: none;
  border: none;
  outline: none;
  color: #e2e8f0;
  font-size: 13px;
  width: 100%;
}
.sidebar-search input::placeholder { color: #475569; }

.sidebar-logo span {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: #64748b;
  letter-spacing: .3px;
}

.sidebar-nav { flex: 1; padding: 10px 0; }

.nav-section {
  padding: 12px 16px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #475569;
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 13.5px;
  transition: background .12s, color .12s;
  border-left: 3px solid transparent;
}

.nav-link:hover  { background: rgba(255,255,255,.06); color: #e2e8f0; }
.nav-link.active {
  background: rgba(79,70,229,.18);
  color: #fff;
  border-left-color: var(--primary);
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255,255,255,.05);
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.user-name { flex: 1; font-size: 13px; color: #e2e8f0; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.logout-btn {
  color: #475569;
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  transition: color .15s;
  flex-shrink: 0;
}
.logout-btn:hover { color: #ef4444; }

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

/* ─── Topbar mobile ──────────────────────────────────────── */
.topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--sidebar);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 15px; font-weight: 700; color: #fff; flex: 1; }


.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  color: #fff;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-radius: 4px;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: .2s;
}

/* ─── Page header ────────────────────────────────────────── */
.page-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--dark);
}

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

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 20px;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.card-title { font-size: 14px; font-weight: 600; color: var(--dark); }
.card-body  { padding: 20px; }

/* ─── Statistiques ───────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--white);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon.indigo { background: var(--primary-lt); color: var(--primary); }
.stat-icon.orange { background: #fff7ed; color: var(--secondary); }
.stat-icon.green  { background: #f0fdf4; color: var(--success); }
.stat-icon.blue   { background: #eff6ff; color: var(--info); }

.stat-value { font-size: 24px; font-weight: 700; color: var(--dark); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 12px; color: var(--text-lt); }

/* ─── Tableaux ───────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; min-width: 500px; }

thead tr { background: #f8fafc; }

th {
  padding: 9px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-lt);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: none; }

.table-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-lt);
}

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-warning   { background: #fef3c7; color: #92400e; }
.badge-success   { background: #dcfce7; color: #166534; }
.badge-info      { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-danger    { background: #fee2e2; color: #991b1b; }

/* ─── Boutons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background .14s, box-shadow .14s;
  white-space: nowrap;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 6px; }

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); }

.btn-secondary { background: var(--white); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f8fafc; }

.btn-danger  { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }

.btn-success { background: #dcfce7; color: #16a34a; }
.btn-success:hover { background: #bbf7d0; }

.actions { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }

/* ─── Formulaires ────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 5px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  transition: border-color .14s, box-shadow .14s;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

textarea { resize: vertical; min-height: 72px; }

.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ─── Alertes ────────────────────────────────────────────── */
.alert {
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert-error   { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }

/* ─── Pages d'authentification ───────────────────────────── */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #1e3a5f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: var(--white);
  border-radius: 16px;
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 60px rgba(0,0,0,.35);
}

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

.auth-logo .icon {
  width: 64px; height: 64px;
  background: var(--primary);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
  box-shadow: 0 8px 24px rgba(79,70,229,.4);
}

.auth-logo h1 { font-size: 22px; font-weight: 700; color: var(--dark); }
.auth-logo p  { color: var(--text-lt); margin-top: 4px; font-size: 13px; }
.auth-form h2 { font-size: 17px; font-weight: 600; color: var(--dark); margin-bottom: 20px; }

/* ─── Modals ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.modal {
  background: var(--white);
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 24px 56px rgba(0,0,0,.22);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  position: sticky; top: 0; background: var(--white); z-index: 1;
}

.modal-title { font-size: 15px; font-weight: 600; color: var(--dark); }

.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-lt); font-size: 22px; line-height: 1;
  padding: 2px 6px; border-radius: 4px; flex-shrink: 0;
}
.modal-close:hover { color: var(--dark); background: #f1f5f9; }

.modal-body   { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ─── Filtres ────────────────────────────────────────────── */
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ─── Grille ─────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ─── Monnaie ────────────────────────────────────────────── */
.money { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ─── Dropdown statut ───────────────────────────────────── */
.statut-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  border-radius: 4px;
  font-family: inherit;
  color: var(--text);
}
.statut-btn:hover { background: #f8fafc; }

/* ─── Utilitaires ────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Mobile first
   ═══════════════════════════════════════════════════════════ */

/* Tablette (< 1024px) : sidebar se rétrécit */
@media (max-width: 1023px) {
  :root { --sidebar-w: 220px; }
}

/* Mobile (< 768px) */
@media (max-width: 767px) {

  /* Sidebar cachée par défaut, slide-in au tap */
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.35);
  }

  /* Le contenu prend toute la largeur */
  .main-content {
    margin-left: 0;
  }

  /* Topbar visible */
  .topbar { display: flex; }

  /* Le page-header n'est plus sticky sur mobile (la topbar l'est) */
  .page-header {
    position: static;
    padding: 12px 16px;
  }

  .page-body { padding: 14px 16px; }

  /* Grilles → 1 colonne */
  .form-row,
  .form-row-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  /* Stats → 2 colonnes sur mobile */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-card { padding: 14px; gap: 10px; }
  .stat-value { font-size: 20px; }

  /* Agrandir les zones de tap */
  .btn { min-height: 38px; }
  .btn-sm { min-height: 32px; }

  /* Actions empilées si besoin */
  td .actions { flex-wrap: wrap; }

  /* Modal plein écran sur mobile */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    border-radius: 16px 16px 0 0;
    max-height: 90vh;
    max-width: 100%;
  }

  /* Auth card */
  .auth-card { padding: 28px 20px; }

  /* Masquer colonnes peu importantes sur petit écran */
  .hide-mobile { display: none !important; }

  /* Cards sans overflow caché pour que les dropdowns passent */
  .card { overflow: visible; }
}

/* ─── Calendrier RDV (table simple) ─────────────────────── */
.cal-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 560px;
}

.cal-th-time {
  width: 44px;
}

.cal-th-day {
  text-align: center;
  padding: 10px 4px;
  border-left: 1px solid var(--border);
  border-bottom: 2px solid var(--border);
}
.cal-th-day.today { background: var(--primary-lt); }

.cal-day-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-lt);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.cal-day-date {
  font-size: 16px;
  font-weight: 700;
  color: var(--dark);
}
.cal-th-day.today .cal-day-date { color: var(--primary); }

.cal-hour-td {
  font-size: 10px;
  color: var(--text-lt);
  text-align: right;
  padding: 6px 6px 0 0;
  vertical-align: top;
  white-space: nowrap;
  border-top: 1px solid var(--border);
  height: 72px;
  width: 44px;
}

.cal-slot-td {
  border: 1px solid var(--border);
  height: 72px;
  padding: 3px;
  vertical-align: top;
  cursor: pointer;
  transition: background .12s;
}
.cal-slot-td:hover { background: var(--bg); }
.cal-slot-td.today { background: rgba(238, 242, 255, .2); }
.cal-slot-td.today:hover { background: rgba(238, 242, 255, .4); }

.cal-slot-event {
  display: block;
  border-radius: 5px;
  padding: 5px 7px;
  cursor: pointer;
  border-left: 3px solid;
  overflow: hidden;
  text-decoration: none;
  transition: filter .15s;
  height: calc(100% - 0px);
  box-sizing: border-box;
}
.cal-slot-event:hover { filter: brightness(.93); }

.ev-header {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-bottom: 2px;
}
.ev-time   { font-weight: 700; font-size: 11px; color: inherit; white-space: nowrap; }
.ev-immat  { font-weight: 700; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-client { font-size: 11px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-motif  { font-size: 10px; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }

/* Couleurs par statut RDV */
.rdv-planifie { background: #f1f5f9; border-color: #64748b; color: #334155; }
.rdv-confirme { background: #dbeafe; border-color: #3b82f6; color: #1e40af; }
.rdv-annule   { background: #fee2e2; border-color: #ef4444; color: #991b1b; }

/* ─── Kanban ─────────────────────────────────────────────── */
.kanban-board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 24px;
  align-items: flex-start;
  min-height: calc(100vh - 120px);
}

.kanban-col {
  flex: 0 0 260px;
  min-width: 220px;
  background: var(--bg);
  border-radius: 12px;
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: border-color .2s, background .2s;
}

.kanban-col.drag-over {
  border-color: var(--primary);
  background: var(--primary-lt);
}

.kanban-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px 10px 0 0;
  user-select: none;
}

.kanban-warning  { background: #fef3c7; }
.kanban-info     { background: #dbeafe; }
.kanban-success  { background: #dcfce7; }
.kanban-secondary{ background: #f1f5f9; }

.kanban-col-title {
  font-weight: 700;
  font-size: 13px;
  flex: 1;
  color: var(--dark);
}

.kanban-count {
  background: rgba(0,0,0,.12);
  color: var(--dark);
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 600;
}

.kanban-add {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  color: var(--text-lt);
  padding: 0 2px;
  border-radius: 4px;
  transition: color .15s, background .15s;
}
.kanban-add:hover { color: var(--primary); background: rgba(79,70,229,.1); }

.kanban-cards {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}

.kanban-empty {
  text-align: center;
  color: var(--text-lt);
  font-size: 12px;
  padding: 16px 8px;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
}

.kanban-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: grab;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  transition: box-shadow .2s, opacity .2s;
  user-select: none;
}
.kanban-card:hover { box-shadow: 0 4px 10px rgba(0,0,0,.10); }
.kanban-card.dragging { opacity: .4; cursor: grabbing; }

.kanban-card-immat {
  font-family: monospace;
  font-weight: 700;
  font-size: 13px;
  color: var(--dark);
  letter-spacing: .5px;
}
.kanban-card-sub {
  font-size: 11px;
  color: var(--text-lt);
  margin-bottom: 4px;
}
.kanban-card-client {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.kanban-card-desc {
  font-size: 12px;
  color: var(--text-lt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 8px;
}
.kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.kanban-date {
  font-size: 11px;
  color: var(--text-lt);
}
.kanban-detail-btn {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}
.kanban-detail-btn:hover { text-decoration: underline; }

/* Mobile : colonnes en scroll horizontal */
@media (max-width: 767px) {
  .kanban-board { gap: 10px; }
  .kanban-col   { flex: 0 0 80vw; }
}

/* Très petit écran (< 400px) */
@media (max-width: 399px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 15px; }
}
