/* ═══════════════════════════════════════════════════════════
   CVGénio v2 — Main Stylesheet
   Theme: Editorial · Noir & Or · DM Serif Display
   ═══════════════════════════════════════════════════════════ */

:root {
  --ink:        #0E0E12;
  --ink-mid:    #1C1C24;
  --ink-light:  #2A2A36;
  --surface:    #16161E;
  --bg:         #0E0E12;
  --bg-surface: #1C1C24;
  --bg-input:   #1C1C24;

  --border:     rgba(255,255,255,0.08);
  --border-md:  rgba(255,255,255,0.14);

  --gold:       #C9A84C;
  --gold-light: #E8C97A;
  --gold-dim:   rgba(201,168,76,0.15);
  --gold-glow:  rgba(201,168,76,0.06);
  --accent-gold:#C9A84C;

  --text:       #E8E6E0;
  --text-main:  #E8E6E0;
  --text-muted: #888690;
  --text-hint:  #4A4858;

  --success:    #4CAF82;
  --danger:     #E05C5C;
  --warning:    #E8A838;
  --info:       #5B9BD5;

  --radius:     8px;
  --radius-sm:  5px;
  --radius-lg:  12px;

  --sidebar-w:  240px;
  --font-serif: 'DM Serif Display', Georgia, serif;
  --font-sans:  'DM Sans', system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', monospace;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--ink);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
}

/* ═══════ LOADER ═══════ */
#loaderScreen {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--ink);
  display: flex; align-items: center; justify-content: center;
}
.loader-box { text-align: center; max-width: 420px; padding: 2rem; }
.loader-gem {
  font-size: 56px; color: var(--gold);
  animation: gem-spin 3s linear infinite;
  display: block; margin-bottom: 1.5rem;
}
@keyframes gem-spin {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(180deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(1); }
}
.loader-box h1 { font-family: var(--font-serif); font-size: 32px; margin-bottom: 8px; }
.loader-box h1 span { color: var(--gold); }
.loader-sub { font-size: 14px; color: var(--text-muted); line-height: 1.6; margin-bottom: 2rem; }
.loader-bar-wrap { height: 3px; background: var(--ink-light); border-radius: 99px; overflow: hidden; margin-bottom: 12px; }
.loader-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--gold), var(--gold-light)); border-radius: 99px; transition: width 0.4s ease; }
.loader-status { font-size: 13px; color: var(--gold); font-family: var(--font-mono); margin-bottom: 8px; }
.loader-hint { font-size: 12px; color: var(--text-hint); }

/* ═══════ AUTH SCREEN ═══════ */
#authScreen {
  position: fixed; inset: 0; z-index: 10000;
  background: var(--ink);
  display: flex; align-items: center; justify-content: center;
}
.auth-box {
  width: 100%; max-width: 380px; padding: 2.5rem;
  background: var(--ink-mid); border: 1px solid var(--border);
  border-radius: var(--radius-lg); text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.auth-box h1 { font-family: var(--font-serif); font-size: 28px; margin-bottom: 8px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; margin-top: 1.5rem; }
.auth-links { margin-top: 15px; display: flex; flex-direction: column; gap: 8px; }
.auth-links a { font-size: 13px; color: var(--text-muted); text-decoration: none; transition: color 0.15s; cursor: pointer; }
.auth-links a:hover { color: var(--gold); }

/* ═══════ LAYOUT ═══════ */
#appShell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w); background: var(--ink-mid);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh; z-index: 100;
  transition: transform 0.3s ease;
}
.sidebar-brand {
  font-family: var(--font-serif); font-size: 20px; color: var(--gold);
  padding: 1.5rem 1.25rem 1rem; border-bottom: 1px solid var(--border);
  letter-spacing: 0.5px;
}
.sidebar-nav { flex: 1; padding: 1rem 0; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 1.25rem; background: none; border: none;
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  color: var(--text-muted); cursor: pointer; text-align: left; width: 100%;
  transition: all 0.15s; border-left: 2px solid transparent;
}
.nav-item:hover { color: var(--text); background: var(--gold-glow); }
.nav-item.active { color: var(--gold); background: var(--gold-dim); border-left-color: var(--gold); }
.nav-icon { font-family: var(--font-mono); font-size: 11px; color: var(--text-hint); width: 20px; flex-shrink: 0; }
.nav-item.active .nav-icon { color: var(--gold-light); }

