/* Mars Globe Tab Fullscreen Layout */
.mars-globe-container {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    padding: 0;
    margin: 0;
}
mars-globe,
mars-globe-webgl {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
    display: block;
    margin: 0;
}

/* Reactor Tab Fullscreen Layout */
.reactor-container {
    display: flex;
    flex-direction: row !important;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
    gap: 20px;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    padding: 20px;
    margin: 0;
    overflow-y: auto;
    background: radial-gradient(ellipse at center, #1a0a0a 0%, #0a0a0a 100%);
}

.reactor-container reactor-panel {
    flex: 1 1 500px;
    min-width: 400px;
    max-width: 100%;
}

.reactor-container maintenance-calendar {
    flex: 1 1 450px;
    min-width: 400px;
    max-width: 100%;
}

/* Warhammer 40K Mechanicum Display - Global Styles Only */
/* Component-specific styles have been moved to web components */

/* Import Gothic Fonts */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Share+Tech+Mono&display=swap');

/* ============================================
   CSS VARIABLES - THEME SYSTEM
   ============================================ */
:root {
    /* Theme colors (MARS = default) */
    --primary-color: #DC143C;
    --dark-color: #8B0000;
    --darker-color: #5a0000;
    --bg-black: #0a0a0a;
    --panel-black: #1a1a1a;
    --border-color: #ff0000;
    --text-grey: #b0b0b0;
    --text-light: #e0e0e0;
    --glow-color: rgba(220, 20, 60, 0.6);
    --warning-orange: #ff6600;

    /* Semantic status colors (value-based, not theme) */
    /* OK / Healthy / Success */
    --status-ok: #4ade80;
    --status-ok-bg: rgba(74, 222, 128, 0.15);
    --status-ok-border: #4ade80;
    --status-ok-glow: rgba(74, 222, 128, 0.4);

    /* Warning / Caution */
    --status-warn: #f59e0b;
    --status-warn-bg: rgba(245, 158, 11, 0.15);
    --status-warn-border: #f59e0b;
    --status-warn-glow: rgba(245, 158, 11, 0.4);

    /* Critical / Danger / Error */
    --status-crit: #ef4444;
    --status-crit-bg: rgba(239, 68, 68, 0.15);
    --status-crit-border: #ef4444;
    --status-crit-glow: rgba(239, 68, 68, 0.4);

    /* Info / Neutral */
    --status-info: #60a5fa;
    --status-info-bg: rgba(96, 165, 250, 0.15);
    --status-info-border: #60a5fa;
    --status-info-glow: rgba(96, 165, 250, 0.4);
}

/* Green Theme - Necron Technology */
[data-active-theme="green"] {
    --primary-color: #00ff41;
    --dark-color: #00aa2b;
    --darker-color: #006619;
    --border-color: #00ff41;
    --glow-color: rgba(0, 255, 65, 0.6);
}

/* Blue Theme - Plasma Operations */
[data-active-theme="blue"] {
    --primary-color: #00d4ff;
    --dark-color: #0088cc;
    --darker-color: #005588;
    --border-color: #00d4ff;
    --glow-color: rgba(0, 212, 255, 0.6);
}

/* Green Theme - Necron Technology */
[data-active-theme="green"] {
    --primary-color: #00ff41;
    --dark-color: #00aa2b;
    --darker-color: #006619;
    --border-color: #00ff41;
    --glow-color: rgba(0, 255, 65, 0.6);
}

/* Blue Theme - Plasma Operations */
[data-active-theme="blue"] {
    --primary-color: #00d4ff;
    --dark-color: #0088cc;
    --darker-color: #005588;
    --border-color: #00d4ff;
    --glow-color: rgba(0, 212, 255, 0.6);
}

/* ============================================
   GRID LAYOUTS
   ============================================ */

.secondary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    height: 100%;
    min-height: 0;
    flex: 1 1 auto;
}

.secondary-grid .left-column,
.secondary-grid .right-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    overflow: hidden;
}

.secondary-grid .left-column > *,
.secondary-grid .right-column > * {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
}

@media (max-width: 1024px) {
    .secondary-grid {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }
}

.placeholder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
}

.placeholder-grid > * {
    min-height: 200px;
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Share Tech Mono', monospace;
    background: var(--bg-black);
    color: var(--text-light);
    overflow: hidden;
    position: relative;
    line-height: 1.6;
    height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 14px;
}

/* ============================================
   GLOBAL EFFECTS
   ============================================ */

