:root {
    --bg-dark: #0d0d0f;
    --bg-card: #16161a;
    --border-gold: rgba(197, 168, 128, 0.25);
    --accent-gold: #c5a880;
    --accent-gold-hover: #dfbe92;
    --text-main: #f5f3ef;
    --text-muted: #9e9a93;
    --success: #10b981;
    --danger: #ef4444;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    padding: 20px;
}

.top-bar {
    max-width: 1440px;
    margin: 0 auto 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-gold);
}

.brand-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    letter-spacing: 0.08em;
    color: var(--accent-gold);
}

.format-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(197, 168, 128, 0.12);
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 0.82rem;
    font-weight: 600;
}

.login-card {
    max-width: 420px;
    margin: 80px auto;
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    border-radius: 12px;
    padding: 36px 30px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}

.workspace-grid {
    max-width: 1440px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 460px 1fr;
    gap: 28px;
    align-items: start;
}

@media (max-width: 1024px) {
    .workspace-grid { grid-template-columns: 1fr; }
}

.panel-card {
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    border-radius: 12px;
    padding: 24px;
}

.section-heading {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-gold);
    margin: 18px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px dashed rgba(255,255,255,0.1);
}

.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

input[type="text"], input[type="password"], select, input[type="file"] {
    width: 100%;
    padding: 11px 13px;
    background: #0b0b0d;
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 0.92rem;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent-gold);
}

.mode-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.mode-tab-btn {
    padding: 10px;
    background: #0b0b0d;
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.84rem;
}

.mode-tab-btn.active {
    background: rgba(197, 168, 128, 0.16);
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.btn-save {
    width: 100%;
    padding: 14px;
    background: var(--accent-gold);
    color: #0d0d0f;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    margin-top: 10px;
    transition: background 0.2s;
}

.btn-save:hover { background: var(--accent-gold-hover); }

.preview-sticky {
    position: sticky;
    top: 20px;
}

.preview-stage {
    background: #09090b;
    border: 1px dashed rgba(255,255,255,0.15);
    border-radius: 10px;
    min-height: 540px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    overflow: hidden;
}

/* Contrôles Avancés & Sliders Fluides */
.slider-row-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.slider-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.slider-label-row label {
    margin-bottom: 0;
}

.slider-val-pill {
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--accent-gold);
    background: rgba(197, 168, 128, 0.14);
    border: 1px solid rgba(197, 168, 128, 0.35);
    padding: 2px 8px;
    border-radius: 99px;
}

.gold-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.14);
    border-radius: 99px;
    outline: none;
    cursor: pointer;
}

.gold-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-gold);
    border: 2px solid #0d0d0f;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

.sub-control-box, .logo-upload-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(197, 168, 128, 0.22);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 14px;
}

.color-pickers-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.color-pickers-grid input[type="color"] {
    width: 100%;
    height: 36px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    background: #0b0b0d;
    cursor: pointer;
    padding: 2px;
}

.btn-mini-clear {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.45);
    color: #fca5a5;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
}

/* Cadre Photo en Direct Responsive */
.photo-canvas {
    position: relative;
    background: #111;
    box-shadow: 0 25px 60px rgba(0,0,0,0.85);
    overflow: hidden;
    transition: width 0.25s ease, aspect-ratio 0.25s ease;
    display: flex;
    flex-direction: column;
}

.photo-canvas.ratio-10x15.paysage { width: 660px; aspect-ratio: 3 / 2; }
.photo-canvas.ratio-10x15.portrait { width: 440px; aspect-ratio: 2 / 3; }
.photo-canvas.ratio-15x20.paysage { width: 640px; aspect-ratio: 4 / 3; }
.photo-canvas.ratio-15x20.portrait { width: 460px; aspect-ratio: 3 / 4; }

@media (max-width: 760px) {
    .photo-canvas.ratio-10x15.paysage,
    .photo-canvas.ratio-15x20.paysage { width: 100%; }
    .photo-canvas.ratio-10x15.portrait,
    .photo-canvas.ratio-15x20.portrait { width: 88%; }
}

