/* ============================================================
   CLIC FLASH CRM — Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500;1,600&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg:           #faf8f5;
  --bg-alt:       #f3ede4;
  --white:        #FFFFFF;
  --accent:       #e25570;
  --accent-hover: #c43d5a;
  --accent-light: #fdf0f3;
  --neutral:      #d9c8b4;
  --text:         #3d2e26;
  --muted:        #9b8678;
  --border:       #e8ddd3;

  --font-title: 'Cormorant Garamond', serif;
  --font-ui:    'DM Sans', sans-serif;

  --sidebar-w:  240px;
  --topbar-h:   60px;
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;

  --shadow-sm:  0 1px 3px rgba(61,46,38,.06), 0 1px 2px rgba(61,46,38,.04);
  --shadow-md:  0 4px 12px rgba(61,46,38,.08), 0 2px 4px rgba(61,46,38,.04);
  --shadow-lg:  0 12px 32px rgba(61,46,38,.10), 0 4px 8px rgba(61,46,38,.04);

  --transition: 150ms cubic-bezier(.4,0,.2,1);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--font-ui); cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: var(--font-ui); font-size: 14px; }
ul, ol { list-style: none; }
img { display: block; max-width: 100%; }

/* ── Logo ───────────────────────────────────────────────────── */
.logo {
  font-family: var(--font-title);
  font-size: 20px;
  font-style: italic;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  user-select: none;
}
.logo .dot { color: var(--accent); font-style: normal; }

/* ── Layout ─────────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar content";
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  grid-area: sidebar;
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-header .logo { color: var(--text); }
.sidebar-header .logo .dot { color: var(--accent); }

.sidebar-subtitle {
  font-size: 10px;
  font-family: var(--font-ui);
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 3px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  border-left: 2px solid transparent;
  margin-bottom: 2px;
}

.nav-item:hover {
  color: var(--text);
  background: var(--bg-alt);
}

.nav-item.active {
  color: #ffffff;
  background: var(--accent);
  border-left-color: transparent;
}

.nav-item.active svg { color: #ffffff; }
.nav-item svg { flex-shrink: 0; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: .6;
  padding: 12px 12px 6px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--bg-alt);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-email {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  font-size: 12px;
  color: var(--muted);
  transition: color var(--transition);
  padding: 0;
  margin-top: 2px;
  display: block;
}
.btn-logout:hover { color: var(--accent); }

/* ── Hamburger (mobile) ─────────────────────────────────────── */
.btn-hamburger {
  display: none;
  padding: 8px;
  color: var(--text);
  border-radius: var(--radius-sm);
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}

/* ── Top Bar ─────────────────────────────────────────────────── */
.topbar {
  grid-area: topbar;
  position: sticky; top: 0;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px 0 20px;
  z-index: 50;
  min-height: var(--topbar-h);
}

.topbar-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
}

.topbar-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ── Main Content ────────────────────────────────────────────── */
.app-content {
  grid-area: content;
  padding: 32px;
  min-height: calc(100vh - var(--topbar-h));
  background: var(--bg);
}

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-family: var(--font-title);
  font-size: 30px;
  font-style: italic;
  font-weight: 500;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.page-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}
