:root {
    --primary: #1e3a5f;
    --primary-light: #2d5a8f;
    --secondary: #e8963f;
    --bg: #f4f6f9;
    --card-bg: #ffffff;
    --text: #202632;
    --muted: #6b7684;
    --border: #e1e5eb;
    --success: #2e9e5b;
    --warning: #d99b23;
    --danger: #d24545;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { text-decoration: none; color: inherit; }
h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.page-subtitle { color: var(--muted); margin-bottom: 1.5rem; }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.15); padding-top: 0.75rem; font-size: 0.85rem; }
.user-chip { color: #cfd9e8; margin-bottom: 0.5rem; }
.logout-link { color: var(--secondary); }

.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card { background: var(--card-bg); padding: 2.5rem; border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,0.08); width: 100%; max-width: 380px; }
.auth-card h1 { text-align: center; }
.auth-card .subtitle { text-align: center; color: var(--muted); margin-bottom: 1.5rem; }
.auth-card label { display: block; font-size: 0.85rem; margin: 0.75rem 0 0.3rem; color: var(--muted); }
.auth-card input { width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-radius: 8px; font-size: 0.95rem; }
.auth-switch { text-align: center; margin-top: 1.25rem; font-size: 0.9rem; color: var(--muted); }
.auth-switch a { color: var(--primary-light); font-weight: 600; }

