/* --- CSS Variables & Design System --- */
:root {
    --bg-main: #090d16;
    --bg-surface: rgba(18, 25, 41, 0.7);
    --bg-surface-opaque: #121929;
    --border-color: rgba(30, 41, 59, 0.5);
    --border-glow: rgba(14, 165, 233, 0.2);
    
    --primary: hsl(195, 95%, 45%);
    --primary-glow: rgba(14, 165, 233, 0.4);
    --success: hsl(145, 90%, 45%);
    --success-glow: rgba(16, 185, 129, 0.4);
    --warning: hsl(35, 95%, 50%);
    --warning-glow: rgba(245, 158, 11, 0.4);
    --danger: hsl(10, 90%, 50%);
    --danger-glow: rgba(239, 68, 68, 0.4);
    --info: hsl(210, 95%, 50%);
    
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --text-highlight: #ffffff;
    
    --font-sans: 'Outfit', sans-serif;
    --font-mono: 'Share Tech Mono', monospace;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Global Resets & Body --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--bg-main);
}

*::-webkit-scrollbar {
    width: 6px;
}
*::-webkit-scrollbar-track {
    background: var(--bg-main);
}
*::-webkit-scrollbar-thumb {
    background-color: var(--primary);
    border-radius: 3px;
}

body.cyber-theme {
    background-color: var(--bg-main);
    background-image: radial-gradient(circle at 50% 50%, #151e36 0%, #090d16 100%);
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

.font-mono {
    font-family: var(--font-mono);
}

.highlight {
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary-glow);
}

/* --- Buttons & Inputs --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    text-transform: uppercase;
    font-family: var(--font-sans);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #0284c7 100%);
    color: var(--text-highlight);
    box-shadow: 0 4px 15px var(--primary-glow);
}
.btn-primary:hover {
    filter: brightness(1.2);
    box-shadow: 0 6px 20px var(--primary-glow);
    transform: translateY(-2px);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: var(--text-highlight);
    box-shadow: 0 4px 15px var(--success-glow);
}
.btn-success:hover {
    filter: brightness(1.2);
    box-shadow: 0 6px 20px var(--success-glow);
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: var(--text-highlight);
    box-shadow: 0 4px 15px var(--danger-glow);
}
.btn-danger:hover {
    filter: brightness(1.2);
    box-shadow: 0 6px 20px var(--danger-glow);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border-color: var(--primary);
    color: var(--primary);
}
.btn-outline:hover {
    background: rgba(14, 165, 233, 0.1);
    color: var(--text-highlight);
    box-shadow: 0 0 15px var(--primary-glow);
}

.btn-block {
    display: flex;
    width: 100%;
}

input[type="text"], input[type="number"], select {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 14px;
    color: var(--text-main);
    font-family: var(--font-sans);
    transition: var(--transition);
    width: 100%;
}
input[type="text"]:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* --- Layout Screens --- */
.app-container {
    width: 100vw;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.screen {
    display: none;
    flex: 1;
    width: 100%;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* --- Lobby screen --- */
#lobby {
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.lobby-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    max-width: 960px;
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-top: 4px solid var(--primary);
}

.lobby-header {
    padding: 40px 40px 20px 40px;
    text-align: center;
}

.logo-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 10px;
}

.lobby-header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: 2px;
    margin-bottom: 5px;
}

.tagline {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.lobby-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 30px;
    padding: 20px 40px 40px 40px;
    border-top: 1px dashed var(--border-color);
}

.lobby-info {
    border-right: 1px solid var(--border-color);
    padding-right: 30px;
}

.lobby-info h3, .lobby-setup h3 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--text-highlight);
    display: flex;
    align-items: center;
    gap: 10px;
}

.lobby-info p {
    color: var(--text-muted);
    margin-bottom: 15px;
    font-size: 0.95rem;
}

.lobby-info ul {
    list-style: none;
}

.lobby-info li {
    margin-bottom: 12px;
    font-size: 0.95rem;
    color: var(--text-muted);
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.lobby-info li i {
    color: var(--primary);
    margin-top: 4px;
}

.lobby-setup .form-group {
    margin-bottom: 20px;
}

.lobby-setup label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.divider span {
    padding: 0 10px;
}

.section-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 15px;
}