.sidebar-footer { padding: 1.25rem; border-top: 1px solid var(--border); background: rgba(0,0,0,0.1); }
.user-card { display: flex; align-items: center; gap: 12px; margin-bottom: 1.25rem; padding: 10px; background: var(--ink-light); border-radius: var(--radius); border: 1px solid var(--border); }
.user-card__icon { width: 32px; height: 32px; background: var(--gold-dim); color: var(--gold); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.user-card__info { display: flex; flex-direction: column; overflow: hidden; }
.user-card__email { font-size: 12px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card__logout { font-size: 11px; color: var(--danger); text-decoration: none; opacity: 0.8; transition: opacity 0.2s; }
.user-card__logout:hover { opacity: 1; text-decoration: underline; }

.local-mode-box { margin-bottom: 1rem; padding: 10px; background: rgba(201,168,76,0.05); border: 1px dashed rgba(201,168,76,0.2); border-radius: var(--radius); }
.switch-label { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.switch-text { font-size: 11px; font-weight: 600; color: var(--gold); text-transform: uppercase; letter-spacing: 0.5px; }
.switch { position: relative; display: inline-block; width: 34px; height: 18px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background-color: var(--ink-light); transition: .4s; border-radius: 34px; border: 1px solid var(--border); }
.slider:before { position: absolute; content: ""; height: 12px; width: 12px; left: 2px; bottom: 2px; background-color: var(--text-muted); transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--gold-dim); border-color: var(--gold); }
input:checked + .slider:before { transform: translateX(16px); background-color: var(--gold); }

.progress-bar-sm { height: 3px; background: var(--ink-light); border-radius: 99px; overflow: hidden; }
.progress-bar-sm__fill { height: 100%; width: 0%; background: var(--gold); transition: width 0.3s; }

.model-badge { display: flex; align-items: center; gap: 8px; font-size: 11px; font-family: var(--font-mono); color: var(--text-muted); margin-bottom: 10px; }
.badge-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-hint); transition: all 0.3s; }
.status-ok .badge-dot { background: var(--success); box-shadow: 0 0 8px var(--success); animation: pulse 2s ease-in-out infinite; }
.status-warn .badge-dot { background: var(--warning); box-shadow: 0 0 8px var(--warning); }
.status-err .badge-dot { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.status-ok #modelBadgeText { color: var(--gold); }
.status-warn #modelBadgeText, .status-err #modelBadgeText { color: var(--text-muted); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.sidebar-note { font-size: 10px; color: var(--text-hint); line-height: 1.5; font-style: italic; }

/* Hamburger (mobile) */
.hamburger {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 200;
  background: var(--ink-mid); border: 1px solid var(--border-md);
  border-radius: var(--radius-sm); padding: 8px 10px;
  cursor: pointer; color: var(--gold); font-size: 20px;
  transition: all 0.2s;
}
.hamburger:hover { background: var(--gold-dim); }
.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 99;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(2px);
}

/* Main */
.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 2.5rem 2.5rem 4rem; max-width: 860px; }

/* ═══════ TAB PANELS ═══════ */
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeUp 0.25s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.panel-header { margin-bottom: 2rem; }
.panel-header h2 { font-family: var(--font-serif); font-size: 28px; margin-bottom: 6px; }
.panel-header p { font-size: 14px; color: var(--text-muted); }

