/* ============================================================
   Nestor Assist — Dashboard Client (Restaurants)
   Design system premium · thème dynamique (couleurs entreprise)
   ============================================================ */

:root {
  /* Couleurs de marque — surchargées par theme.js au login */
  --primary: #00b4a6;
  --primary-hover: #009d96;
  --primary-light: #e0f7f5;
  --primary-rgb: 0, 180, 166;
  --secondary: #1e3280;

  --sidebar-bg: #0c1424;
  --sidebar-hover: rgba(255,255,255,0.06);
  --sidebar-active-bg: rgba(var(--primary-rgb), 0.18);
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #f1f5f9;
  --sidebar-border: rgba(255,255,255,0.07);
  --sidebar-w: 256px;

  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e2e8f0;
  --border-light: #eef2f7;

  --success: #10b981; --success-light: #d1fae5; --success-text: #065f46;
  --warning: #f59e0b; --warning-light: #fef3c7; --warning-text: #92400e;
  --danger: #ef4444;  --danger-light: #fee2e2;  --danger-text: #991b1b;
  --info: #3b82f6;    --info-light: #dbeafe;    --info-text: #1e40af;
  --purple: #8b5cf6;  --purple-light: #ede9fe;  --purple-text: #5b21b6;

  --text: #1e293b; --text-secondary: #64748b; --text-muted: #94a3b8;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,.08);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.1);
  --shadow-xl: 0 25px 50px -12px rgba(0,0,0,.18);

  --radius-sm: 6px; --radius: 9px; --radius-md: 11px; --radius-lg: 14px; --radius-full: 9999px;
  --header-h: 64px;
  --transition: .18s ease;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.55; }
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
input, textarea, select, button { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
ul { list-style: none; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 1.2rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 600; }
p { color: var(--text-secondary); }

/* ── Login ─────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, var(--secondary) 60%, var(--sidebar-bg) 100%);
  padding: 1.5rem; position: relative; overflow: hidden;
}
.login-page::before, .login-page::after {
  content: ''; position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(var(--primary-rgb),.18) 0%, transparent 70%);
}
.login-page::before { width: 600px; height: 600px; top: -200px; right: -180px; }
.login-page::after { width: 420px; height: 420px; bottom: -160px; left: -120px; }
.login-card {
  width: 100%; max-width: 410px; background: rgba(255,255,255,.98);
  border-radius: var(--radius-lg); padding: 2.5rem 2.25rem; box-shadow: var(--shadow-xl);
  position: relative; z-index: 1;
}
.login-logo { display: flex; flex-direction: column; align-items: center; gap: .85rem; margin-bottom: 1.75rem; }
.login-logo-icon {
  width: 54px; height: 54px; border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  display: flex; align-items: center; justify-content: center;
  color: #fff; box-shadow: 0 6px 18px rgba(var(--primary-rgb),.45);
}
.login-brand { text-align: center; }
.login-brand h1 { font-size: 1.3rem; }
.login-brand span { color: var(--text-muted); font-size: .85rem; }

/* ── Forms ─────────────────────────────────────────────────── */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .4rem; color: var(--text); }
.input, input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; padding: .65rem .8rem; border: 1.5px solid var(--border); border-radius: var(--radius);
  background: #fff; transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb),.15);
}
textarea { resize: vertical; min-height: 84px; }
input[type=color] { height: 42px; padding: 4px; cursor: pointer; }
.field-row { display: flex; gap: .9rem; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 150px; }
.hint { font-size: .78rem; color: var(--text-muted); margin-top: .3rem; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .6rem 1.1rem; border-radius: var(--radius); font-weight: 600; font-size: .9rem;
  transition: var(--transition); white-space: nowrap;
}
.btn-primary { background: var(--btn-primary-bg, var(--primary)); color: #fff; border: 1.5px solid var(--btn-primary-bg, var(--primary)); border-radius: var(--radius); }
.btn-primary:hover { background: var(--btn-primary-hover, var(--primary-hover)); border-color: var(--btn-primary-hover, var(--primary-hover)); }
.btn-block { width: 100%; }
.btn-ghost { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: #fff; border-color: var(--text-muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: .4rem .7rem; font-size: .82rem; }
.btn-icon { padding: .45rem; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--border); }
.btn-icon:hover { background: #fff; border-color: var(--text-muted); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ── Layout ────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40;
  transition: transform .25s ease;
}
.sidebar-head { padding: 1.25rem 1.25rem 1rem; border-bottom: 1px solid var(--sidebar-border); }
.sidebar-resto { display: flex; align-items: center; gap: .7rem; }
.sidebar-resto .avatar {
  width: 38px; height: 38px; border-radius: var(--radius); flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: .95rem;
  overflow: hidden;
}
.sidebar-resto .avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-resto-info { min-width: 0; }
.sidebar-resto-info strong { color: var(--sidebar-text-active); font-size: .92rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-resto-info span { font-size: .74rem; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .65rem; }
.nav-item {
  display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: var(--radius);
  color: var(--sidebar-text); font-size: .9rem; font-weight: 500; cursor: pointer;
  border-left: 3px solid transparent; margin-bottom: 2px; transition: var(--transition);
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-active); }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-text-active); border-left-color: var(--primary); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--primary); color: #fff; font-size: .68rem; font-weight: 700; padding: 1px 7px; border-radius: var(--radius-full); }
.sidebar-foot { padding: .85rem 1rem; border-top: 1px solid var(--sidebar-border); font-size: .72rem; color: var(--text-muted); }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--header-h); background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem; position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 1.15rem; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .65rem; }
.burger { display: none; }
.user-chip { display: flex; align-items: center; gap: .6rem; padding: .35rem .55rem; border-radius: var(--radius); }
.user-chip .avatar { width: 34px; height: 34px; border-radius: var(--radius-full); background: var(--primary-light); color: var(--text); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; }
.user-chip-info { line-height: 1.2; }
.user-chip-info strong { font-size: .85rem; display: block; }
.user-chip-info span { font-size: .72rem; color: var(--text-muted); }
.content { padding: 1.5rem; flex: 1; }