.roles-selector-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.role-select-btn {
    flex-direction: column;
    height: 90px;
    font-size: 0.75rem;
    padding: 10px;
    gap: 5px;
    text-align: center;
}

.role-select-btn i {
    font-size: 1.5rem;
}

.lobby-footer {
    padding: 15px;
    text-align: center;
    background: rgba(10, 15, 30, 0.5);
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- Game Screen HUD Header --- */
.game-header {
    background: rgba(10, 15, 30, 0.85);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    backdrop-filter: blur(10px);
}

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

.header-logo h2 {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 1px;
}

.hud-stats {
    display: flex;
    gap: 20px;
    align-items: center;
}

.hud-item {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.hud-item i {
    font-size: 1rem;
}

.hud-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.hud-value {
    color: var(--text-highlight);
    font-size: 1.1rem;
    font-weight: bold;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.host-badge {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid var(--warning);
    color: var(--warning);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* --- Solo Mode Swither Bar --- */
#solo-role-switcher {
    background: rgba(15, 23, 42, 0.9);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.switcher-title {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    margin-right: 10px;
}

.switcher-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
    font-family: var(--font-sans);
    transition: var(--transition);
}

.switcher-btn:hover {
    border-color: var(--primary);
    color: var(--text-highlight);
}

.switcher-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-highlight);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* --- Game Grid Layout --- */
.game-main-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 300px;
    overflow: hidden;
    height: calc(100vh - 65px);
}

.game-main-grid.hide-sidebar {
    grid-template-columns: 1fr;
}

.game-main-grid.hide-sidebar .alerts-sidebar {
    display: none !important;
}

/* If solo switcher is active, adjust height */
.app-container:has(#solo-role-switcher:not(.hidden)) .game-main-grid {
    height: calc(100vh - 105px);
}

.workspace-area {
    padding: 24px;
    overflow-y: auto;
    position: relative;
}

.role-view {
    height: 100%;
}

.role-view.hidden {
    display: none !important;
}

/* --- Alert Sidebar --- */
.alerts-sidebar {
    background: rgba(10, 15, 26, 0.8);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    font-size: 1rem;
    color: var(--text-highlight);
}

.alerts-badge {
    background: var(--danger);
    color: var(--text-highlight);
    border-radius: 12px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: bold;
    padding: 2px 8px;
    min-width: 24px;
    text-align: center;
}

.alerts-log {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.empty-alerts {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-alerts i {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.alert-item {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: slideIn 0.25s ease-out;
}

.alert-item.info {
    border-left: 3px solid var(--info);
}

.alert-item.danger {
    border-left: 3px solid var(--danger);
    background: rgba(239, 68, 68, 0.05);
}

.alert-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 600;
}

.alert-meta .alert-code {
    font-family: var(--font-mono);
}

.alert-meta.info-meta {
    color: var(--info);
}

.alert-meta.danger-meta {
    color: var(--danger);
}

.alert-text {
    font-size: 0.85rem;
    color: var(--text-main);
}

/* --- Common Components Layout UI --- */
.view-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.view-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.view-card-header h2 {
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* --- CSS Micro Animations --- */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spin-slow {
    animation: spin 10s linear infinite;
}

.pulse {
    animation: pulse 3.5s ease-in-out infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hidden {
    display: none !important;
}

/* --- Modals Overlay --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 8, 16, 0.85);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-card {
    background: var(--bg-surface-opaque);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    padding: 32px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    border-top: 4px solid var(--primary);
    animation: slideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.trophy-icon {
    font-size: 4rem;
    color: var(--warning);
    margin-bottom: 15px;
}

.score-card {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    text-align: left;
}

.score-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.score-val {
    font-size: 3.5rem;
    font-family: var(--font-mono);
    font-weight: 800;
    color: var(--success);
    line-height: 1;
}

.score-lbl {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 1px;
}

.score-breakdown h4 {
    margin-bottom: 10px;
    color: var(--text-highlight);
    font-size: 0.95rem;
}

.score-breakdown ul {
    list-style: none;
}

.score-breakdown li {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.score-breakdown li strong {
    color: var(--text-highlight);
    font-family: var(--font-mono);
}

.modal-actions {
    margin-top: 20px;
}

/* --- Component Specific UI - Control Panel --- */
.control-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.gauge-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
}

.gauge-container {
    position: relative;
    width: 160px;
    height: 160px;
    margin-bottom: 10px;
}

.gauge-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.gauge-bg {
    fill: none;
    stroke: rgba(30, 41, 59, 0.8);
    stroke-width: 10;
}

.gauge-fill {
    fill: none;
    stroke: var(--primary);
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dasharray 0.5s ease-out, stroke 0.5s ease-out;
}

.gauge-fill.high {
    stroke: var(--warning);
}

.gauge-fill.danger {
    stroke: var(--danger);
}

.gauge-value-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-mono);
    font-size: 1.8rem;
    font-weight: 800;
}

.wind-vane-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.compass-container {
    width: 180px;
    height: 180px;
    position: relative;
    border-radius: 50%;
    border: 2px dashed var(--border-color);
    margin-bottom: 15px;
    background: rgba(15, 23, 42, 0.4);
}

.compass-direction {
    position: absolute;
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--text-muted);
}
.compass-n  { top: 5px; left: 50%; transform: translateX(-50%); }
.compass-e  { right: 5px; top: 50%; transform: translateY(-50%); }
.compass-s  { bottom: 5px; left: 50%; transform: translateX(-50%); }
.compass-o  { left: 5px; top: 50%; transform: translateY(-50%); }

.compass-arrow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 100px;
    margin-top: -50px;
    margin-left: -10px;
    transition: transform 0.8s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    transform-origin: center center;
}

