/**
 * [CYBER-STRAT] Design System Cyberpunk
 * Esthetique Blade Runner 1982 — Interface console d'intelligence
 * Aucune librairie CSS externe
 */

/* === IMPORTS & VARIABLES === */
@import url("https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap");

:root {
    --bg-primary: #000000;
    --text-primary: #00FF41;
    --text-secondary: #00CC33;
    --text-dim: #008F11;
    --accent-alert: #FF6600;
    --grid-color: #1a1a1a;
    --scanline: rgba(0, 255, 65, 0.03);
    --border-glow: rgba(0, 255, 65, 0.4);
    --border-glow-strong: rgba(0, 255, 65, 0.7);
    --shadow-glow: 0 0 10px rgba(0, 255, 65, 0.3);
    --shadow-glow-strong: 0 0 20px rgba(0, 255, 65, 0.5);
    --font-mono: "Share Tech Mono", "Courier New", monospace;
    --font-size-base: 14px;
    --font-size-sm: 12px;
    --font-size-lg: 16px;
    --line-height: 1.6;
    --grid-size: 40px;
    --image-panel-width: 280px;
    --header-height: 40px;
    --input-bar-height: 50px;
}

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

/* === BASE === */
html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: var(--font-size-base);
    line-height: var(--line-height);
}

/* === FOND CIRCUIT IMPRIME === */
body {
    background: #000000;
}

/* === FOND GRILLE + DIAMANTS === */
.cs-grid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    background-color: #000;
    background-image:
        linear-gradient(rgba(180,180,180,0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(180,180,180,0.07) 1px, transparent 1px),
        linear-gradient(45deg, rgba(160,160,160,0.12) 1px, transparent 1px),
        linear-gradient(-45deg, rgba(160,160,160,0.12) 1px, transparent 1px);
    background-size: 40px 40px, 40px 40px, 8px 8px, 8px 8px;
    background-position: -1px -1px, -1px -1px, 16px 16px, 16px 16px;
}

/* === SCANLINES OVERLAY === */
.scanlines::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        var(--scanline),
        var(--scanline) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 9999;
}

/* === LAYOUT PRINCIPAL === */
.cs-app {
    display: flex;
    flex-direction: column;
    height: 90vh;
    max-height: 90vh;
    width: 100%;
    max-width: 900px;
    margin: 5vh auto;
    position: relative;
    border: 1px solid #00FF41;
    border-radius: 2px;
    box-shadow: 0 0 18px rgba(0,255,65,0.35), inset 0 0 8px rgba(0,255,65,0.1);
    overflow: hidden;
}