.btn { display: inline-block; padding: 0.55rem 1rem; border-radius: 8px; border: none; font-size: 0.9rem; cursor: pointer; font-weight: 600; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-small { padding: 0.35rem 0.7rem; font-size: 0.82rem; }
.btn-block { display: block; width: 100%; text-align: center; margin-top: 0.75rem; }
.btn-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.alert { padding: 0.6rem 0.8rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.88rem; }
.alert-error { background: #fdeaea; color: var(--danger); }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--card-bg); padding: 1.25rem; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.04); }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }
.quick-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.capture-actions { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.capture-btn { cursor: pointer; }
.input-inline { padding: 0.5rem 0.7rem; border-radius: 8px; border: 1px solid var(--border); }
.upload-progress { margin-bottom: 1rem; color: var(--primary-light); font-weight: 600; }

.status-filters { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.chip { padding: 0.35rem 0.85rem; border-radius: 20px; background: #fff; border: 1px solid var(--border); font-size: 0.85rem; color: var(--muted); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.photo-card { background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.photo-card img { width: 100%; height: 140px; object-fit: cover; display: block; }
.photo-placeholder { height: 140px; display: flex; align-items: center; justify-content: center; background: #eef1f5; color: var(--muted); font-size: 0.8rem; }
.photo-card-body { padding: 0.6rem; display: flex; justify-content: space-between; align-items: center; gap: 0.4rem; }

.badge { padding: 0.2rem 0.55rem; border-radius: 12px; font-size: 0.72rem; text-transform: capitalize; background: #eef1f5; color: var(--muted); }
.badge-nouvelle { background: #e6f0ff; color: #2159b5; }
.badge-en_retouche { background: #fff3e0; color: var(--warning); }
.badge-prete_impression, .badge-en_conception { background: #f1e9ff; color: #6a3fc2; }
.badge-imprimee { background: #e3f7ea; color: var(--success); }
.badge-livree { background: #e3f7ea; color: var(--success); }

.empty-state { color: var(--muted); padding: 1.5rem; text-align: center; }

.editor-canvas-area { background: #111; border-radius: 12px; padding: 1rem; display: flex; align-items: center; justify-content: center; min-height: 420px; }
.editor-canvas-area img { max-width: 100%; max-height: 500px; }
#sheetResult { margin-top: 0.75rem; font-size: 0.85rem; }

.inline-form { display: flex; gap: 0.6rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.inline-form input, .inline-form select { padding: 0.5rem 0.7rem; border-radius: 8px; border: 1px solid var(--border); }

.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; }
.data-table th, .data-table td { padding: 0.7rem 0.9rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.data-table th { background: #f8f9fb; color: var(--muted); font-weight: 600; }

.print-canvas-wrapper { background: #e9ecf1; border-radius: 12px; padding: 1.5rem; display: flex; align-items: flex-start; justify-content: center; overflow: auto; }

/* ===================== Refonte layout V2 (chantier A) ===================== */

.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

/* --- Barre supérieure globale --- */
.topbar {
    display: flex; align-items: center; gap: 1rem;
    background: #16283f; color: #fff; padding: 0.5rem 1rem;
    position: sticky; top: 0; z-index: 50; height: 52px;
}
.topbar-brand { font-weight: 700; white-space: nowrap; margin-right: 0.5rem; }
.topbar-actions { display: flex; gap: 0.3rem; flex-wrap: nowrap; overflow-x: auto; }
.tb-btn {
    background: rgba(255,255,255,0.08); color: #dbe4f0; border: none; border-radius: 6px;
    padding: 0.4rem 0.7rem; font-size: 0.82rem; cursor: pointer; white-space: nowrap;
}
.tb-btn:hover { background: rgba(255,255,255,0.18); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; position: relative; }
.topbar-search input {
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15); border-radius: 8px;
    padding: 0.4rem 0.7rem; color: #fff; font-size: 0.82rem; width: 220px;
}
.topbar-search input::placeholder { color: #a9b7cc; }
.tb-icon { position: relative; background: none; border: none; color: #dbe4f0; font-size: 1.1rem; cursor: pointer; }
.notif-dot { position: absolute; top: -2px; right: -2px; width: 8px; height: 8px; background: #e24a4a; border-radius: 50%; }
.notif-panel {
    display: none; position: absolute; top: 40px; right: 0; width: 300px; background: #fff; color: var(--text);
    border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,0.18); overflow: hidden; z-index: 60;
}
.notif-panel.open { display: block; }
.notif-item { padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.notif-item:last-child { border-bottom: none; }
.notif-item strong { display: block; margin-bottom: 0.15rem; }
.notif-empty { padding: 1rem; text-align: center; color: var(--muted); font-size: 0.85rem; }

/* --- Corps (sidebar / contenu / panneau droit) --- */
.app-body { display: flex; flex: 1; min-height: calc(100vh - 52px); }

.sidebar {
    width: 240px; background: var(--primary); color: #fff; display: flex; flex-direction: column;
    padding: 1rem 0.85rem; position: sticky; top: 52px; height: calc(100vh - 52px); overflow-y: auto;
    flex-shrink: 0;
}
.sidebar nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.nav-item { padding: 0.55rem 0.7rem; border-radius: 8px; color: #cfd9e8; font-size: 0.9rem; font-weight: 600; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,0.12); color: #fff; }
.nav-group { margin-top: 0.6rem; }
.nav-group-title { padding: 0.5rem 0.7rem 0.2rem; font-size: 0.85rem; font-weight: 700; color: #fff; }
.nav-sub { display: block; padding: 0.4rem 0.7rem 0.4rem 1.4rem; border-radius: 6px; color: #b7c4d9; font-size: 0.82rem; }
.nav-sub:hover, .nav-sub.active { background: rgba(255,255,255,0.1); color: #fff; }

.content { flex: 1; padding: 1.5rem 1.75rem; max-width: none; min-width: 0; }
.content-full { flex: 1; }

.right-panel {
    width: 280px; background: #fff; border-left: 1px solid var(--border); padding: 1.25rem 1rem;
    position: sticky; top: 52px; height: calc(100vh - 52px); overflow-y: auto; flex-shrink: 0;
}
.right-panel h3 { font-size: 0.9rem; margin: 0 0 0.6rem; color: var(--primary); }
.right-panel-empty { color: var(--muted); font-size: 0.85rem; text-align: center; margin-top: 2rem; }
.rp-section { margin-bottom: 1.25rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.rp-section:last-child { border-bottom: none; }
.rp-section label { display: block; font-size: 0.78rem; color: var(--muted); margin-top: 0.5rem; }
.rp-section input, .rp-section select { width: 100%; padding: 0.4rem; border-radius: 6px; border: 1px solid var(--border); margin-top: 0.2rem; }
.rp-swatches { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.4rem; }
.rp-swatch { width: 22px; height: 22px; border-radius: 5px; cursor: pointer; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); }

/* --- Barre d'outils contextuelle au-dessus du contenu --- */
.page-toolbar {
    display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap;
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    padding: 0.5rem 0.6rem; margin-bottom: 1.1rem;
}
.pt-btn {
    background: #f4f6f9; border: 1px solid var(--border); border-radius: 7px; padding: 0.4rem 0.65rem;
    font-size: 0.82rem; cursor: pointer; color: var(--text); display: inline-flex; align-items: center; gap: 0.3rem;
}
.pt-btn:hover { background: #e9edf3; }
.pt-sep { width: 1px; height: 22px; background: var(--border); margin: 0 0.15rem; }

.settings-fab {
    display: none; position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 75;
    width: 52px; height: 52px; border-radius: 50%; border: none; background: var(--secondary);
    color: #fff; font-size: 1.3rem; box-shadow: 0 4px 16px rgba(0,0,0,0.3); cursor: pointer;
}

@media (max-width: 1100px) {
    .right-panel {
        position: fixed; top: 52px; right: 0; height: calc(100vh - 52px); width: 300px; max-width: 85vw;
        transform: translateX(100%); transition: transform 0.25s ease; z-index: 80;
        box-shadow: -2px 0 20px rgba(0,0,0,0.25);
    }
    .right-panel.mobile-open { transform: translateX(0); }
    .settings-fab { display: flex; align-items: center; justify-content: center; }
}
.hamburger-btn {
    display: none; background: none; border: none; color: #fff; font-size: 1.3rem; cursor: pointer;
    padding: 0.2rem 0.5rem; margin-right: 0.4rem;
}

.sidebar-overlay {
    display: none; position: fixed; top: 52px; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45); z-index: 70;
}
.sidebar-overlay.active { display: block; }

@media (max-width: 900px) {
    .hamburger-btn { display: inline-flex; align-items: center; }
    .topbar-search { display: none; }

    .sidebar {
        position: fixed; top: 52px; left: 0; height: calc(100vh - 52px); width: 260px;
        transform: translateX(-100%); transition: transform 0.25s ease; z-index: 80;
        flex-direction: column; box-shadow: 2px 0 20px rgba(0,0,0,0.25);
    }
    .sidebar.mobile-open { transform: translateX(0); }
    .sidebar nav { flex-direction: column; }
    .nav-group { display: block; }
    .sidebar-footer { display: flex; flex-direction: column; }

    .content { padding: 1.25rem 1rem; }
}

.editor-canvas-standalone { min-height: 520px; }
.pt-btn.btn-primary-toolbar { background: var(--primary); color: #fff; border-color: var(--primary); }

.layers-list { display: flex; flex-direction: column; gap: 0.25rem; max-height: 160px; overflow-y: auto; }
.layer-row { padding: 0.35rem 0.5rem; background: #f4f6f9; border-radius: 6px; font-size: 0.8rem; cursor: pointer; }
.layer-row:hover { background: #e9edf3; }

/* --- Galerie d'entrée Studio Print (chantier B) --- */
.create-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.85rem; margin-bottom: 1rem; }
.create-tile {
    background: #fff; border: 1.5px dashed var(--border); border-radius: 12px; padding: 1.3rem 0.8rem;
    display: flex; flex-direction: column; align-items: center; gap: 0.5rem; cursor: pointer;
    font-size: 0.85rem; font-weight: 600; color: var(--text); transition: all 0.15s;
}
.create-tile:hover { border-color: var(--primary-light); background: #f4f8ff; transform: translateY(-2px); }
.create-tile-icon { font-size: 1.8rem; }
.chip-active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* --- Assistant photo d'identité en 6 étapes (chantier B) --- */
.wizard-steps { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.wizard-step {
    padding: 0.45rem 0.9rem; border-radius: 20px; background: #eef1f5; color: var(--muted);
    font-size: 0.82rem; font-weight: 600;
}
.wizard-step.active { background: var(--primary); color: #fff; }

.wizard-panel { background: #fff; border-radius: 12px; padding: 1.75rem; }
.wizard-pane { display: none; }
.wizard-pane.active { display: block; }
.wizard-pane h3 { margin-top: 0; }

.format-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.75rem; }
.format-tile {
    background: #f4f6f9; border: 2px solid transparent; border-radius: 10px; padding: 1rem 0.5rem;
    font-size: 0.85rem; font-weight: 600; cursor: pointer; text-align: center; color: var(--text);
}
.format-tile small { color: var(--muted); font-weight: 400; }
.format-tile:hover { background: #e9edf3; }
.format-tile.selected { border-color: var(--primary); background: #eaf1fb; }
.copies-tile { font-size: 1.3rem; padding: 0.9rem 0.5rem; }

.bg-tiles { display: flex; gap: 0.85rem; flex-wrap: wrap; }
.bg-tile {
    width: 110px; height: 80px; border-radius: 10px; border: 2px solid var(--border); cursor: pointer;
    font-size: 0.82rem; font-weight: 600; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 0.4rem;
}
.bg-tile.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(30,58,95,0.25); }

.wizard-nav { display: flex; justify-content: space-between; margin-top: 1.5rem; }
.wizard-selection { color: var(--primary-light); font-weight: 600; margin-top: 0.75rem; }
.wizard-summary { list-style: none; padding: 0; margin: 0 0 1.25rem; }
.wizard-summary li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
