/* Facturus — Main Styles */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --accent: #f59e0b;
  --text: #1e293b;
  --text-light: #64748b;
  --bg: #f8fafc;
  --white: #ffffff;
  --border: #e2e8f0;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.05);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text); background: var(--bg); line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Skip link */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 10000;
  background: var(--primary); color: var(--white);
  padding: .75rem 1rem; border-radius: 0 0 8px 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

/* Typography */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.2; }
h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }
p { margin-bottom: 1rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.muted { color: var(--text-light); }
.empty { text-align: center; padding: 1.5rem; color: var(--text-light); }

/* Header */
.header {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 1rem 0; position: sticky; top: 0; z-index: 100;
}
.header .container { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.logo { font-size: 1.5rem; font-weight: 800; color: var(--primary); }
.logo strong { color: var(--primary); font-weight: 800; }
.logo span { color: var(--accent); }
.nav { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.nav a { color: var(--text-light); font-size: .9rem; font-weight: 500; }
.nav a:hover { color: var(--primary); text-decoration: none; }
.file-status { font-size: .8rem; color: var(--text-light); padding-left: 1rem; border-left: 1px solid var(--border); }
.file-status:empty { display: none; }

/* Hero */
.hero { text-align: center; padding: 3rem 0 2rem; }
.hero h1 { margin-bottom: .75rem; }
.hero p { color: var(--text-light); font-size: 1.15rem; max-width: 640px; margin: 0 auto 1.5rem; }
.badge-row { display: flex; justify-content: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--primary-light); color: var(--primary-dark);
  padding: .35rem .75rem; border-radius: 20px; font-size: .8rem; font-weight: 600;
}
.cta-row { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-top: 1rem; }

/* Page header (entre h1 et bouton action) */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin: 2rem 0 1.5rem; gap: 1rem; flex-wrap: wrap;
}
.page-header h1 { font-size: 1.75rem; margin: 0; }

/* Card */
.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; color: var(--text-light); }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: .6rem .75rem; border: 1px solid var(--border);
  border-radius: 8px; font-size: .9rem; font-family: inherit;
  transition: border-color .2s; background: var(--white); color: var(--text);
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-group textarea { resize: vertical; min-height: 60px; }
.form-group small { display: block; margin-top: .35rem; color: var(--text-light); }

.form-grid-1 { display: grid; gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.form-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .7rem 1.25rem; border: none; border-radius: 8px;
  font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: all .2s; font-family: inherit;
}
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); text-decoration: none; }
.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #15803d; text-decoration: none; }
.btn-lg { padding: 1rem 2rem; font-size: 1.1rem; }
.btn-link {
  background: none; border: none; color: var(--primary); cursor: pointer;
  font-size: .85rem; padding: .25rem .5rem; font-family: inherit; font-weight: 500;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--danger); }

/* Data table (factures, clients, lignes) */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th {
  background: var(--bg); font-size: .75rem; color: var(--text-light);
  text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
}
.data-table .num { text-align: right; }
.data-table .actions { text-align: right; white-space: nowrap; }
.data-table input {
  width: 100%; padding: .4rem .5rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: .9rem; font-family: inherit;
}
.data-table input:focus { outline: none; border-color: var(--primary); }

/* Totals */
.totals-row { display: flex; justify-content: flex-end; margin-top: 1rem; }
.totals-box { min-width: 280px; }
.totals-line { display: flex; justify-content: space-between; padding: .4rem 0; font-size: .95rem; }
.totals-line.total-final {
  border-top: 2px solid var(--text); font-size: 1.15rem; font-weight: 700;
  margin-top: .5rem; padding-top: .75rem;
}

/* Info section (home) */
.info-section {
  background: var(--primary-light); border-radius: var(--radius);
  padding: 2rem; margin: 3rem auto;
  max-width: 1100px;
}
.info-section h2 { margin-bottom: 1rem; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; }
.info-card h3 { margin-bottom: .35rem; font-size: 1.05rem; }
.info-card p { color: var(--text); font-size: .9rem; margin: 0; }

/* Footer */
.footer {
  background: var(--white); border-top: 1px solid var(--border);
  padding: 2rem 0; margin-top: 3rem; text-align: center;
  color: var(--text-light); font-size: .85rem;
}
.footer-links { display: flex; justify-content: center; gap: 1.5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.footer-links a { color: var(--text-light); }

/* Page content (a-propos, guide, mentions) */
.page-content { max-width: 800px; margin: 2rem auto; padding: 0 1.5rem; }
.page-content h1 { margin-bottom: 1.5rem; }
.page-content h2 { margin-top: 2rem; margin-bottom: .75rem; }
.page-content ul, .page-content ol { margin-left: 1.5rem; margin-bottom: 1rem; }
.page-content li { margin-bottom: .5rem; }

/* Toast */
.toast {
  position: fixed; bottom: 2rem; right: 2rem;
  background: var(--text); color: var(--white);
  padding: .75rem 1.25rem; border-radius: 8px;
  font-weight: 600; box-shadow: var(--shadow-lg);
  transform: translateY(100px); opacity: 0;
  transition: all .3s ease; z-index: 1000;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.toast-success { background: var(--success); }
.toast.toast-error { background: var(--danger); }
.toast.toast-info { background: var(--text); }

/* Modal */
.modal-host {
  position: fixed; inset: 0; display: none;
  align-items: center; justify-content: center;
  z-index: 2000; padding: 1rem;
}
.modal-host.open { display: flex; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(15, 23, 42, .5);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative; background: var(--white); border-radius: var(--radius);
  padding: 2rem; max-width: 520px; width: 100%;
  box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto;
}
.modal-card h2 { margin-bottom: .75rem; font-size: 1.4rem; }
.modal-card p { color: var(--text-light); margin-bottom: 1rem; }
.modal-actions { display: flex; gap: .75rem; margin-top: 1.5rem; flex-wrap: wrap; }
.modal-note {
  margin-top: 1rem; padding: .75rem; background: var(--bg);
  border-radius: 8px; font-size: .8rem; color: var(--text-light);
}

/* Responsive */
@media (max-width: 768px) {
  h1 { font-size: 1.75rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .header .container { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .nav { gap: .75rem; font-size: .85rem; }
  .file-status { padding-left: 0; border-left: none; }
  .data-table { font-size: .85rem; }
  .data-table th, .data-table td { padding: .4rem .5rem; }
  .totals-box { min-width: 200px; width: 100%; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