/* ═══════ FORMS ═══════ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-block { display: flex; flex-direction: column; gap: 5px; }
label { font-size: 11px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text-hint); }
.req { color: var(--gold); }

input[type="text"], input[type="email"], input[type="password"], input[type="tel"], textarea, select {
  background: var(--bg-input); border: 1px solid var(--border-md); border-radius: var(--radius-sm);
  padding: 9px 12px; font-family: var(--font-sans); font-size: 14px; color: var(--text);
  width: 100%; transition: border-color 0.15s, box-shadow 0.15s; appearance: none;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-dim); }
textarea { resize: vertical; min-height: 72px; line-height: 1.6; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888690' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}
.password-toggle { transition: all 0.2s; user-select: none; cursor: pointer; }
.password-toggle:hover { color: var(--gold) !important; }

.section-block { margin-top: 1.75rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.section-block h3 { font-size: 13px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase; color: var(--gold); margin-bottom: 1rem; }
.inline-form { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 8px; }

/* ═══════ BUTTONS ═══════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 20px; border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-size: 14px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border-md);
  background: transparent; color: var(--text-muted);
  transition: all 0.15s; white-space: nowrap;
}
.btn:hover { color: var(--text); border-color: var(--border-md); background: var(--ink-light); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn--primary, .btn-primary { background: var(--gold); color: var(--ink); border-color: var(--gold); font-weight: 600; }
.btn--primary:hover, .btn-primary:hover { background: var(--gold-light); border-color: var(--gold-light); }
.btn--success, .btn-success { background: var(--success); color: var(--ink); border-color: var(--success); font-weight: 600; }
.btn--success:hover, .btn-success:hover { filter: brightness(1.1); }
.btn--danger, .btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); font-weight: 600; }
.btn--danger:hover, .btn-danger:hover { filter: brightness(1.1); }
.btn--info, .btn-info { background: var(--info); color: #fff; border-color: var(--info); font-weight: 600; }
.btn--info:hover, .btn-info:hover { filter: brightness(1.1); }
.btn--outline, .btn-outline { border-color: var(--border-md); color: var(--text-muted); }
.btn--outline:hover, .btn-outline:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-dim); }
.btn-ghost { background: none; border: 1px dashed var(--border-md); color: var(--text-muted); font-size: 13px; }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-dim); }
.btn-xl { padding: 13px 32px; font-size: 15px; border-radius: var(--radius); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-row { display: flex; gap: 10px; margin-top: 2rem; flex-wrap: wrap; }

/* ═══════ UPLOAD ZONE ═══════ */
.upload-zone {
  border: 1.5px dashed var(--border-md); border-radius: var(--radius-lg);
  padding: 2.5rem; text-align: center; cursor: pointer;
  transition: all 0.2s; margin-bottom: 1.25rem; background: var(--ink-mid);
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--gold); background: var(--gold-dim); }
.upload-glyph { font-size: 28px; color: var(--gold); margin-bottom: 10px; }
.upload-zone p { font-size: 14px; color: var(--text-muted); }
.upload-zone strong { color: var(--text); }
.hint { font-size: 12px; color: var(--text-hint); margin-top: 4px; }

/* ═══════ CHIP LIST ═══════ */
.chip-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.chip-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--ink-mid); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px;
}
.chip-item span { color: var(--text); }
.chip-meta { display: flex; align-items: center; gap: 8px; }
.chip-badge {
  font-size: 11px; font-family: var(--font-mono);
  padding: 2px 8px; border-radius: 99px;
  background: var(--gold-dim); color: var(--gold); border: 1px solid rgba(201,168,76,0.2);
}