/* Connecteurs electroniques aux 4 coins (carres 8x8 vert fluo) */
/* ::before couvre le bord haut : coin haut-gauche + coin haut-droit */
.cs-app::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
    z-index: 200;
    pointer-events: none;
    background:
        linear-gradient(#00FF41, #00FF41) left top / 8px 8px no-repeat,
        linear-gradient(#00FF41, #00FF41) right top / 8px 8px no-repeat;
}

/* ::after couvre le bord bas : coin bas-gauche + coin bas-droit */
.cs-app::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 8px;
    z-index: 200;
    pointer-events: none;
    background:
        linear-gradient(#00FF41, #00FF41) left top / 8px 8px no-repeat,
        linear-gradient(#00FF41, #00FF41) right top / 8px 8px no-repeat;
}

/* === CANVAS CATHODE BACKGROUND === */
.cs-cathode-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* === HEADER === */
.console-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 15px;
    border-bottom: 1px solid var(--border-glow);
    background-color: rgba(0, 0, 0, 0.9);
    flex-shrink: 0;
    z-index: 100;
}

.cs-logo {
    font-size: var(--font-size-base);
    color: var(--text-primary);
    letter-spacing: 2px;
    text-shadow: var(--shadow-glow);
}

.cs-status {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.cs-status .blink {
    animation: blink-status 1.5s infinite;
    font-style: normal;
}

@keyframes blink-status {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.cs-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cs-control-btn {
    background: none;
    border: 1px solid var(--border-glow);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    padding: 2px 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.cs-control-btn:hover {
    background-color: rgba(0, 255, 65, 0.1);
    border-color: var(--border-glow-strong);
    box-shadow: var(--shadow-glow);
}

/* === ZONE PRINCIPALE (2 colonnes) === */
.cs-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* === PANNEAU IMAGE (gauche) === */
.cs-image-panel {
    width: var(--image-panel-width);
    flex-shrink: 0;
    border-right: 1px solid var(--border-glow);
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.cs-image-container {
    position: relative;
    border: 1px solid var(--border-glow);
    box-shadow: var(--shadow-glow);
    overflow: visible;
}

/* Conteneur image interne : overflow hidden ici (pas sur le container parent) */
.cs-image-container .cs-image-wrapper,
.cs-image-container > img {
    overflow: hidden;
}

.cs-image-container img {
    width: 100%;
    display: block;
    filter: grayscale(30%) brightness(0.9);
    transition: filter 0.3s;
    object-fit: cover;
    object-position: top;
}

.cs-image-container img:hover {
    filter: grayscale(0%) brightness(1);
}

/* Jaquette publication : contain sur fond noir */
.cs-image-cover {
    background: #0a0a0a;
}

.cs-image-cover img {
    object-fit: contain !important;
    object-position: center !important;
    max-height: 280px;
}

/* Effet scan image : animation top->bottom */
.cs-image-container.scanning::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--text-primary);
    box-shadow: 0 0 15px var(--text-primary), 0 0 30px var(--text-primary);
    animation: scanDown 0.8s ease-out forwards;
    z-index: 10;
}

@keyframes scanDown {
    0% { top: 0; opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

.cs-image-container.scanning img {
    animation: imageReveal 0.8s ease-out forwards;
}

@keyframes imageReveal {
    0% {
        clip-path: inset(0 0 100% 0);
        opacity: 0.3;
    }
    100% {
        clip-path: inset(0 0 0 0);
        opacity: 1;
    }
}

/* Canvas overlay pour l'effet de scan cathodique CRT */
.cs-scan-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

.cs-image-label {
    font-size: var(--font-size-sm);
    color: var(--text-dim);
    padding: 5px 4px;
    text-align: center;
    border-top: 1px solid var(--grid-color);
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.3;
    max-height: none;
}

/* Placeholder quand pas d'image */
.cs-image-placeholder {
    border: 1px dashed var(--grid-color);
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: var(--font-size-sm);
}

/* === PANNEAU CONSOLE (droite) === */
.cs-console-panel {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    position: relative;
}

/* Scrollbar cyberpunk */
.cs-console-panel::-webkit-scrollbar {
    width: 6px;
}

.cs-console-panel::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.cs-console-panel::-webkit-scrollbar-thumb {
    background: var(--text-dim);
    border-radius: 3px;
}

.cs-console-panel::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Zone de sortie texte */
.cs-output {
    min-height: 100%;
}

.cs-output-line {
    margin-bottom: 4px;
}

.cs-output-line .cs-char {
    opacity: 0;
    animation: charAppear 0.05s forwards;
}

@keyframes charAppear {
    to { opacity: 1; }
}

/* Styles de texte console */
.cs-label {
    color: var(--accent-alert);
    font-weight: bold;
}

.cs-value {
    color: var(--text-primary);
}

.cs-dim {
    color: var(--text-dim);
}

.cs-highlight {
    color: var(--accent-alert);
    text-shadow: 0 0 8px rgba(255, 102, 0, 0.5);
}

.cs-separator {
    color: var(--text-dim);
    margin: 8px 0;
    overflow: hidden;
    white-space: nowrap;
}

/* Curseur clignotant */
.cs-cursor {
    display: inline-block;
    width: 8px;
    height: 14px;
    background-color: var(--text-primary);
    animation: cursorBlink 0.8s infinite;
    vertical-align: middle;
    margin-left: 2px;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Message de bienvenue / boot */
.cs-boot-text {
    color: var(--text-dim);
    font-size: var(--font-size-sm);
    margin-bottom: 15px;
}

/* Indicateur de type d'entite */
.cs-entity-badge {
    display: inline-block;
    padding: 2px 8px;
    border: 1px solid var(--accent-alert);
    color: var(--accent-alert);
    font-size: var(--font-size-sm);
    margin: 5px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Lien source */
.cs-source-link {
    color: var(--text-dim);
    font-size: var(--font-size-sm);
    text-decoration: none;
    border-bottom: 1px solid var(--grid-color);
    transition: color 0.2s;
}

.cs-source-link:hover {
    color: var(--text-primary);
}

/* === BARRE DE SAISIE === */
.cs-input-bar {
    display: flex;
    align-items: center;
    height: var(--input-bar-height);
    padding: 0 15px;
    border-top: 1px solid var(--border-glow);
    background-color: rgba(0, 0, 0, 0.9);
    flex-shrink: 0;
    gap: 10px;
}

.cs-prompt {
    color: var(--accent-alert);
    font-size: var(--font-size-base);
    flex-shrink: 0;
}

.cs-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: var(--font-size-base);
    caret-color: var(--text-primary);
}

.cs-input::placeholder {
    color: var(--text-dim);
}

.cs-btn-exec,
.cs-btn-clear {
    background: transparent;
    border: 1px solid var(--border-glow);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    padding: 6px 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cs-btn-exec:hover {
    background-color: rgba(0, 255, 65, 0.15);
    border-color: var(--border-glow-strong);
    box-shadow: var(--shadow-glow);
}

.cs-btn-clear {
    border-color: rgba(255, 102, 0, 0.4);
    color: var(--accent-alert);
}

.cs-btn-clear:hover {
    background-color: rgba(255, 102, 0, 0.1);
    border-color: rgba(255, 102, 0, 0.7);
}

/* Bouton EXECUTE — largeur stable pour chevrons */
.cs-btn-exec {
    min-width: 100px;
    text-align: center;
}

/* Etat chevron actif (animation remplissage) */
.cs-btn-exec.chevron-active {
    pointer-events: none;
    color: var(--text-secondary);
    border-color: var(--text-secondary);
    letter-spacing: 0;
    text-transform: none;
}

/* Flash vert de completion */
.cs-btn-exec.chevron-done {
    pointer-events: none;
    background-color: rgba(0, 255, 65, 0.25);
    color: var(--text-primary);
    border-color: var(--border-glow-strong);
    box-shadow: var(--shadow-glow-strong);
    text-shadow: 0 0 8px rgba(0, 255, 65, 0.8);
    letter-spacing: 0;
    text-transform: none;
}

/* === LOADER ANIMATION === */
.cs-loader {
    display: inline-block;
    color: var(--text-secondary);
}

.cs-loader::after {
    content: "|";
    animation: loaderSpin 0.3s infinite steps(4);
}

@keyframes loaderSpin {
    0% { content: "|"; }
    25% { content: "/"; }
    50% { content: "-"; }
    75% { content: "\\"; }
}

/* === ETATS SPECIAUX === */
.cs-error {
    color: var(--accent-alert);
    border-left: 2px solid var(--accent-alert);
    padding-left: 10px;
    margin: 10px 0;
}

.cs-success {
    color: var(--text-primary);
    border-left: 2px solid var(--text-primary);
    padding-left: 10px;
    margin: 10px 0;
}

/* Metadonnees sources et synthese (v1.1) */
.cs-sources-meta {
    color: var(--text-secondary);
    font-size: 11px;
    margin-top: 4px;
    letter-spacing: 0.5px;
}

/* === CARTE LEAFLET CYBERPUNK === */
.cs-map-container {
    width: 100%;
    height: 250px;
    margin: 10px 0;
    border: 1px solid var(--border-glow);
    box-shadow: var(--shadow-glow);
    position: relative;
}

.cs-map {
    width: 100%;
    height: 100%;
    background: #000000;
}

/* Surcharge Leaflet pour esthetique cyberpunk */
.leaflet-container {
    background: #000000 !important;
    font-family: var(--font-mono) !important;
}

.leaflet-popup-content-wrapper {
    background: #0a0a0a !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--text-primary) !important;
    font-family: var(--font-mono) !important;
    font-size: 12px !important;
    border-radius: 0 !important;
}

.leaflet-popup-tip {
    background: var(--text-primary) !important;
}

.leaflet-control-attribution {
    background: rgba(0, 0, 0, 0.7) !important;
    color: var(--text-dim) !important;
    font-size: 9px !important;
}

.leaflet-control-attribution a {
    color: var(--text-dim) !important;
}

.leaflet-control-zoom a {
    background: #0a0a0a !important;
    color: var(--text-primary) !important;
    border-color: var(--border-glow) !important;
}

/* Coordonnees texte (pour personnes/organisations sans carte) */
.cs-coords-text {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    margin: 5px 0;
}

/* Indicateur de traitement */
.cs-processing-time {
    color: var(--text-dim);
    font-size: var(--font-size-sm);
    margin-top: 15px;
    text-align: right;
}

/* === RESPONSIVE MOBILE === */
@media (max-width: 768px) {
    :root {
        --image-panel-width: 100%;
        --font-size-base: 13px;
    }

    .cs-app {
        max-width: 100%;
        margin: 0;
        height: 100vh;
        max-height: 100vh;
        border: 1px solid #00FF41;
        border-radius: 0;
        padding: 8px;
        box-shadow: 0 0 18px rgba(0,255,65,0.35), inset 0 0 8px rgba(0,255,65,0.1);
    }

    /* Masquer les connecteurs de coin sur mobile */
    .cs-app::before,
    .cs-app::after {
        display: none;
    }

    .cs-main {
        flex-direction: column;
    }

    .cs-image-panel {
        width: 100%;
        display: flex;
        flex-direction: row;
        justify-content: center;
        gap: 8px;
        padding: 8px;
        order: 1;
        max-height: 180px;
        overflow: hidden;
        border-right: none;
        border-bottom: 1px solid var(--border-glow);
    }

    .cs-image-panel img {
        width: 48%;
        max-width: 48%;
        height: 160px;
        object-fit: cover;
        object-position: top;
    }

    .cs-image-cover img {
        object-fit: contain !important;
        object-position: center !important;
    }

    .cs-image-container {
        min-width: unset;
        max-width: 48%;
        flex-shrink: 1;
    }

    .cs-console-panel {
        order: 2;
        width: 100%;
        padding: 15px;
    }

    .cs-input-bar {
        display: flex;
        flex-wrap: nowrap;
        width: 100%;
        box-sizing: border-box;
        padding: 6px 8px;
        gap: 4px;
    }

    .cs-prompt {
        flex-shrink: 0;
        font-size: 12px;
    }

    .cs-input {
        flex: 1 1 0%;
        min-width: 0;
        font-size: 16px;
        padding: 4px 6px;
    }

    .cs-btn-exec {
        flex-shrink: 0;
        white-space: nowrap;
        padding: 4px 8px;
        font-size: 11px;
        min-width: 82px;
    }

    .cs-btn-clear {
        display: none;
    }

    html, body {
        overflow-x: hidden;
    }

    .cs-status {
        display: none;
    }
}

@media (max-width: 480px) {
    .cs-image-panel {
        max-height: 140px;
    }

    .cs-logo {
        font-size: var(--font-size-sm);
    }
}

/* === BOUTON MUTE === */
#cs-mute-btn {
    width: 44px;
    height: 28px;
    min-width: 44px;
    max-width: 44px;
    background: transparent;
    border: 1px solid #00FF41;
    color: #00FF41;
    font-family: "Share Tech Mono", "Courier New", monospace;
    font-size: 10px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    overflow: hidden;
}

#cs-mute-btn:hover {
    background: rgba(0,255,65,0.1);
}

/* Etat mute : fond vert, texte noir */
#cs-mute-btn.active {
    background: #00FF41;
    color: #000000;
    font-weight: bold;
}

/* === IMAGE WRAPPER LINK + OVERLAY === */
.cs-image-wrapper {
    display: block;
    position: relative;
    overflow: hidden;
}

.cs-image-wrapper::after {
    content: "\2197 VOIR";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.75);
    color: #00FF41;
    font-family: var(--font-mono);
    font-size: 11px;
    text-align: center;
    padding: 4px 0;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
    letter-spacing: 2px;
}

.cs-image-wrapper:hover::after {
    opacity: 1;
}

/* === PUBLICATIONS === */
.cs-pub-link {
    color: #00FF41;
    font-size: 12px;
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 255, 65, 0.3);
    transition: all 0.2s;
    display: inline-block;
    margin: 3px 0;
}

.cs-pub-link:hover {
    color: #FFFFFF;
    border-bottom-color: #FFFFFF;
    text-shadow: 0 0 8px rgba(0, 255, 65, 0.5);
}

.cs-pub-link--old {
    color: #00CC33;
    font-size: 11px;
}

.cs-pub-link--old:hover {
    color: #00FF41;
}

/* === ANIMATIONS UTILITAIRES === */
.fade-in {
    animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Effet de glitch occasionnel sur le logo */
.cs-logo:hover {
    animation: glitch 0.3s ease;
}

@keyframes glitch {
    0% { text-shadow: var(--shadow-glow); }
    20% { text-shadow: -2px 0 #ff0000, 2px 0 #00ffff; }
    40% { text-shadow: 2px 0 #ff0000, -2px 0 #00ffff; }
    60% { text-shadow: -1px 0 #ff0000, 1px 0 #00ffff; }
    80% { text-shadow: 1px 0 #ff0000, -1px 0 #00ffff; }
    100% { text-shadow: var(--shadow-glow); }
}
