/* ═══════════════════════════════════════════════════════════════════════════
   main.css — Culture et Cinéma — Outil de gestion
   Thème : Cinématographique / sombre / or
   Typographies : Cormorant Garamond (titres) + Jost (corps)
   ═══════════════════════════════════════════════════════════════════════════ */

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

/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  /* Fond */
  --bg:            #08080f;
  --bg-surface:    #111120;
  --bg-elevated:   #1a1a2e;
  --bg-hover:      #20203a;

  /* Bordures */
  --border:        #26263d;
  --border-light:  #32324d;

  /* Or — couleur signature */
  --gold:          #c9a227;
  --gold-light:    #e4c060;
  --gold-dim:      #7a6115;
  --gold-bg:       rgba(201, 162, 39, 0.08);

  /* Texte */
  --text:          #ededf5;
  --text-secondary:#9090b0;
  --text-muted:    #54546e;

  /* États */
  --success:       #4caf82;
  --success-bg:    rgba(76, 175, 130, 0.1);
  --danger:        #e05555;
  --danger-bg:     rgba(224, 85, 85, 0.1);
  --warning:       #e09a45;
  --warning-bg:    rgba(224, 154, 69, 0.1);
  --info:          #4a90d9;
  --info-bg:       rgba(74, 144, 217, 0.1);

  /* Typographie */
  --font-display:  'Cormorant Garamond', Georgia, serif;
  --font-body:     'Jost', 'Segoe UI', sans-serif;
  --font-mono:     'Courier New', monospace;

  /* Layout */
  --sidebar-w:     240px;
  --topbar-h:      60px;
  --radius:        8px;
  --radius-sm:     4px;
  --radius-lg:     12px;

  /* Ombres */
  --shadow-sm:     0 1px 3px rgba(0,0,0,.4);
  --shadow:        0 4px 16px rgba(0,0,0,.5);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.6);
  --shadow-gold:   0 0 20px rgba(201,162,39,.15);
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; transition: color .2s; }
a:hover { color: var(--gold-light); }

img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: var(--font-body); }

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

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

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: .03em;
  line-height: 1.2;
}

.sidebar-logo-sub {
  font-size: .7rem;
  color: var(--text-muted);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 8px;
}

.sidebar-section-title {
  font-size: .65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .12em;
  padding: 8px 20px 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-secondary);
  font-size: .88rem;
  font-weight: 400;
  transition: all .15s;
  position: relative;
}

.sidebar-link:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.sidebar-link.active {
  color: var(--gold);
  background: var(--gold-bg);
  font-weight: 500;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--gold);
  border-radius: 0 2px 2px 0;
}

.sidebar-link .icon {
  width: 18px;
  text-align: center;
  font-size: .95rem;
  opacity: .8;
}

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

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

.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--gold-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 600;
  color: var(--gold-light);
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: .82rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-user-role {
  font-size: .7rem;
  color: var(--text-muted);
}

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

/* ── Top bar ──────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .88rem;
  color: var(--text-muted);
}

.topbar-breadcrumb .current {
  color: var(--text);
  font-weight: 500;
}

.topbar-breadcrumb .sep { opacity: .4; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Page content ─────────────────────────────────────────────────────────── */
.page {
  padding: 28px;
  flex: 1;
}

.page-header {
  margin-bottom: 28px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.1;
}

.page-subtitle {
  font-size: .9rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card-title {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-header .card-title { margin-bottom: 0; }

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

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .2s, box-shadow .2s;
}

.stat-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-sm);
}

.stat-card.gold {
  border-color: var(--gold-dim);
  background: linear-gradient(135deg, var(--bg-surface) 0%, rgba(201,162,39,.04) 100%);
}

.stat-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}

.stat-card.gold .stat-value { color: var(--gold); }

.stat-meta {
  font-size: .78rem;
  color: var(--text-muted);
}

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}

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

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

tbody td {
  padding: 11px 14px;
  color: var(--text);
  vertical-align: middle;
}

tbody td.muted { color: var(--text-secondary); }
tbody td.mono  { font-family: var(--font-mono); font-size: .82rem; }

.td-film strong {
  display: block;
  font-weight: 500;
  color: var(--text);
}

