/* ── InvoiceAI · App Shell CSS (shared across dashboard, invoices, clients, settings) ── */
/* Import this in each app page: <link rel="stylesheet" href="app.css"> */

/* Polices système standard */

:root {
  --bg: #f5f4f0;
  --bg2: #edecea;
  --ink: #1a1916;
  --ink2: #6b6860;
  --ink3: #a8a59f;
  --accent: #2d5be3;
  --accent-light: #eef1fd;
  --accent-dark: #1a3db8;
  --green: #16a34a;
  --green-light: #dcfce7;
  --amber: #d97706;
  --amber-light: #fef3c7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --border: #dddbd6;
  --border2: #e8e6e1;
  --white: #ffffff;
  --card: #ffffff;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --shadow: 0 1px 3px rgba(26,25,22,0.06), 0 4px 16px rgba(26,25,22,0.04);
  --shadow-lg: 0 8px 40px rgba(26,25,22,0.10);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  display: flex; align-items: center; gap: 10px;
  font-family: Arial, sans-serif; font-weight: 800; font-size: 17px;
  color: var(--ink); text-decoration: none;
  border-bottom: 1px solid var(--border2);
}
.logo-mark {
  width: 30px; height: 30px;
  background: var(--ink); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--bg); font-size: 14px; font-weight: 800;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  list-style: none;
}
.nav-section-label {
  font-size: 10px; font-family: 'Courier New', Courier, monospace;
  text-transform: uppercase; letter-spacing: 2px;
  color: var(--ink3); padding: 16px 10px 6px;
}
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--ink2); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: all 0.15s; margin-bottom: 2px;
}
.sidebar-nav a:hover { background: var(--bg); color: var(--ink); }
.sidebar-nav a.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.sidebar-nav a .nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--red); color: white;
  font-size: 10px; font-weight: 700;
  font-family: 'Courier New', Courier, monospace;
  padding: 1px 6px; border-radius: 100px;
}
.nav-badge.amber { background: var(--amber); }

.sidebar-plan {
  margin: 10px; padding: 14px;
  background: var(--ink); color: var(--bg);
  border-radius: 10px;
}
.plan-label { font-size: 10px; font-family: 'Courier New', Courier, monospace; opacity: 0.5; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.plan-name { font-family: Arial, sans-serif; font-weight: 700; font-size: 15px; margin-bottom: 10px; }
.plan-limit { font-size: 11px; opacity: 0.6; margin-bottom: 10px; }
.plan-bar { height: 4px; background: rgba(255,255,255,0.15); border-radius: 2px; margin-bottom: 12px; }
.plan-bar-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s; }
.plan-upgrade {
  display: block; text-align: center;
  background: var(--accent); color: white;
  border-radius: 6px; padding: 8px;
  font-size: 12px; font-weight: 600; text-decoration: none;
  transition: background 0.15s;
}
.plan-upgrade:hover { background: var(--accent-dark); }

.sidebar-user {
  border-top: 1px solid var(--border2);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
}
.user-av {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--ink); color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; font-family: Arial, sans-serif;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-plan { font-size: 11px; color: var(--ink3); font-family: 'Courier New', Courier, monospace; }
.user-menu { margin-left: auto; color: var(--ink3); cursor: pointer; font-size: 16px; }

/* ── MAIN CONTENT ── */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── TOPBAR ── */
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--white);
  position: sticky; top: 0; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.page-title { font-family: Arial, sans-serif; font-weight: 800; font-size: 18px; letter-spacing: -0.5px; }
.topbar-breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink3); }
.topbar-breadcrumb span { color: var(--ink); font-weight: 500; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 14px;
  font-size: 13px; color: var(--ink3);
  cursor: text; transition: border-color 0.15s;
}
.topbar-search:hover { border-color: var(--ink3); }
.topbar-search input {
  background: transparent; border: none; outline: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; font-size: 13px;
  color: var(--ink); width: 160px;
}
.topbar-search input::placeholder { color: var(--ink3); }
.topbar-icon-btn {
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--white);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px; transition: all 0.15s; position: relative;
}
.topbar-icon-btn:hover { background: var(--bg2); border-color: var(--ink3); }
.notif-dot { position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; background: var(--red); border-radius: 50%; border: 2px solid var(--white); }