.compass-arrow::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 50px solid var(--primary);
}

.compass-arrow::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 50px solid rgba(239, 68, 68, 0.8);
}

.compass-center-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-surface-opaque);
    border: 1px solid var(--border-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-highlight);
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    z-index: 5;
}

.control-actions-card {
    grid-column: span 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.transformer-meta {
    flex: 1;
}

.transformer-meta table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.transformer-meta td {
    padding: 6px 12px;
}

.transformer-meta td:first-child {
    color: var(--text-muted);
    font-weight: bold;
    width: 40%;
}

.transformer-meta td:last-child {
    font-family: var(--font-mono);
    color: var(--text-highlight);
}

.replace-progress-wrapper {
    width: 100%;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    height: 24px;
    overflow: hidden;
    position: relative;
    margin-top: 10px;
}

.replace-progress-bar {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.1s linear;
}

.replace-progress-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75rem;
    font-weight: bold;
    font-family: var(--font-mono);
}

/* --- Component Specific UI - Turbine --- */
.turbine-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.camera-container {
    background: #000;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    aspect-ratio: 4/3;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.webcam-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror camera */
}

.cam-fallback {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-muted);
    padding: 20px;
    text-align: center;
}

.cam-fallback i {
    font-size: 3rem;
    margin-bottom: 10px;
}

.ml-training-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.class-card {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.class-info h4 {
    font-size: 0.95rem;
    color: var(--text-highlight);
}

.class-sample-count {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--primary);
}

.class-actions {
    display: flex;
    gap: 8px;
}