.td-film small {
  font-size: .78rem;
  color: var(--text-muted);
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-gold    { background: var(--gold-bg);    color: var(--gold);    border: 1px solid var(--gold-dim); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info    { background: var(--info-bg);    color: var(--info);    }
.badge-muted   { background: var(--bg-elevated); color: var(--text-muted); }

/* ── Boutons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .875rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--gold);
  color: #0a0a0f;
  border-color: var(--gold);
}
.btn-primary:hover {
  background: var(--gold-light);
  color: #0a0a0f;
  border-color: var(--gold-light);
  box-shadow: var(--shadow-gold);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border-light);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--gold-dim);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: white; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }

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

.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: .02em;
}

.form-label.required::after {
  content: ' *';
  color: var(--danger);
}

.form-control {
  width: 100%;
  padding: 9px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .9rem;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(201,162,39,.12);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2354546e' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-control[readonly],
.form-control[disabled] {
  opacity: .6;
  cursor: not-allowed;
}

.form-hint {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: .75rem;
  color: var(--danger);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

/* ── Alertes ──────────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 20px;
  border: 1px solid transparent;
}

.alert-success { background: var(--success-bg); color: var(--success); border-color: rgba(76,175,130,.2); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: rgba(224,85,85,.2); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: rgba(224,154,69,.2); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border-color: rgba(74,144,217,.2); }

/* ── Grille contenu ───────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; width: 100%; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 20px; width: 100%; }

/* ── Séparateur ───────────────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ── Texte utilitaires ────────────────────────────────────────────────────── */
.text-gold    { color: var(--gold); }
.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.font-display { font-family: var(--font-display); }

/* ── Page de login ────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(201,162,39,.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(74,144,217,.03) 0%, transparent 50%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--gold);
}

.login-logo-sub {
  font-size: .75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-top: 4px;
}

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 2rem; margin-bottom: 12px; opacity: .5; }
.empty-state p { font-size: .9rem; }

/* ── Responsive (tablette) ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 200px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .hamburger        { display: flex !important; }
  .app-layout       { overflow-x: hidden; }

  .sidebar {
    display: flex !important;
    left: -100vw !important;
    visibility: hidden;
    transition: left .25s ease, visibility .25s;
    width: 80vw;
    max-width: 300px;
    overflow-y: auto;
  }
  .sidebar.open {
    left: 0 !important;
    visibility: visible;
  }
  .sidebar-overlay.open { display: block; }

  .sidebar-logo-title   { font-size: 1.4rem; }
  .sidebar-logo-sub     { font-size: .8rem; }
  .sidebar-section-title{ font-size: .78rem; padding: 10px 20px 6px; }
  .sidebar-link         { font-size: 1rem; padding: 13px 20px; }
  .sidebar-link .icon   { font-size: 1.1rem; }

  .main-content {
    margin-left: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
  }

  .topbar { padding: 0 12px; }
  .page   { padding: 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr !important; }
}

/* ── Encarts d'aide API ───────────────────────────────────────────────────── */
.api-help {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--gold-dim);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
  font-size: .82rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.api-help p    { margin-bottom: 8px; }
.api-help ol   { padding-left: 20px; margin-bottom: 8px; }
.api-help li   { margin-bottom: 4px; }
.api-help a    { color: var(--gold); }
.api-help code {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: .78rem;
  font-family: var(--font-mono);
  color: var(--text);
}

.api-help-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 8px 0;
  font-size: .8rem;
}

/* ── Statistiques ─────────────────────────────────────────────────────────── */
.stat-donut-wrap    { display:flex; align-items:center; gap:20px; }
.stat-donut-canvas  { flex-shrink:0; width:100px !important; height:100px !important;
                      max-width:100px; max-height:100px; }
.stat-donut-info    { flex:1; min-width:0; }
.stat-donut-pct     { font-size:1.6rem; font-weight:700; color:var(--gold); }
.stat-donut-label   { font-size:.75rem; color:var(--text-muted); margin-bottom:10px; }
.stat-donut-rows    { display:flex; flex-direction:column; gap:5px; }
.stat-donut-row     { display:flex; justify-content:space-between; font-size:.78rem; gap:8px; }
.stat-donut-row span:first-child { white-space:nowrap; }
.stat-donut-row span:last-child  { color:var(--text-muted); text-align:right; }
.stat-donut-total   { border-top:1px solid var(--border); padding-top:5px;
                      display:flex; justify-content:space-between;
                      font-size:.8rem; font-weight:600; }

.stat-summary-grid  { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.stat-summary-cell  { background:var(--bg-elevated); border-radius:var(--radius);
                      padding:12px; text-align:center; }
.stat-summary-val   { font-size:1.4rem; font-weight:700; color:var(--gold); }
.stat-summary-lbl   { font-size:.72rem; color:var(--text-muted); margin-top:2px; }

.stat-row           { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-bottom:20px; }

.tarif-btn          { font-size:.72rem; padding:3px 8px; border-radius:4px; cursor:pointer; transition:all .15s; }
.tarif-btn.active   { color:#1a1a2e !important; }
.stat-row-3         { display:grid; grid-template-columns:1fr 1fr 1fr; gap:16px; margin-bottom:20px; }

/* ── Impression ───────────────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .btn, button, form,
  #tarif-toggles, #btn-ae-list, #btn-cdlc-liste, #btn-delais,
  #liste-ae, #liste-delais, #cdlc-liste { display: none !important; }

  .app-layout  { display: block !important; }
  .main-content { margin: 0 !important; padding: 0 !important; }
  .page        { padding: 12px !important; }

  .card {
    break-inside: avoid;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    margin-bottom: 12px !important;
    background: #fff !important;
    color: #000 !important;
  }

  .card-title, h1, h2, .page-title, .page-subtitle,
  td, th, .stat-summary-val, .stat-summary-lbl,
  .stat-donut-pct, .stat-donut-label { color: #000 !important; }

  .muted { color: #555 !important; }

  canvas { display: none !important; }
  canvas + .print-canvas-img { display: block !important; max-width: 100% !important; }
  .stat-donut-canvas + .print-canvas-img { width: 100px !important; max-width: 100px !important; height: 100px !important; }

  .grid-2, .grid-3 { gap: 8px !important; }

  @page { margin: 1cm; }
}

/* ── Hamburger & responsive ───────────────────────────────────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all .2s;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}