/* ── Cards / KPI ───────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 1.25rem; }
.section-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.section-head h2 { margin-right: auto; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow-sm); position: relative;
}
.kpi-label { font-size: .8rem; color: var(--text-secondary); font-weight: 500; display: flex; align-items: center; gap: .5rem; }
.kpi-label svg { width: 17px; height: 17px; color: var(--primary); }
.kpi-value { font-size: 1.9rem; font-weight: 750; letter-spacing: -.02em; margin-top: .35rem; }
.kpi-sub { font-size: .78rem; color: var(--text-muted); margin-top: .15rem; }

/* ── Badges ────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: var(--radius-full); font-size: .76rem; font-weight: 600; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-en_attente { background: var(--warning-light); color: var(--warning-text); }
.badge-confirmee { background: var(--success-light); color: var(--success-text); }
.badge-annulee   { background: var(--danger-light);  color: var(--danger-text); }
.badge-refusee   { background: var(--danger-light);  color: var(--danger-text); }
.badge-deplacee  { background: var(--info-light);    color: var(--info-text); }
.badge-terminee  { background: #e2e8f0;              color: #475569; }
.badge-no_show   { background: var(--purple-light);  color: var(--purple-text); }
.badge-nouveau   { background: var(--info-light);    color: var(--info-text); }
.badge-lu        { background: #e2e8f0;              color: #475569; }
.badge-traite    { background: var(--success-light); color: var(--success-text); }
.badge-archive   { background: #f1f5f9;              color: #94a3b8; }
.tag { background: var(--primary-light); color: var(--primary-hover); padding: .15rem .55rem; border-radius: var(--radius-full); font-size: .72rem; font-weight: 600; }

/* ── Tables ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; padding: .7rem .9rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: .8rem .9rem; border-bottom: 1px solid var(--border-light); font-size: .9rem; vertical-align: middle; }
table.data tbody tr:hover { background: var(--bg); }
table.data tbody tr { cursor: default; }
table.data tr.clickable { cursor: pointer; }

/* ── Filters bar ───────────────────────────────────────────── */
.filters { display: flex; gap: .65rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.1rem; }
.filters input, .filters select { width: auto; min-width: 130px; padding: .5rem .7rem; }
.search-box { position: relative; }
.search-box input { padding-left: 2.1rem; min-width: 220px; }
.search-box svg { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); }

