/* Shared Styling */
.loading-spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid white;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Game Specific Styling */
.game-board {
    touch-action: none; 
    user-select: none;
    cursor: crosshair;
}
.wire-start {
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    transition: transform 0.1s ease;
}
.wire-start:hover {
    transform: scale(1.1);
}
.terminal {
    transition: box-shadow 0.3s ease;
    cursor: default;
}
.connected {
    box-shadow: 0 0 15px 5px var(--wire-color);
    border: 3px solid var(--wire-color);
    background-color: var(--wire-color-light);
}
.color-red { --wire-color: #ef4444; --wire-color-light: #fef2f2; }
.color-blue { --wire-color: #3b82f6; --wire-color-light: #eff6ff; }
.color-green { --wire-color: #22c55e; --wire-color-light: #f0fdf4; }
.color-yellow { --wire-color: #eab308; --wire-color-light: #fefce8; }
.color-purple { --wire-color: #a855f7; --wire-color-light: #f5f3ff; }
.color-orange { --wire-color: #f97316; --wire-color-light: #fff7ed; }

/* Keypad Game Styling */
.keypad-btn {
    transition: all 0.1s;
}
.keypad-btn:active {
    transform: scale(0.95);
    background-color: #4b5563;
}
.keypad-btn.lit {
    background-color: #fbbf24; /* amber-400 */
    color: black;
    border-color: #d97706;
    box-shadow: 0 0 25px #fbbf24;
    transform: scale(1.05);
}
.display-error {
    animation: flash-red-bg 0.5s ease;
    color: #fca5a5;
}
.display-success {
    color: #86efac;
}
@keyframes flash-red-bg {
    0%, 100% { background-color: black; }
    50% { background-color: #7f1d1d; }
}

/* Sliding Puzzle Styling */
.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    background-color: #172554; /* Deep Blue Border */
    padding: 4px;
    border-radius: 4px;
    width: 300px;
    height: 300px;
    border: 4px solid #1e40af;
}
.puzzle-tile {
    width: 100%;
    height: 100%;
    background-size: 300px 300px; /* Matches grid size */
    cursor: pointer;
    transition: transform 0.1s ease;
}
.puzzle-tile:active {
    transform: scale(0.95);
}
.puzzle-tile.empty {
    background: transparent !important;
    cursor: default;
}

/* Data Sort Styling */
.data-block {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 10px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.5);
    cursor: grab;
    user-select: none;
    touch-action: none;
    z-index: 10;
}
.data-block:active {
    cursor: grabbing;
    transform: scale(1.1);
    z-index: 20;
}
.data-bin {
    border: 2px dashed #4b5563;
    transition: all 0.2s;
}
.data-bin.highlight {
    background-color: rgba(255,255,255,0.1);
    border-color: white;
    transform: scale(1.05);
}

/* Pest Control Styling */
.bug {
    position: absolute;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: top 1s linear, left 1s linear; /* Smooth linear movement */
    z-index: 10;
    color: #84cc16; /* lime-500 */
}
.bug:active {
    transform: scale(0.9);
}
.bug-squished {
    color: #3f6212; /* lime-900 */
    transform: scale(1.2) rotate(45deg);
    pointer-events: none;
    opacity: 0.5;
    transition: opacity 0.5s ease;
}

/* Circuit Breaker Styling */
.breaker-switch {
    width: 40px;
    height: 80px;
    background-color: #374151;
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    border: 2px solid #1f2937;
    transition: background-color 0.2s;
}
.breaker-handle {
    width: 32px;
    height: 32px;
    background-color: #9ca3af;
    border-radius: 2px;
    position: absolute;
    left: 2px;
    transition: top 0.2s ease-in-out, background-color 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.breaker-switch.on .breaker-handle {
    top: 4px;
    background-color: #ef4444; 
}
.breaker-switch.off .breaker-handle {
    top: 40px;
    background-color: #4b5563;
}
.breaker-light {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #374151;
    border: 2px solid #1f2937;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
    transition: all 0.3s;
}
.breaker-light.active {
    background-color: #22c55e;
    box-shadow: 0 0 10px #22c55e, inset 0 0 5px white;
    border-color: #166534;
}

/* Dashboard Status Badge - Compact Version */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem; /* Fixed width circle */
    height: 1.5rem;
    border-radius: 9999px;
    font-weight: 800;
    font-size: 0.9rem;
}
.status-complete {
    background-color: #059669; /* emerald-600 */
    color: white;
    box-shadow: 0 0 5px rgba(5, 150, 105, 0.5);
}
.status-pending {
    background-color: #374151; /* gray-700 */
    color: #6b7280; /* gray-500 */
    border: 1px solid #4b5563;
    font-size: 0.7rem;
}

/* Pulse animation for updates */
@keyframes highlight-pulse {
    0% { background-color: #374151; }
    50% { background-color: #4b5563; }
    100% { background-color: #374151; }
}
.updating-row {
    animation: highlight-pulse 1s ease-in-out;
}

/* EMERGENCY ALARM ANIMATIONS */
@keyframes flash-red {
    0%, 100% { background-color: rgba(220, 38, 38, 0.9); }
    50% { background-color: rgba(153, 27, 27, 0.9); }
}
@keyframes pulse-icon {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}
#emergencyOverlay.active {
    display: flex;
    animation: flash-red 0.5s infinite;
}
.emergency-icon {
    animation: pulse-icon 0.5s infinite;
}

/* SUCCESS OVERLAY ANIMATIONS */
.success-overlay {
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes check-scale {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
.success-check {
    animation: check-scale 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* =========================================
   RETRO HUB STYLING (Scoped to #hubView)
   ========================================= */

.retro-hub-scope {
    font-family: 'JetBrains Mono', monospace, 'Courier New', Courier;
    background-color: #0a0a0a;
    color: #22c55e; /* Green-500 */
    /* Full screen override */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
    padding: 2rem;
}

/* CRT Scanlines */
.retro-hub-scope::before {
    content: " ";
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        to bottom,
        rgba(18, 16, 16, 0) 50%,
        rgba(0, 0, 0, 0.25) 50%
    );
    background-size: 100% 4px;
    z-index: 101;
    pointer-events: none;
}

/* Subtle Flicker */
.retro-hub-scope::after {
    content: " ";
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: rgba(18, 16, 16, 0.1);
    opacity: 0;
    z-index: 101;
    pointer-events: none;
    animation: flicker 0.15s infinite;
}

@keyframes flicker {
    0% { opacity: 0.02; }
    5% { opacity: 0.05; }
    10% { opacity: 0.01; }
    15% { opacity: 0.05; }
    25% { opacity: 0.02; }
    50% { opacity: 0.05; }
    70% { opacity: 0.02; }
    90% { opacity: 0.05; }
    100% { opacity: 0.02; }
}

/* Retro UI Elements */
.retro-border {
    border: 2px solid #15803d; /* Green-700 */
    background-color: #000;
    box-shadow: 0 0 15px rgba(21, 128, 61, 0.2);
    transition: all 0.2s ease-in-out;
}
.retro-border:hover {
    box-shadow: 0 0 25px rgba(34, 197, 94, 0.3);
    border-color: #22c55e;
}

.retro-header {
    border-bottom: 2px solid #22c55e;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.retro-btn {
    background-color: #14532d; /* Green-900 */
    color: #4ade80; /* Green-400 */
    border: 1px solid #22c55e;
    font-family: inherit;
    text-transform: uppercase;
    transition: all 0.2s;
    cursor: pointer;
}
.retro-btn:hover {
    background-color: #22c55e;
    color: #000;
    box-shadow: 0 0 10px #22c55e;
}

/* Recent Sessions Dropdown */
.retro-dropdown summary {
    list-style: none;
}
.retro-dropdown summary::-webkit-details-marker {
    display: none;
}

/* Scrollbar for Hub */
.retro-hub-scope ::-webkit-scrollbar {
    width: 8px;
}
.retro-hub-scope ::-webkit-scrollbar-track {
    background: #000;
    border-left: 1px solid #14532d;
}
.retro-hub-scope ::-webkit-scrollbar-thumb {
    background: #15803d;
    border: 1px solid #22c55e;
}

/* Dynamic Interaction for Retro Card */
/* When details is open, hide the description */
.retro-card:has(details[open]) .retro-description {
    display: none;
}

/* When details is open, switch from justify-between to justify-start to pack items upwards */
.retro-card:has(details[open]) {
    justify-content: flex-start;
    gap: 1rem;
}