.turbine-preview-pane {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.turbine-rotor-container {
    position: relative;
    width: 200px;
    height: 200px;
    margin-bottom: 20px;
}

.turbine-tower {
    position: absolute;
    bottom: 0;
    left: calc(50% - 6px);
    width: 12px;
    height: 110px;
    background: linear-gradient(90deg, #334155 0%, #1e293b 100%);
    border-radius: 6px 6px 0 0;
    z-index: 1;
}

.turbine-rotor {
    position: absolute;
    top: 15px;
    left: calc(50% - 75px);
    width: 150px;
    height: 150px;
    z-index: 2;
}

.turbine-rotor::before {
    /* Hub */
    content: '';
    position: absolute;
    top: calc(50% - 12px);
    left: calc(50% - 12px);
    width: 24px;
    height: 24px;
    background: #64748b;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    z-index: 5;
}

.blade {
    position: absolute;
    left: calc(50% - 5px);
    width: 10px;
    height: 75px;
    background: #e2e8f0;
    border-radius: 5px;
    transform-origin: bottom center;
}
.blade-1 { transform: rotate(0deg); }
.blade-2 { transform: rotate(120deg); }
.blade-3 { transform: rotate(240deg); }

.turbine-meta-stats {
    width: 100%;
}

.simulator-controller {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 16px;
    margin-top: 15px;
}

/* --- Component Specific UI - Technician --- */
.tech-desktop {
    background: #111827;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    height: 500px;
    display: grid;
    grid-template-columns: 200px 1fr;
    overflow: hidden;
}

.tech-sidebar {
    background: rgba(15, 23, 42, 0.8);
    border-right: 1px solid var(--border-color);
    padding: 16px;
}

.tech-sidebar-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 12px;
    letter-spacing: 1px;
}

.tech-folder-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.folder-item:hover, .folder-item.active {
    background: rgba(14, 165, 233, 0.1);
    color: var(--text-highlight);
}

.folder-item.active i {
    color: var(--primary);
}

.tech-files-view {
    padding: 20px;
    overflow-y: auto;
}

.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 20px;
}

.file-icon-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    text-align: center;
    padding: 10px;
    border-radius: 6px;
    transition: var(--transition);
}

.file-icon-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-highlight);
}

.file-icon-btn i {
    font-size: 2.2rem;
    color: #eab308; /* Folder/File Yellow */
}

.file-icon-btn.pdf-file i {
    color: #ef4444; /* PDF Red */
}

.file-label {
    font-size: 0.75rem;
    word-break: break-word;
}

/* Document Viewer Modal */
.doc-viewer-modal {
    position: absolute;
    top: 20px;
    left: 220px;
    right: 20px;
    bottom: 20px;
    background: var(--bg-surface-opaque);
    border: 1px solid var(--primary);
    border-radius: 8px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}

.doc-viewer-header {
    background: rgba(15, 23, 42, 0.9);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.doc-viewer-header h3 {
    font-size: 0.95rem;
    color: var(--text-highlight);
    display: flex;
    align-items: center;
    gap: 8px;
}

.doc-viewer-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    font-size: 0.9rem;
}

.doc-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 0.85rem;
}

.doc-table th, .doc-table td {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.doc-table th {
    background: rgba(15, 23, 42, 0.8);
    color: var(--primary);
    font-weight: 600;
}

.doc-table tr:nth-child(even) td {
    background: rgba(15, 23, 42, 0.3);
}

/* --- Component Specific UI - Programmer --- */
.programmer-workspace {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 20px;
    height: 520px;
    background: #0d131f;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.blocks-toolbox {
    background: rgba(15, 23, 42, 0.8);
    border-right: 1px solid var(--border-color);
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toolbox-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.toolbox-block {
    background: #1e293b;
    border-left: 4px solid var(--primary);
    border-radius: 4px;
    padding: 10px;
    font-size: 0.75rem;
    color: var(--text-highlight);
    cursor: grab;
    user-select: none;
    font-family: var(--font-mono);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toolbox-block.block-yellow { border-left-color: var(--warning); }
.toolbox-block.block-green { border-left-color: var(--success); }
.toolbox-block.block-red { border-left-color: var(--danger); }

.toolbox-block:hover {
    filter: brightness(1.2);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.1);
}

.dropzone-workspace {
    padding: 24px;
    overflow-y: auto;
    background: radial-gradient(rgba(30, 41, 59, 0.2) 1px, transparent 1px);
    background-size: 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: relative;
}

.dropzone-workspace::before {
    content: 'Arrastra y suelta los bloques de código aquí para configurar el sistema';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(148, 163, 184, 0.2);
    font-size: 1.1rem;
    font-weight: 600;
    max-width: 320px;
    text-align: center;
    pointer-events: none;
    z-index: 0;
}

.dropzone-workspace:has(.workspace-block)::before {
    display: none;
}

.workspace-block {
    background: #1e293b;
    border-radius: 6px;
    border-left: 6px solid var(--primary);
    padding: 14px 20px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-highlight);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    z-index: 1;
    position: relative;
    animation: slideIn 0.2s ease-out;
}

.workspace-block.block-yellow { border-left-color: var(--warning); }
.workspace-block.block-green { border-left-color: var(--success); }
.workspace-block.block-red { border-left-color: var(--danger); }

.workspace-block input, .workspace-block select {
    background: #0f172a;
    border: 1px solid var(--border-color);
    color: var(--success);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 4px;
    width: auto;
    display: inline-block;
}

.workspace-block select {
    padding-right: 20px;
}

.block-remove-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    margin-left: auto;
    font-size: 1.1rem;
    transition: var(--transition);
}

