@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:wght@400;500;700&display=swap');

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

:root {
    --red: #C0101E;
    --black: #0a0a0a;
    --white: #FAFAF8;
    --off: #F0EFE9;
    --muted: #999;
    --border: 2px solid var(--black);
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--red);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ══════════ SIDEBAR ══════════ */
#sidebar {
    width: 220px;
    min-width: 220px;
    background: var(--white);
    border-right: var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    display: flex;
    align-items: stretch;
    border-bottom: var(--border);
    flex-shrink: 0;
}

.logo-title {
    flex: 1;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 22px;
    letter-spacing: .06em;
    padding: 12px 14px;
    background: var(--black);
    color: var(--white);
    white-space: nowrap;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.logo-title span { color: var(--red); }

/* Drapeaux */
#countries-container {
    display: flex;
    border-bottom: var(--border);
    flex-shrink: 0;
}
.country-btn {
    flex: 1;
    background: var(--white);
    border: none;
    border-right: var(--border);
    padding: 10px 6px;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    transition: background .1s;
}
.country-btn:last-child { border-right: none; }
.country-btn.active { 
    background: var(--off);
    box-shadow: inset 0 -3px 0 var(--red);
}
.country-btn:hover:not(.active) { background: var(--off); }

/* Zone d'actions (Import & Export) */
.sidebar-actions {
    border-bottom: var(--border);
    background: var(--off);
    display: flex;
    flex-shrink: 0;
}
.action-btn {
    flex: 1;
    text-align: center;
    padding: 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--black);
    font-family: 'DM Sans', sans-serif;
    transition: background .15s, color .15s;
}
.action-btn:not(:last-child) {
    border-right: var(--border);
}
.action-btn:hover {
    background: var(--black);
    color: var(--white);
}

/* Grille logos */
#logos-container {
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    align-content: start;
    grid-gap: 12px;
    gap: 12px;
    overflow-y: auto;
    flex: 1;
}

/* Scrollbar personnalisée */
#logos-container::-webkit-scrollbar { 
    width: 8px; 
}
#logos-container::-webkit-scrollbar-track { 
    background: var(--off);
    border-left: 1px solid #ddd;
}
#logos-container::-webkit-scrollbar-thumb { 
    background: var(--black); 
    border-radius: 4px;
}
#logos-container::-webkit-scrollbar-thumb:hover { 
    background: var(--red);
}

.logo-item {
    border: var(--border);
    width: 100%;
    height: 87px; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 8px;
    background: var(--white);
    transition: background .12s, transform .1s;
    overflow: hidden;
    gap: 4px;
    position: relative;
    margin: 2px;
}
.logo-item:hover { background: var(--black); transform: scale(1.03); }
.logo-item:active { transform: scale(0.97); }

.logo-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.logo-item:hover img { filter: invert(1); }

.unknown-icon {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 34px;
    color: var(--black);
    line-height: 1;
}
.logo-item:hover .unknown-icon { color: var(--white); }

.logo-missing {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 9px;
    font-weight: 700;
    color: #bbb;
    text-align: center;
    word-break: break-all;
    line-height: 1.3;
}
.logo-missing .miss-icon { font-size: 18px; }

/* Indicateur mode ajout */
#logos-container.adding-mode {
    outline: 3px solid var(--red);
    outline-offset: -3px;
    border-radius: 2px;
}
#logos-container.adding-mode::before {
    content: '← Cliquez pour ajouter';
    display: block;
    grid-column: 1 / -1;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--red);
    padding: 4px 2px;
    text-align: center;
}

/* ══════════ WORKSPACE ══════════ */
#workspace {
    flex: 1;
    display: flex;
    padding: 32px;
    overflow: auto;
    min-width: 0;
}

#canvas-paper {
    background: var(--white);
    position: relative;
    width: 100%;
    max-width: 860px;
    min-height: 460px;
    margin: auto;
    padding: 20px 0 40px;
    border: var(--border);
    box-shadow: 6px 6px 0 rgba(0,0,0,.35);
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: visible;
}

#canvas-paper::-webkit-scrollbar { height: 10px; }
#canvas-paper::-webkit-scrollbar-track { background: transparent; border-top: 1px solid #ddd; }
#canvas-paper::-webkit-scrollbar-thumb { background: var(--black); }