.photo-area-wrapper {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.photo-bg-sample {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.custom-png-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
    z-index: 4;
}

/* Bandeau Mode Assisté Responsive (s'adapte à la taille des logos et du QR Code sans jamais chevaucher) */
.template-banner {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    z-index: 5;
    transition: padding 0.15s ease, background 0.2s ease;
    box-sizing: border-box;
    width: 100%;
}

.banner-text-block {
    flex: 1 1 120px;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
    padding-right: 4px;
}

.banner-left-cluster,
.banner-right-cluster {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    max-width: 62%;
}

.banner-left-cluster:empty,
.banner-right-cluster:empty {
    display: none;
}

.banner-logos.floating-photo-logos {
    position: absolute;
    z-index: 6;
}
.banner-logos.floating-photo-logos.logo-pos-photo-top-left {
    top: 12px;
    left: 12px;
}
.banner-logos.floating-photo-logos.logo-pos-photo-top-right {
    top: 12px;
    right: 12px;
}
.banner-logos.floating-photo-logos.logo-pos-photo-top-center {
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
}

.banner-qr-slot {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.banner-qr-slot:empty {
    display: none;
}

.theme-noel .template-banner {
    background: linear-gradient(90deg, rgba(110, 12, 18, 0.95), rgba(65, 8, 12, 0.96));
    border-top: 2px solid #d4af37;
    color: #fff;
}

.theme-sapin .template-banner {
    background: linear-gradient(90deg, rgba(11, 59, 36, 0.95), rgba(6, 36, 22, 0.96));
    border-top: 2px solid #d4af37;
    color: #fff;
}

.theme-nuit .template-banner {
    background: linear-gradient(90deg, rgba(13, 27, 62, 0.95), rgba(8, 16, 38, 0.96));
    border-top: 2px solid #d4af37;
    color: #fff;
}

.theme-polaroid {
    padding: 14px 14px 0 14px;
    background: #faf8f5;
}
.theme-polaroid .template-banner {
    position: relative;
    background: #faf8f5;
    color: #18181b;
    border-top: none;
    padding: 12px 6px;
}

.theme-galerie .template-banner {
    background: rgba(10, 10, 12, 0.94);
    border-top: 2px solid #c5a880;
    color: #f5f3ef;
}

.theme-transparent .template-banner {
    background: linear-gradient(to top, rgba(0,0,0,0.88) 25%, rgba(0,0,0,0.35) 80%, transparent);
    color: #fff;
}

.banner-logos {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.banner-logos img {
    height: 42px;
    max-width: 160px;
    width: auto;
    object-fit: contain;
    border-radius: 5px;
    transition: height 0.12s ease, max-width 0.12s ease;
}

.banner-logos img.logo-bg-white {
    background: rgba(255, 255, 255, 0.94);
    padding: 4px 7px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.banner-logos img.logo-bg-transparent {
    background: transparent;
    padding: 0;
}

.banner-logos img.logo-bg-dark {
    background: rgba(12, 12, 15, 0.9);
    border: 1px solid rgba(197, 168, 128, 0.55);
    padding: 4px 7px;
}

/* Cartouche Code Unique + QR Code Compact & Responsive */
.code-cartouche {
    position: absolute;
    z-index: 6;
    background: rgba(12, 12, 14, 0.92);
    border: 1px solid rgba(197, 168, 128, 0.65);
    color: #fff;
    padding: 4px 7px;
    border-radius: 5px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.60rem;
    line-height: 1.18;
    box-shadow: 0 3px 10px rgba(0,0,0,0.45);
    white-space: nowrap;
    flex-shrink: 0;
}

.code-cartouche.in-banner-flow {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* 5 Designs de Cartouche QR Code */
.code-cartouche.qr-design-badge-portrait {
    flex-direction: column;
    text-align: center;
    padding: 5px 7px;
    gap: 3px;
}
.code-cartouche.qr-design-badge-portrait .qr-text-lines {
    align-items: center;
}

.code-cartouche.qr-design-badge-square {
    flex-direction: column;
    text-align: center;
    padding: 5px 6px;
    gap: 2px;
}
.code-cartouche.qr-design-badge-square .qr-top-line {
    display: none;
}
.code-cartouche.qr-design-badge-square .qr-text-lines {
    align-items: center;
}

.code-cartouche.qr-design-badge-light {
    background: rgba(255, 255, 255, 0.95);
    border: 1.5px solid #c5a880;
    color: #111;
}
.code-cartouche.qr-design-badge-light .qr-top-line {
    color: #7c6238;
}
.code-cartouche.qr-design-badge-light .qr-code-line {
    color: #111;
}
.code-cartouche.qr-design-badge-light .qr-mini-box {
    border: 1px solid #d4d4d8;
}

.code-cartouche.qr-design-badge-transparent {
    background: transparent;
    border: 1px dashed rgba(197, 168, 128, 0.55);
    box-shadow: none;
}

.qr-text-lines {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.qr-top-line {
    font-size: 0.52rem;
    color: #c5a880;
    letter-spacing: 0.03em;
    font-weight: 600;
}

.qr-code-line {
    font-size: 0.60rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    color: #fff;
}

.code-cartouche.pos-top-right { top: 10px; right: 10px; }
.code-cartouche.pos-top-left { top: 10px; left: 10px; }
.code-cartouche.pos-bottom-right { bottom: 78px; right: 10px; }
.code-cartouche.pos-bottom-left { bottom: 78px; left: 10px; }

.qr-mini-box {
    width: 24px;
    height: 24px;
    background: #fff;
    color: #000;
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 0.48rem;
    border-radius: 3px;
    flex-shrink: 0;
}