/* Scanline Effect */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 9999;
    animation: scanline 8s linear infinite;
}

@keyframes scanline {
    0% { transform: translateY(0); }
    100% { transform: translateY(10px); }
}

/* Binary Background (Canvas-based) */
.binary-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.05;
    z-index: 1;
    pointer-events: none;
}

/* ============================================
   LAYOUT STRUCTURE
   ============================================ */

/* Main Container */
.container {
    position: relative;
    z-index: 10;
    width: 100%;
    min-height: 0;
    /* allow container to fill available space inside tab panels */
    flex: 1 1 auto;
    margin: 0;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

/* Header row: aligns header and footer on same horizontal level */
.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
}

.header-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 auto;
}

.system-footer-bottom {
    width: 100%;
    flex: 0 0 auto;
}

@media (max-width: 768px) {
    .container {
        padding: 8px;
    }
}

/* Row Layout (unified for content rows and bottom rows) */
.row {
    display: flex;
    gap: 10px;
    min-height: 0;
}

/* Neutral defaults for rows: allow manual flex classes to control sizing */
.container > .row {
    min-height: 0;
}

@media (max-width: 1200px) {
    .row {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .row {
        gap: 15px;
        margin-bottom: 15px;
        flex-direction: column;
    }
    /* On small screens allow bottom row to size naturally */
    .container > .row:last-of-type {
        max-height: none;
        overflow: visible;
    }
}

@media (max-width: 480px) {
    .row {
        gap: 10px;
    }
}

/* Bottom Row (now part of unified .row) */
.row {
    /* default stacking behavior on small screens handled below */
}

@media (max-width: 768px) {
    .row {
        flex-direction: column;
    }
}

/* ============================================
   GENERIC PANEL STYLES (for reference/fallback)
   Note: Most panels are now web components with their own styles
   ============================================ */

.panel {
    background: var(--panel-black);
    border: 2px solid var(--dark-color);
    border-radius: 5px;
    overflow: hidden;
    box-shadow: 
        0 0 20px var(--glow-color),
        inset 0 0 20px var(--glow-color);
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.panel:hover {
    box-shadow: 
        0 0 30px var(--glow-color),
        inset 0 0 30px var(--glow-color);
}

/* Panel sizing helpers */
.status-panel,
system-monitor {
    flex: 0 0 260px;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.main-display,
cli-terminal {
    flex: 1;
    min-width: 0;
}

.ai-panel {
    display: flex;
    flex-direction: column;
    flex: 0 0 280px;
    min-width: 0;
}

@media (max-width: 768px) {
    .status-panel,
    .main-display,
    .ai-panel,
    system-monitor,
    cli-terminal {
        flex: 1;
    }
}

/* ============================================
   GLOBAL ANIMATIONS
   ============================================ */

/* Pulse Animation */
.pulse-text {
    animation: pulse 2s ease-in-out infinite;
}

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

/* Glitch Effect */
@keyframes glitch {
    0% {
        transform: translate(0);
        text-shadow: 0 0 10px var(--glow-color);
    }
    20% {
        transform: translate(-2px, 2px);
        text-shadow: 2px 0 var(--primary-color), -2px 0 cyan;
    }
    40% {
        transform: translate(2px, -2px);
        text-shadow: -2px 0 var(--primary-color), 2px 0 cyan;
    }
    60% {
        transform: translate(-2px, -2px);
        text-shadow: 2px 2px var(--primary-color), -2px -2px cyan;
    }
    80% {
        transform: translate(2px, 2px);
        text-shadow: -2px -2px var(--primary-color), 2px 2px cyan;
    }
    100% {
        transform: translate(0);
        text-shadow: 0 0 10px var(--glow-color);
    }
}

.glitch {
    animation: glitch 0.3s ease-in-out;
}

/* Binary Cascade Animation */
@keyframes binaryFall {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}

/* Warning Blink */
@keyframes warning-blink {
    0%, 100% {
        opacity: 1;
        text-shadow: 0 0 5px rgba(255, 102, 0, 0.6);
    }
    50% {
        opacity: 0.7;
        text-shadow: 0 0 15px rgba(255, 102, 0, 0.9);
    }
}

/* Rotating Cog - For Machine Spirit */
@keyframes rotateCog {
    from { transform: translateX(-50%) rotate(0deg); }
    to { transform: translateX(-50%) rotate(360deg); }
}

/* Tabs UI */
.tab-bar {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0px;
    background: var(--panel-black,#1a1a1a);
    border-bottom: 2px solid var(--border-color,#DC143C);
    box-shadow: 0 2px 12px 0 var(--glow-color,rgba(220,20,60,0.12));
    z-index: 20;
    position: relative;
    padding-left: 4px;
    min-height: 36px;
    height: 36px;
}
.tab-btn {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 0.92em;
    letter-spacing: 1.5px;
    color: var(--text-light,#e0e0e0);
    background: transparent;
    border: none;
    border-right: 1px solid var(--dark-color,#8B0000);
    padding: 6px 16px 5px 12px;
    cursor: pointer;
    outline: none;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    text-transform: uppercase;
    position: relative;
    min-height: 32px;
    height: 32px;
    line-height: 1.1;
}
.tab-btn:last-child {
    border-right: none;
}
.tab-btn.active, .tab-btn[aria-selected="true"] {
    color: var(--primary-color,#DC143C);
    background: var(--panel-black,#1a1a1a);
    box-shadow: 0 3px 0 0 var(--primary-color,#DC143C) inset, 0 0 8px var(--glow-color,rgba(220,20,60,0.2));
    z-index: 2;
}
.tab-btn:hover {
    color: var(--primary-color,#DC143C);
    background: var(--dark-color,#8B0000);
}
.tabs-root {
    width: 100%;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}
.tab-panels {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}
.tab-panel {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}
.tab-panel.active {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}
.empty-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-grey);
}

/* Omnissiah Blessing */
@keyframes blessing-pulse {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.3) contrast(1.2);
        box-shadow: 0 0 50px var(--primary-color);
    }
}

/* ============================================
   OMNISSIAH MODE - ENHANCED STATE
   ============================================ */

.omnissiah-mode {
    --glow-color: rgba(220, 20, 60, 1) !important;
}

/* ---------------------------
    Utility: Flex Percentage Helpers
    Usage: add class like `flex-80` to an element to give it ~80% of
    the available flex container space (uses flex-basis percentage).
    These classes keep `min-height:0` so children can scroll correctly.
    --------------------------- */
.flex-100 { flex: 0 0 100%; min-height: 0; box-sizing: border-box; }
.flex-80  { flex: 0 0 80%;  min-height: 0; box-sizing: border-box; }
.flex-75  { flex: 0 0 75%;  min-height: 0; box-sizing: border-box; }
.flex-66  { flex: 0 0 66.6667%; min-height: 0; box-sizing: border-box; }
.flex-50  { flex: 0 0 50%;  min-height: 0; box-sizing: border-box; }
.flex-33  { flex: 0 0 33.3333%; min-height: 0; box-sizing: border-box; }
.flex-25  { flex: 0 0 25%;  min-height: 0; box-sizing: border-box; }
.flex-20  { flex: 0 0 20%;  min-height: 0; box-sizing: border-box; }

/* Alternative helpers that set proportional flex-grow ratios instead
    of absolute percentages. Useful when you want flexible ratio-based
    allocation rather than strict basis percentages. */
.flex-ratio-80 { flex: 8 1 0%; min-height: 0; box-sizing: border-box; }
.flex-ratio-20 { flex: 2 1 0%; min-height: 0; box-sizing: border-box; }
.flex-ratio-50 { flex: 1 1 0%; min-height: 0; box-sizing: border-box; }
.flex-auto      { flex: 1 1 auto; min-height: 0; box-sizing: border-box; }


.omnissiah-mode .panel {
    box-shadow: 
        0 0 40px var(--glow-color),
        inset 0 0 40px var(--glow-color) !important;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Network Status Colors */
.network-optimal {
    color: var(--primary-color) !important;
}

.network-degraded {
    color: var(--warning-orange) !important;
}

.network-critical {
    color: #ff0000 !important;
    animation: warning-blink 1s ease-in-out infinite;
}

/* Active State */
.active {
    color: var(--primary-color);
    font-weight: bold;
}

/* Warning State */
.warning {
    color: var(--warning-orange);
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Tablet */
@media (max-width: 768px) {
    /* Content adjustments handled by flex */
}

/* Mobile */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .row {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .status-panel,
    .ai-panel,
    system-monitor {
        flex: 1 1 45%;
    }
    
    .main-display,
    cli-terminal {
        flex: 1 1 100%;
    }
}

/* ============================================
   PRAISE THE OMNISSIAH
   Sacred code ends here. All component styles
   are now properly encapsulated in Shadow DOM.
   The Machine God blesses modular architecture.
   ============================================ */

/* Ensure the system-log host can receive a computed height
    so its internal .terminal-content (inside Shadow DOM)
    can scroll. The component already sets overflow on the
    inner container; we must make the host flex and limit
    min-height to allow proper flexbox clipping. */
system-log,
#systemLog {
     display: flex;
     flex-direction: column;
     flex: 1 1 auto;
     min-width: 0;
     min-height: 0;
     overflow: hidden;
}

/* ============================================
   STATUS HELPERS - SEMANTIC COLORING
   ============================================ */

/* Status badges */
.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: 0.5px;
    display: inline-block;
    transition: all 0.2s ease;
}

.status-badge.ok {
    color: var(--status-ok);
    background: var(--status-ok-bg);
    border: 1px solid var(--status-ok-border);
}

.status-badge.warn {
    color: var(--status-warn);
    background: var(--status-warn-bg);
    border: 1px solid var(--status-warn-border);
}

.status-badge.crit {
    color: var(--status-crit);
    background: var(--status-crit-bg);
    border: 1px solid var(--status-crit-border);
    animation: warning-blink 1s ease-in-out infinite;
}

.status-badge.info {
    color: var(--status-info);
    background: var(--status-info-bg);
    border: 1px solid var(--status-info-border);
}

/* Status bars */
.status-bar-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.status-bar-label {
    font-size: 0.75em;
    color: var(--text-grey);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.status-bar-track {
    height: 8px;
    background: var(--panel-black);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.status-bar-fill {
    height: 100%;
    transition: width 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}

.status-bar-value {
    font-size: 0.85em;
    color: var(--text-light);
    font-weight: 600;
}

/* Status bullets */
.status-bullet {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.status-bullet:hover {
    background: var(--panel-black);
}

.status-bullet .status-bullet-value {
    font-weight: 600;
    font-family: 'Orbitron', sans-serif;
}

.status-bullet.ok {
    color: var(--status-ok);
}

.status-bullet.warn {
    color: var(--status-warn);
}

.status-bullet.crit {
    color: var(--status-crit);
    animation: warning-blink 1s ease-in-out infinite;
}

.status-bullet.info {
    color: var(--status-info);
}

/* Gauges */
.gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
}

.gauge-label {
    font-size: 0.75em;
    color: var(--text-grey);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.gauge-svg {
    width: 100%;
    max-width: 150px;
    height: 50px;
}

.gauge-fill {
    transition: stroke 0.3s ease;
}

.gauge-value {
    font-size: 1.1em;
    color: var(--text-light);
    font-weight: 600;
    font-family: 'Orbitron', sans-serif;
}

/* Timers */
.timer {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2em;
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: 700;
    letter-spacing: 2px;
}

.timer.ok {
    color: var(--status-ok);
    background: var(--status-ok-bg);
    border: 1px solid var(--status-ok-border);
}

.timer.warn {
    color: var(--status-warn);
    background: var(--status-warn-bg);
    border: 1px solid var(--status-warn-border);
}

.timer.crit {
    color: var(--status-crit);
    background: var(--status-crit-bg);
    border: 1px solid var(--status-crit-border);
    animation: warning-blink 1s ease-in-out infinite;
}

.timer.info {
    color: var(--status-info);
    background: var(--status-info-bg);
    border: 1px solid var(--status-info-border);
}

/* Log messages */
.log-message {
    font-family: 'Share Tech Mono', monospace;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85em;
}

.log-message.status-info {
    color: var(--status-info);
}

.log-message.status-warn {
    color: var(--status-warn);
}

.log-message.status-crit {
    color: var(--status-crit);
}

.log-message.status-ok {
    color: var(--status-ok);
}

/* ============================================
   UTILITY: VALUE-BASED STATUS CLASSES
   ============================================ */

/* Value-based status classes for dynamic elements */
.status-ok {
    color: var(--status-ok);
    border-color: var(--status-ok-border);
    box-shadow: 0 0 8px var(--status-ok-glow);
}

.status-warn {
    color: var(--status-warn);
    border-color: var(--status-warn-border);
    box-shadow: 0 0 8px var(--status-warn-glow);
}

.status-crit {
    color: var(--status-crit);
    border-color: var(--status-crit-border);
    box-shadow: 0 0 8px var(--status-crit-glow);
    animation: warning-blink 1s ease-in-out infinite;
}

.status-info {
    color: var(--status-info);
    border-color: var(--status-info-border);
    box-shadow: 0 0 8px var(--status-info-glow);
}