/* ═══════ SECTION ENTRIES ═══════ */
.section-entry {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 8px; padding: 10px 14px; margin-bottom: 6px;
  background: var(--ink-mid); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.section-entry .content { flex: 1; font-size: 13px; line-height: 1.6; }
.section-entry .content strong { color: var(--text); }
.section-entry .content .sub { color: var(--text-hint); font-size: 12px; }

/* ═══════ TEMPLATES ═══════ */
.template-row { display: flex; gap: 12px; flex-wrap: wrap; }
.tmpl-card {
  flex: 1; min-width: 140px; max-width: 200px;
  border: 1.5px solid var(--border-md); border-radius: var(--radius-lg);
  padding: 12px; cursor: pointer; text-align: center;
  transition: all 0.2s; background: var(--ink-mid);
}
.tmpl-card:hover { border-color: var(--gold); }
.tmpl-card.selected { border-color: var(--gold); background: var(--gold-dim); }
.tmpl-card span { font-size: 13px; font-weight: 500; color: var(--text-muted); margin-top: 8px; display: block; }
.tmpl-card.selected span { color: var(--gold); }

.tmpl-preview { width: 100%; aspect-ratio: 0.72; border-radius: 5px; overflow: hidden; margin-bottom: 6px; position: relative; }
.tp-classique { background: #F5F5F5; display: flex; flex-direction: column; }
.tp-classique .tp-header { height: 22%; background: #1A1A1A; }
.tp-classique .tp-lines { padding: 10px 8px; display: flex; flex-direction: column; gap: 5px; }
.tp-classique .tp-lines div { height: 4px; background: #DCDCDC; border-radius: 2px; }
.tp-classique .tp-lines .short { width: 60%; }
.tp-moderne { background: #F0F0F7; display: flex; flex-direction: row; }
.tp-moderne .tp-sidebar { width: 32%; background: var(--gold); }
.tp-moderne .tp-body { flex: 1; padding: 8px 6px; display: flex; flex-direction: column; gap: 5px; }
.tp-moderne .tp-body div { height: 4px; background: #D0CDE8; border-radius: 2px; }
.tp-moderne .tp-body .short { width: 60%; }
.tp-executive { background: #FAFAF7; display: flex; flex-direction: column; }
.tp-executive .tp-top-bar { height: 8px; background: #0E0E12; }
.tp-executive .tp-lines { padding: 10px 8px; display: flex; flex-direction: column; gap: 5px; }
.tp-executive .tp-lines div { height: 4px; background: #E0DDD5; border-radius: 2px; }
.tp-executive .tp-lines .short { width: 60%; }
.tp-creatif { background: #FFF6F5; display: flex; flex-direction: column; }
.tp-creatif .tp-accent { height: 35%; background: #E85D50; border-bottom-right-radius: 20px; }
.tp-creatif .tp-lines { padding: 10px 8px; display: flex; flex-direction: column; gap: 5px; }
.tp-creatif .tp-lines div { height: 4px; background: #E8CAC8; border-radius: 2px; }
.tp-creatif .tp-lines .short { width: 50%; }
.tp-minimaliste { background: #FFFFFF; display: flex; flex-direction: column; padding: 15px 10px; gap: 6px; }
.tp-minimaliste .tp-lines { display: flex; flex-direction: column; gap: 5px; margin: auto 0; }
.tp-minimaliste .tp-lines div { height: 3px; background: #E0E0E0; border-radius: 1px; }
.tp-minimaliste .tp-lines .short { width: 40%; }

.tp-ats { background: #FFFFFF; display: flex; flex-direction: column; padding: 15px 10px; gap: 4px; }
.tp-ats .tp-lines { display: flex; flex-direction: column; gap: 4px; margin: auto 0; }
.tp-ats .tp-lines div { height: 3px; background: #1A1A1A; border-radius: 0; }
.tp-ats .tp-lines .short { width: 50%; }

/* ═══════ GENERATION ═══════ */
.gen-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.stream-box { margin-top: 1.5rem; background: var(--ink-mid); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.stream-header { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--ink-light); border-bottom: 1px solid var(--border); font-size: 13px; font-family: var(--font-mono); color: var(--gold); }
.stream-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); animation: pulse 1s ease-in-out infinite; }
.stream-text { padding: 1rem 1.25rem; font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); white-space: pre-wrap; max-height: 280px; overflow-y: auto; line-height: 1.7; }

.feedback { font-size: 13px; margin-top: 10px; min-height: 18px; }
.feedback--ok { color: var(--success); }
.feedback--err { color: var(--danger); }

.preview-header { display: flex; justify-content: space-between; align-items: center; margin: 1.5rem 0 0.75rem; }
.preview-header h3 { font-family: var(--font-serif); font-size: 20px; }
.cv-preview-wrap { background: white; border-radius: var(--radius); overflow: auto; min-height: 500px; border: 1px solid var(--border); }
#cvPreview { padding: 40px; font-family: Georgia, serif; color: #1A1A1A; }
.raw-wrap { margin-top: 1rem; }
.raw-code { background: var(--ink-mid); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); white-space: pre-wrap; max-height: 300px; overflow-y: auto; }
code { background: var(--ink-light); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; font-family: var(--font-mono); font-size: 12px; color: var(--gold); }

/* ═══════ TEMPLATE CARDS (trained models) ═══════ */
.template-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-top: 16px; }
.template-card {
  background: var(--ink-mid); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; cursor: pointer; transition: all 0.2s; position: relative;
}
.template-card:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
.template-card.selected { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-dim); }
.template-card__thumb { width: 100%; aspect-ratio: 0.72; object-fit: cover; background: var(--ink-light); display: block; }
.template-card__info { padding: 10px 12px; }
.template-card__name { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.template-card__tags { font-size: 11px; color: var(--text-muted); }
.template-card__actions { display: flex; gap: 6px; margin-top: 8px; }
.template-card__check {
  position: absolute; top: 8px; right: 8px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--gold); color: var(--ink); display: none;
  align-items: center; justify-content: center; font-size: 14px; font-weight: bold;
}
.template-card.selected .template-card__check { display: flex; }

/* Progress bar for upload */
.progress-bar { height: 4px; background: var(--ink-light); border-radius: 2px; overflow: hidden; margin-top: 10px; }
.progress-bar__fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-light)); border-radius: 2px; transition: width 0.3s ease; width: 0%; }
.progress-text { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ═══════ KPI CARDS ═══════ */
.kpi-card {
  background: var(--bg-surface); padding: 1.5rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  text-align: center;
}
.kpi-card h3 { margin: 0; color: var(--text-muted); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; }
.kpi-card .kpi-value { font-family: var(--font-serif); font-size: 3rem; color: var(--gold); margin: 0.5rem 0 0; }

/* ═══════ RESPONSIVE ═══════ */
@media (max-width: 720px) {
  .hamburger { display: block; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.visible { display: block; }
  .main-content { margin-left: 0; padding: 3.5rem 1rem 3rem; }
  .form-grid, .inline-form { grid-template-columns: 1fr; }
  .template-row { justify-content: center; }
  .template-cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