/* ── Modal / Drawer ────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: none; align-items: center; justify-content: center; z-index: 60; padding: 1.25rem; }
.overlay.show { display: flex; }
.modal { background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-xl); }
.modal-lg { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff; }
.modal-head h3 { font-size: 1.1rem; }
.modal-body { padding: 1.4rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: .65rem; padding: 1rem 1.4rem; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: #fff; }
.close-x { width: 32px; height: 32px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.close-x:hover { background: var(--bg); color: var(--text); }

/* ── Toasts ────────────────────────────────────────────────── */
.toasts { position: fixed; top: 1rem; right: 1rem; z-index: 100; display: flex; flex-direction: column; gap: .6rem; }
.toast { background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius); padding: .8rem 1rem; box-shadow: var(--shadow-lg); min-width: 260px; max-width: 360px; animation: slideIn .25s ease; font-size: .9rem; }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── States ────────────────────────────────────────────────── */
.empty { text-align: center; padding: 3rem 1.5rem; color: var(--text-muted); }
.empty svg { width: 48px; height: 48px; margin: 0 auto 1rem; color: var(--border); }
.empty h3 { color: var(--text-secondary); margin-bottom: .35rem; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.loader { display: flex; justify-content: center; padding: 3rem; }
.loader .spinner { width: 32px; height: 32px; border-color: var(--border); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

.alert { padding: .7rem .9rem; border-radius: var(--radius); font-size: .85rem; margin-bottom: 1rem; display: none; }
.alert.show { display: block; }
.alert-error { background: var(--danger-light); color: var(--danger-text); }

/* ── Planning ──────────────────────────────────────────────── */
.planning-grid { display: grid; gap: .6rem; }
.planning-week { grid-template-columns: repeat(7, 1fr); }
.day-col { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); min-height: 120px; padding: .5rem; }
.day-col h4 { font-size: .8rem; text-align: center; padding-bottom: .4rem; border-bottom: 1px solid var(--border-light); margin-bottom: .5rem; }
.day-col h4 span { display: block; font-size: 1.1rem; color: var(--text); }
.resa-chip { font-size: .76rem; padding: .35rem .5rem; border-radius: var(--radius-sm); margin-bottom: .35rem; cursor: pointer; border-left: 3px solid var(--primary); background: var(--bg); }
.resa-chip:hover { background: var(--primary-light); }
.resa-chip.st-confirmee { border-left-color: var(--success); }
.resa-chip.st-en_attente { border-left-color: var(--warning); }
.resa-chip.st-annulee, .resa-chip.st-refusee { border-left-color: var(--danger); opacity: .6; }
.resa-chip.st-deplacee { border-left-color: var(--info); }
.resa-chip.st-no_show { border-left-color: var(--purple); }
.resa-chip strong { font-weight: 600; }

/* ── Misc helpers ──────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.flex { display: flex; align-items: center; gap: .6rem; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.muted { color: var(--text-muted); }
.mb-1 { margin-bottom: .75rem; } .mb-2 { margin-bottom: 1.25rem; }
.row-actions { display: flex; gap: .4rem; }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { display: none; }
.switch .slider { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: var(--transition); }
.switch .slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: var(--transition); box-shadow: var(--shadow-sm); }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.bar { height: 8px; background: var(--border-light); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .burger { display: inline-flex; }
  .grid-2 { grid-template-columns: 1fr; }
  .planning-week { grid-template-columns: 1fr; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 39; display: none; }
  .sidebar-backdrop.show { display: block; }
}