#watermark {
    position: absolute;
    bottom: 14px;
    right: 18px;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 13px;
    letter-spacing: .12em;
    color: #ccc;
    pointer-events: none;
    user-select: none;
}

#empty-hint {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Bebas Neue', sans-serif;
    font-size: 18px;
    letter-spacing: .1em;
    color: #d0cfc9;
    text-align: center;
    line-height: 1.6;
    pointer-events: none;
    user-select: none;
}

/* ══════════ ESCALIER ══════════ */
.staircase-wrapper {
    display: flex;
    align-items: flex-end;
    border-bottom: 3px solid var(--black);
    padding: 140px 40px 0 40px;
    margin: 0 auto;
    min-width: max-content;
}

.step {
    width: 130px;
    border-top: 3px solid var(--black);
    border-left: 3px solid var(--black);
    position: relative;
    flex-shrink: 0;
}

.step:last-child {
    border-right: 3px solid var(--black);
}

.step-content {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 8px;
    gap: 6px;
}

.step.selected .step-content {
    background: rgba(192, 16, 30, 0.05);
    outline: 2px dashed var(--red);
    outline-offset: 4px;
    border-radius: 4px;
}

.step-logos {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3px;
    width: 100%;
    padding: 0 4px;
}

.step-logo {
    width: 54px;
    height: 54px;
    object-fit: contain;
    cursor: pointer;
    transition: opacity .15s;
    display: block;
}
.step-logo:hover { opacity: .5; }

.step-unknown {
    width: 54px;
    height: 54px;
    border: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 26px;
    cursor: pointer;
    transition: opacity .15s;
    background: var(--white);
}
.step-unknown:hover { opacity: .5; }

.date-input {
    font-family: 'DM Sans', sans-serif;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    padding: 3px 8px;
    min-width: 80px;
    max-width: 120px;
    outline: none;
    white-space: pre-wrap;
    border: 1px dashed transparent;
    line-height: 1.5;
    cursor: text;
    word-break: break-word;
    background: transparent;
    border-radius: 2px;
}
.date-input:hover { border-color: #ccc; }
.date-input:focus { border-color: var(--black); background: rgba(255,255,255,.9); }

.step-actions {
    display: none;
    gap: 4px;
    align-items: center;
}
.step:hover .step-actions { display: flex; }

.add-btn, .del-btn {
    font-family: 'DM Sans', sans-serif;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    border: var(--border);
    padding: 3px 8px;
    cursor: pointer;
    line-height: 1;
    transition: background .1s;
}
.add-btn { background: var(--black); color: var(--white); }
.add-btn:hover { background: #333; }
.del-btn { background: var(--white); color: var(--red); border-color: var(--red); }
.del-btn:hover { background: var(--red); color: var(--white); }

/* ══════════ MASQUAGE DES BOUTONS SUR L'EXPORTATION IMAGE ══════════ */
.is-capturing .step-actions,
.is-capturing ::-webkit-scrollbar {
    display: none !important;
}
.is-capturing .date-input {
    border-color: transparent !important;
    background: transparent !important;
}

/* ══════════ MOBILE ══════════ */
@media (max-width: 680px) {
    body { flex-direction: column-reverse; }

    #sidebar {
        width: 100%;
        min-width: unset;
        height: auto;
        max-height: 45vh;
        border-right: none;
        border-top: var(--border);
    }

    #logos-container {
        grid-template-columns: repeat(4, 1fr);
        align-content: start;
        grid-gap: 8px;
        gap: 8px;
        padding: 10px;
    }

    .logo-item {
        height: calc(25vw - 13px); 
        margin: 1px;
    }

    #workspace {
        flex: 1;
        padding: 12px;
        overflow: auto;
        display: flex;
        align-items: center;
    }

    #canvas-paper {
        min-height: 320px;
        padding: 20px 0 30px;
        align-items: flex-end;
        justify-content: flex-start;
    }

    .staircase-wrapper {
        padding: 90px 20px 0 20px;
        min-width: max-content;
    }

    .step {
        width: 95px;
    }

    .step-logo, .step-unknown { 
        width: 38px; 
        height: 38px; 
    }
    
    .date-input { 
        font-size: 9px; 
        min-width: 50px; 
    }
}