.page-header-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

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

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  letter-spacing: .01em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-top: 3px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.stat-card.accent-top { border-top-color: var(--accent); }
.stat-card.green-top { border-top-color: #2D7A4F; }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.stat-value {
  font-family: var(--font-title);
  font-size: 32px;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.02em;
}
.stat-value.accent { color: var(--accent); }
.stat-value.success { color: #2D7A4F; }
.stat-value.danger { color: #C0392B; }

.stat-delta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

/* ── Dashboard modules ───────────────────────────────────────── */
.dash-modules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.dash-module { cursor: default; }
.dash-module-full { grid-column: 1 / -1; }

/* ── Table ───────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--white);
  box-shadow: var(--shadow-sm);
}

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

thead th {
  background: var(--bg-alt);
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

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

tbody tr:last-child td { border-bottom: none; }

tbody tr {
  transition: background var(--transition);
  cursor: pointer;
}
tbody tr:hover { background: var(--bg); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  font-family: var(--font-ui);
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-sm); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-alt); }

.btn-danger {
  background: transparent;
  color: #C0392B;
  border: 1px solid #f5c6c6;
}
.btn-danger:hover { background: #fdf0f0; }

.btn-sm {
  padding: 5px 10px;
  font-size: 12.5px;
}

.btn-icon {
  padding: 6px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--bg-alt); color: var(--text); border-color: var(--border); }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.form-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-ui);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(226,85,112,.12);
}

.input::placeholder { color: var(--neutral); }

select.input { cursor: pointer; }

textarea.input {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

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

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-devis { background: #f3ede4; color: #7a6350; }
.badge-acompte { background: #e8f0fd; color: #2d5db0; }
.badge-solde { background: #e6f4ee; color: #2D7A4F; }
.badge-livre { background: #e0f0ff; color: #1a5fa8; }
.badge-annule { background: #fdecea; color: #C0392B; }
.badge-attente { background: #fff7e6; color: #9a6800; }
.badge-paye { background: #e6f4ee; color: #2D7A4F; }
.badge-prevu { background: #e8f0fd; color: #2d5db0; }
.badge-fait { background: #e6f4ee; color: #2D7A4F; }
.badge-gray { background: var(--bg-alt); color: var(--muted); }
.badge-pink { background: var(--accent-light); color: var(--accent); }
.badge-mariage   { background: #fce7f3; color: #9d174d; }
.badge-portrait  { background: #ede9fe; color: #5b21b6; }
.badge-evenement { background: #e0f2fe; color: #0369a1; }

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

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in .15s ease;
}
.modal-lg { max-width: 740px; }
.modal-xl { max-width: 900px; }
.modal-fullscreen { max-width: 98vw; max-height: 95vh; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-title {
  font-family: var(--font-title);
  font-size: 22px;
  font-style: italic;
  font-weight: 500;
  color: var(--text);
}

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn-close {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--muted);
  transition: all var(--transition);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.btn-close:hover { background: var(--bg-alt); color: var(--text); }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}
.alert-error { background: #fdecea; color: #C0392B; border: 1px solid #f5c6c6; }
.alert-success { background: #e6f4ee; color: #2D7A4F; border: 1px solid #b8dfc9; }
.alert-info { background: #e8f0fd; color: #2d5db0; border: 1px solid #b8cfef; }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  padding: 12px 18px;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #C0392B; }
.toast.success { background: #2D7A4F; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-state-icon {
  font-size: 40px;
  margin-bottom: 16px;
  opacity: .4;
}
.empty-state-title {
  font-family: var(--font-title);
  font-size: 20px;
  font-style: italic;
  color: var(--text);
  margin-bottom: 6px;
}
.empty-state-text { font-size: 13.5px; }

/* ── Helpers ─────────────────────────────────────────────────── */
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-gap { display: flex; align-items: center; gap: 8px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 12.5px; }
.text-accent { color: var(--accent); }
.text-right { text-align: right; }
.text-bold { font-weight: 600; }

/* ── Activity list ───────────────────────────────────────────── */
.activity-list { display: flex; flex-direction: column; gap: 10px; }
.activity-item { display: flex; align-items: flex-start; gap: 10px; }
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--neutral);
  margin-top: 5px;
  flex-shrink: 0;
}
.activity-dot.green { background: #2D7A4F; }
.activity-dot.red { background: #C0392B; }
.activity-dot.accent { background: var(--accent); }
.activity-dot.blue { background: #2d5db0; }
.activity-text { font-size: 13.5px; color: var(--text); line-height: 1.4; }
.activity-time { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Calendrier ──────────────────────────────────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}
.cal-day-header {
  background: var(--bg-alt);
  padding: 8px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.cal-day {
  background: var(--white);
  min-height: 90px;
  padding: 6px;
  position: relative;
}
.cal-day.other-month { background: var(--bg); }
.cal-day.today .cal-date { background: var(--accent); color: #fff; border-radius: 50%; }
.cal-date {
  font-size: 12px;
  font-weight: 600;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
  color: var(--text);
}
.cal-event {
  font-size: 11px;
  padding: 2px 5px;
  border-radius: 3px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
}
.cal-event.rdv { background: #e8f0fd; color: #2d5db0; }
.cal-event.dossier { background: var(--accent-light); color: var(--accent); }

/* ── Filters bar ─────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filter-btn {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition);
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Search input ────────────────────────────────────────────── */
.search-input-wrap {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.search-input-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search-input-wrap .input {
  padding-left: 34px;
}

/* ── Fiche (detail view) ─────────────────────────────────────── */
.fiche-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

/* ── Lignes facture ──────────────────────────────────────────── */
.ligne-row {
  display: grid;
  grid-template-columns: 1fr 1fr 120px 90px 30px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.ligne-offert { text-decoration: line-through; color: var(--muted); }

/* ── Responsive Mobile ───────────────────────────────────────── */
@media (max-width: 768px) {
  .btn-hamburger { display: flex; }

  .app-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "content";
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open {
    display: block;
  }

  .topbar { padding: 0 16px; }
  .app-content { padding: 20px 16px; }

  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dash-modules-grid { grid-template-columns: 1fr; }
  .dash-module-full { grid-column: 1; }

  .fiche-layout { grid-template-columns: 1fr; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }

  .ligne-row { grid-template-columns: 1fr 80px 30px; }
  .ligne-row .ligne-date, .ligne-row .ligne-note { display: none; }

  table { font-size: 12.5px; }
  thead th, tbody td { padding: 10px 12px; }
}
