/* ============================================================
   FOUNDRY ARCHITECT PRO - THEME INDUSTRIEL
   ============================================================ */

:root {
    /* Palette Foundry */
    --foundry-yellow: #ffb400;
    --xeno-orange: #f25f00;
    --technum-blue: #00e5ff;
    --bg-dark: #0f1113;
    --panel-gray: rgba(30, 33, 38, 0.95);
    --card-bg: #1e2126;
    --border-metal: #3d424a;
    --text-main: #e0e0e0;
    --text-dim: #9ca3af;
    
    /* Variables de layout */
    --node-width: 220px;
}

/* --- Base --- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 2px 2px, rgba(255,255,255,0.05) 1px, transparent 0);
    background-size: 40px 40px; /* Grille de fond discrète */
    color: var(--text-main);
    margin: 0;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* --- Barre de Contrôle Supérieure --- */
.panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: var(--panel-gray);
    backdrop-filter: blur(10px);
    border-bottom: 2px solid var(--foundry-yellow);
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-left: auto;
}

.controls-row {
    display: flex;
    gap: 25px;
    align-items: flex-end;
    width: 100%;
}

.input-group {
    display: flex;
    flex-direction: column;
}

label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--foundry-yellow);
    margin-bottom: 4px;
    font-weight: bold;
    letter-spacing: 1px;
}

input, select, button {
    background: #000;
    border: 1px solid var(--border-metal);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
}

input:focus, select:focus {
    border-color: var(--foundry-yellow);
    outline: none;
}

/* --- Boutons Spéciaux --- */
.btn-primary {
    background: var(--foundry-yellow);
    color: black;
    font-weight: bold;
    border: none;
    cursor: pointer;
    transition: transform 0.1s;
}

.zoom-controls button {
    background: #000;
    border: 1px solid var(--border-metal);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    margin: 0 5px;
}

.zoom-controls button:hover {
    background: var(--foundry-yellow);
    color: black;
}

.btn-primary:hover {
    background: #ffc843;
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--foundry-yellow);
    color: var(--foundry-yellow);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 4px;
    margin-left: 10px;
}

.btn-secondary:hover {
    background: rgba(255, 180, 0, 0.2);
}

/* --- Viewport & Canvas --- */
#viewport {
    width: 100vw;
    height: 100vh;
    cursor: grab;
    position: relative;
    overflow: hidden;
    padding-top: 70px;
}
#viewport:active {
    cursor: grabbing; /* Curseur main fermée pendant le clic */
}
#zoom-container {
    position: absolute;
    transform-origin: 0 0; /* Important pour le calcul de centrage */
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1); /* Animation fluide */
    width: 100%;
    height: 100%;
    overflow: visible !important;
}

#svg-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 10000px; /* Taille immense pour éviter le tronquage */
    height: 10000px;
    pointer-events: none; /* Laisse cliquer à travers sur les machines */
    z-index: 1;
    overflow: visible; /* Très important */
}

.conveyor-line {
    fill: none;
    stroke: rgba(255, 180, 0, 0.3);
    stroke-dasharray: 10, 5;
    animation: flow 2s linear infinite;
}

@keyframes flow {
    from { stroke-dashoffset: 15; }
    to { stroke-dashoffset: 0; }
}

/* --- Nœuds (Bâtiments) --- */
.node {
    position: absolute;
    width: var(--node-width);
    background: var(--card-bg);
    border: 1px solid var(--border-metal);
    border-radius: 4px;
    box-shadow: 0 10px 15px rgba(0,0,0,0.4);
    z-index: 2;
    transition: box-shadow 0.2s;
    cursor: default; /* Les cartes elles-mêmes ne déclenchent pas le drag du fond */
    pointer-events: all;    
}

.node:hover {
    box-shadow: 0 0 15px var(--foundry-yellow);
    border-color: var(--foundry-yellow);
}

.node.factory { border-left: 5px solid var(--foundry-yellow); }
.node.raw { border-left: 5px solid var(--technum-blue); }

.node-header {
    background: rgba(0,0,0,0.3);
    gap: 8px;
    padding: 8px;
    font-weight: bold;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border-metal);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;    
}
.node-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
}
.node-body {
    padding: 12px;
}

.rate {
    font-size: 1.4rem;
    font-weight: bold;
    margin-bottom: 8px;
}

.rate small { font-size: 0.7rem; color: var(--text-dim); }

.machine-badge {
    display: inline-block;
    background: #000;
    color: var(--foundry-yellow);
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 0.8rem;
    font-family: monospace;
    border: 1px solid rgba(255, 180, 0, 0.4);
    margin-bottom: 5px;
}

.rate-badge {
    display: inline-block;
    background: #000;
    color: var(--text-main);
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 0.75rem;
    margin-bottom: 5px;
    width: 100%;
}

.rate-badge .input-rate {
    color: var(--technum-blue);
    margin-right: 10px;
}

.rate-badge .output-rate {
    color: var(--xeno-orange);
}

.byproduct {
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--xeno-orange);
    border-top: 1px dashed var(--border-metal);
    padding-top: 5px;
}

/* --- Recherche --- */
.search-container {
    position: relative;
    width: 250px;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--foundry-yellow);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
}

.search-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-metal);
}

.search-item:hover {
    background: var(--foundry-yellow);
    color: black;
}

.hidden { display: none !important; }

/* --- Panneau Résumé (Sidebar) --- */
.summary-panel {
    position: fixed;
    right: 0;
    top: 70px;
    bottom: 0;
    width: 300px;
    background: var(--panel-gray);
    border-left: 2px solid var(--foundry-yellow);
    padding: 20px;
    z-index: 90;
    box-shadow: -5px 0 15px rgba(0,0,0,0.3);
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: var(--foundry-yellow);
}

.summary-line {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-metal);
}

/* --- Interface 3D Overlay --- */
.fullscreen-schema-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 200;
}

.fullscreen-schema-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 15px 30px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 210;
}

#threejs-container {
    width: 100%;
    height: 100%;
}

.perf-badge {
    background: #000;
    color: #0f0;
    padding: 4px 8px;
    font-family: monospace;
    font-size: 0.8rem;
    border: 1px solid #0f0;
    margin-left: 15px;
}
.search-group-title {
    background: #000;
    color: var(--foundry-yellow);
    padding: 5px 10px;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
    border-left: 3px solid var(--foundry-yellow);
    margin-top: 5px;
    position: sticky;
    top: 0;
}

.search-item {
    padding: 8px 20px; /* On décale un peu les items pour l'effet de hiérarchie */
    font-size: 0.9rem;
}