/* ── PAGE CONTENT ── */
.page-content { flex: 1; padding: 32px; }

/* ── CARDS & SURFACES ── */
.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px;
}
.card-sm { padding: 16px; }
.card-title { font-family: Arial, sans-serif; font-weight: 700; font-size: 16px; letter-spacing: -0.3px; margin-bottom: 4px; }
.card-sub { font-size: 13px; color: var(--ink2); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: 8px;
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; border: none; text-decoration: none;
  transition: all 0.15s; white-space: nowrap;
}
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: #2d2b27; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(26,25,22,0.15); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-dark); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--ink2); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--ink); border-color: var(--ink2); background: var(--white); }
.btn-danger { background: var(--red-light); color: var(--red); border: 1px solid rgba(220,38,38,0.2); }
.btn-danger:hover { background: var(--red); color: white; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-icon { padding: 9px; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 100px;
  font-size: 11px; font-weight: 600;
  font-family: 'Courier New', Courier, monospace;
}
.badge-green { background: var(--green-light); color: var(--green); }
.badge-amber { background: var(--amber-light); color: var(--amber); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-blue { background: var(--accent-light); color: var(--accent); }
.badge-gray { background: var(--bg2); color: var(--ink2); }
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 10px 16px;
  font-size: 11px; font-weight: 600;
  font-family: 'Courier New', Courier, monospace;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--ink3); border-bottom: 1px solid var(--border);
  background: var(--bg);
}
thead th:first-child { border-radius: 8px 0 0 0; }
thead th:last-child { border-radius: 0 8px 0 0; }
tbody tr { border-bottom: 1px solid var(--border2); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
tbody td { padding: 14px 16px; font-size: 14px; vertical-align: middle; }

/* ── FORMS ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.form-sub-label { font-size: 11px; color: var(--ink3); font-family: 'Courier New', Courier, monospace; margin-top: 4px; }
.form-input {
  width: 100%; padding: 10px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--white);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; font-size: 14px; color: var(--ink);
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(45,91,227,0.08); }
.form-input::placeholder { color: var(--ink3); }
.form-textarea { resize: vertical; min-height: 90px; }
.form-row { display: grid; gap: 16px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── STAT CARDS ── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px 22px;
}
.stat-card-label { font-size: 12px; color: var(--ink3); font-family: 'Courier New', Courier, monospace; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.stat-card-val { font-family: Arial, sans-serif; font-size: 30px; font-weight: 800; letter-spacing: -1px; margin-bottom: 6px; }
.stat-card-delta { font-size: 12px; display: flex; align-items: center; gap: 4px; }
.delta-up { color: var(--green); }
.delta-down { color: var(--red); }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 64px 24px; }
.empty-icon { font-size: 40px; margin-bottom: 16px; opacity: 0.4; }
.empty-title { font-family: Arial, sans-serif; font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.empty-sub { font-size: 14px; color: var(--ink2); max-width: 340px; margin: 0 auto 24px; line-height: 1.6; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(26,25,22,0.5);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white); border-radius: 16px;
  border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  width: 90%; max-width: 560px; max-height: 90vh;
  overflow-y: auto;
  transform: translateY(16px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { padding: 24px 28px 0; display: flex; justify-content: space-between; align-items: flex-start; }
.modal-title { font-family: Arial, sans-serif; font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink3); line-height: 1; padding: 0; }
.modal-body { padding: 20px 28px 28px; }
.modal-footer { padding: 0 28px 24px; display: flex; gap: 10px; justify-content: flex-end; }

/* ── TOAST ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: var(--bg);
  border-radius: 10px; padding: 14px 20px;
  font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s ease;
  max-width: 360px;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.warning { background: var(--amber); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ── UTILITY ── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; font-family: 'Courier New', Courier, monospace; }
.text-muted { color: var(--ink2); }
.text-mono { font-family: 'Courier New', Courier, monospace; }
.font-bold { font-weight: 700; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-title { font-family: Arial, sans-serif; font-size: 18px; font-weight: 800; letter-spacing: -0.5px; }
.divider { height: 1px; background: var(--border); margin: 24px 0; }

/* ── LOADING SKELETON ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg2) 25%, var(--border2) 50%, var(--bg2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
  .topbar-search { display: none; }
}
@media (max-width: 640px) {
  .stat-grid { grid-template-columns: 1fr; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
}