.block-remove-btn:hover {
    color: var(--danger);
}

.programmer-control-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

/* --- Component Specific UI - Energy Distributor --- */
.distributor-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 20px;
}

.city-map-container {
    background: #050811;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    position: relative;
    aspect-ratio: 16/10;
    overflow: hidden;
}

.grid-map-svg {
    width: 100%;
    height: 100%;
}

.zone-node {
    cursor: pointer;
}

.zone-node-circle {
    fill: rgba(15, 23, 42, 0.8);
    stroke: var(--border-color);
    stroke-width: 2;
    transition: var(--transition);
}

.zone-node:hover .zone-node-circle {
    stroke: var(--primary);
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.zone-text-lbl {
    font-family: var(--font-mono);
    font-size: 11px;
    fill: var(--text-muted);
    text-transform: uppercase;
}

.zone-text-val {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: bold;
    fill: var(--text-highlight);
}

/* State colors for map nodes */
.zone-node[data-state="iluminada"] .zone-node-circle { stroke: var(--success); fill: rgba(16, 185, 129, 0.1); }
.zone-node[data-state="iluminada"] .zone-text-val { fill: var(--success); }

.zone-node[data-state="parcial"] .zone-node-circle { stroke: var(--info); fill: rgba(14, 165, 233, 0.1); }
.zone-node[data-state="parcial"] .zone-text-val { fill: var(--info); }

.zone-node[data-state="critica"] .zone-node-circle { stroke: var(--warning); fill: rgba(245, 158, 11, 0.1); }
.zone-node[data-state="critica"] .zone-text-val { fill: var(--warning); }

.zone-node[data-state="sin_energia"] .zone-node-circle { stroke: var(--danger); fill: rgba(239, 68, 68, 0.15); }
.zone-node[data-state="sin_energia"] .zone-text-val { fill: var(--danger); }

/* Sliders control panel */
.sliders-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.zone-slider-group {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px 16px;
}

.slider-group-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.slider-label {
    font-weight: 600;
    color: var(--text-highlight);
}

.slider-pct {
    font-family: var(--font-mono);
    color: var(--primary);
    font-weight: bold;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 15px;
}

.cyber-range-input {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: rgba(30, 41, 59, 0.8);
    outline: none;
}

.cyber-range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 8px var(--primary-glow);
    transition: var(--transition);
}

.cyber-range-input::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider-meta-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
    display: flex;
    justify-content: space-between;
}

.emergency-gen-container {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 16px;
    margin-top: 15px;
}

.gen-list {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.gen-card-item {
    flex: 1;
    background: rgba(10, 15, 26, 0.6);
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.gen-card-item:hover:not(.disabled) {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.05);
}

.gen-card-item.active {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.gen-card-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-style: solid;
}

.gen-card-item i {
    font-size: 1.4rem;
    margin-bottom: 5px;
}

.gen-card-title {
    font-size: 0.7rem;
    font-weight: 600;
}

/* Zone Info Details inside sliders panel */
.distributor-totals-info {
    display: flex;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px 20px;
    font-size: 0.9rem;
}

.distributor-totals-info strong {
    font-family: var(--font-mono);
    color: var(--success);
}
.distributor-totals-info strong.deficit {
    color: var(--danger);
}
