/* ========================================
   INTELLIGENT TERMINAL - CSS VARIABLES & BASE
   ======================================== */

:root {
    /* TUI Color Palette - Monochrome + Single Accent */
    --color-accent: #00FF41;
    --color-accent-dim: #00AA2B;
    --color-accent-glow: rgba(0, 255, 65, 0.4);

    /* Grayscale & Glass */
    --color-bg-primary: #05070a;
    /* Darker, richer black */
    --color-bg-secondary: rgba(22, 27, 34, 0.7);
    --color-bg-tertiary: rgba(33, 38, 45, 0.7);

    /* Glassmorphism Variables */
    --glass-bg: rgba(13, 17, 23, 0.65);
    --glass-border: rgba(48, 54, 61, 0.6);
    --glass-blur: 12px;
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

    --color-bg-panel: var(--glass-bg);
    /* Use glass for panels */

    --color-border: #30363d;
    --color-border-active: #00FF41;

    --color-text-primary: #e6edf3;
    /* Brighter text */
    --color-text-secondary: #8b949e;
    --color-text-dim: #484f58;

    /* Status Colors */
    --color-success: #00FF41;
    --color-warning: #FFB000;
    --color-error: #FF4444;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 24px;

    /* Typography */
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    --font-size-xs: 0.7rem;
    --font-size-sm: 0.8rem;
    --font-size-md: 0.9rem;
    --font-size-lg: 1rem;
    --font-size-xl: 1.2rem;

    /* Panel sizing - Desktop defaults */
    --header-height: 32px;
    --panel-header-height: 24px;
    --terminal-height: 120px;
    --navigator-width: 220px;
    --telemetry-width: 200px;
}

/* ========================================
   RESET & BASE
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    height: 100%;
    height: -webkit-fill-available;
}

body {
    font-family: var(--font-mono);
    font-size: var(--font-size-md);
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    line-height: 1.5;
    height: 100%;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Accessibility: Skip link */
.skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-accent);
    color: var(--color-bg-primary);
    padding: 8px 16px;
    text-decoration: none;
    font-weight: bold;
    z-index: 9999;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 10px;
}

/* Custom Selection */
::selection {
    background-color: var(--color-accent);
    color: var(--color-bg-primary);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-accent);
}

/* ========================================
   LOADING SCREEN
   ======================================== */

.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-bg-primary);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    padding: var(--spacing-md);
}

.loading-ascii {
    color: var(--color-accent);
    font-size: 0.5rem;
    line-height: 1.2;
    margin-bottom: var(--spacing-lg);
    text-shadow: 0 0 10px var(--color-accent-glow);
    white-space: pre;
}

.loading-text {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    margin-bottom: var(--spacing-md);
}

.loading-bar {
    width: 200px;
    max-width: 80vw;
    height: 4px;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    margin: 0 auto;
}

.loading-progress {
    height: 100%;
    background: var(--color-accent);
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px var(--color-accent-glow);
}

/* ========================================
   BACKGROUND CANVAS
   ======================================== */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.6;
}

/* ========================================
   TERMINAL CONTAINER
   ======================================== */

.terminal-container {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: transparent;
    /* Changed from variable to transparent */
    position: relative;
    z-index: 1;
}

/* ========================================
   HEADER BAR (tmux-style)
   ======================================== */

.terminal-header {
    height: var(--header-height);
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-sm);
    flex-shrink: 0;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.header-title {
    color: var(--color-accent);
    font-weight: 700;
    font-size: var(--font-size-xs);
    letter-spacing: 1px;
}

.header-separator {
    color: var(--color-text-dim);
    display: none;
}

.header-status {
    display: none;
}

/* ========================================
   WORKSPACES (i3bar style)
   ======================================== */

.workspaces {
    display: flex;
    align-items: center;
    gap: 2px;
}

.ws {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-dim);
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    padding: 1px 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.ws:hover {
    color: var(--color-text-secondary);
    border-color: var(--color-text-dim);
}

.ws.active {
    background: var(--color-accent);
    color: var(--color-bg-primary);
    border-color: var(--color-accent);
    font-weight: 500;
}

.ws.urgent {
    background: var(--color-warning);
    color: var(--color-bg-primary);
    border-color: var(--color-warning);
}

/* Hide workspace labels on very small screens */
@media (max-width: 480px) {
    .ws {
        padding: 1px 4px;
        font-size: 0.6rem;
    }
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
}

.status-dot {
    width: 6px;
    height: 6px;
    background: var(--color-accent);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.header-time {
    color: var(--color-text-dim);
    font-size: var(--font-size-xs);
}

/* ========================================
   LANGUAGE SWITCH
   ======================================== */

.lang-switch {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--color-text-secondary);
    transition: all 0.2s ease;
}

.lang-switch:hover {
    border-color: var(--color-accent);
}

.lang-switch:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.lang-en,
.lang-es {
    padding: 0 2px;
    transition: color 0.2s ease;
}

.lang-en {
    color: var(--color-accent);
}

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

.lang-toggle {
    width: 20px;
    height: 10px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 5px;
    position: relative;
    transition: all 0.2s ease;
}

.lang-toggle::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    width: 6px;
    height: 6px;
    background: var(--color-accent);
    border-radius: 50%;
    transition: transform 0.2s ease;
}

/* Spanish active state */
.lang-switch.es-active .lang-en {
    color: var(--color-text-dim);
}

.lang-switch.es-active .lang-es {
    color: var(--color-accent);
}

.lang-switch.es-active .lang-toggle::after {
    transform: translateX(10px);
}

/* Hide on very small screens */
@media (max-width: 320px) {
    .lang-switch {
        display: none;
    }
}

/* ========================================
   NEOFETCH STYLE (base - overridden in panels.css)
   ======================================== */

.neofetch-line {
    margin-bottom: var(--spacing-xs);
}

.nf-label {
    color: var(--color-accent);
    font-weight: 500;
}

.neofetch-separator {
    color: var(--color-text-dim);
    margin: var(--spacing-sm) 0;
}

.neofetch-status {
    margin: var(--spacing-md) 0;
}

.status-badge {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    border: 1px solid var(--color-accent);
    color: var(--color-accent);
    font-size: var(--font-size-xs);
    animation: borderPulse 3s infinite;
}

@keyframes borderPulse {

    0%,
    100% {
        border-color: var(--color-accent);
        box-shadow: 0 0 5px var(--color-accent-glow);
    }

    50% {
        border-color: var(--color-accent-dim);
        box-shadow: none;
    }
}

/* ========================================
   TABLET+ HEADER
   ======================================== */

@media (min-width: 768px) {
    html {
        font-size: 15px;
    }

    .terminal-header {
        padding: 0 var(--spacing-md);
    }

    .header-title {
        font-size: var(--font-size-sm);
    }

    .header-separator {
        display: inline;
    }

    .header-status {
        display: inline;
        color: var(--color-text-secondary);
        font-size: var(--font-size-xs);
    }

    .header-left,
    .header-right {
        gap: var(--spacing-md);
    }

    .loading-ascii {
        font-size: var(--font-size-xs);
    }

    .loading-bar {
        width: 300px;
    }
}

@media (min-width: 1024px) {
    html {
        font-size: 16px;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

@media (prefers-contrast: high) {
    :root {
        --color-border: #666;
        --color-text-secondary: #bbb;
    }
}

@media (prefers-color-scheme: light) {
    :root {
        color-scheme: dark;
    }
}

/* ========================================
   DUNST-STYLE NOTIFICATIONS
   ======================================== */

.notification-stack {
    position: fixed;
    top: calc(var(--header-height) + 8px);
    right: 8px;
    z-index: 900;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: none;
    max-width: 360px;
    width: 100%;
}

.dunst-notification {
    pointer-events: auto;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-accent);
    padding: 8px 12px;
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    color: var(--color-text-primary);
    animation: dunstSlideIn 0.2s ease;
    position: relative;
    overflow: hidden;
}

.dunst-notification.urgency-low {
    border-left-color: var(--color-text-dim);
    color: var(--color-text-secondary);
}

.dunst-notification.urgency-normal {
    border-left-color: var(--color-accent);
}

.dunst-notification.urgency-critical {
    border-left-color: var(--color-error);
    border-color: var(--color-error);
}

.dunst-notification .dunst-title {
    font-weight: 500;
    color: var(--color-accent);
    margin-bottom: 2px;
}

.dunst-notification.urgency-critical .dunst-title {
    color: var(--color-error);
}

.dunst-notification .dunst-body {
    color: var(--color-text-secondary);
}

.dunst-notification .dunst-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--color-accent);
    animation: dunstProgress var(--dunst-duration, 3s) linear forwards;
}

.dunst-notification.urgency-critical .dunst-progress {
    background: var(--color-error);
}

.dunst-notification.dunst-exit {
    animation: dunstSlideOut 0.2s ease forwards;
}

@keyframes dunstSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes dunstSlideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

@keyframes dunstProgress {
    from { width: 100%; }
    to { width: 0%; }
}

/* ========================================
   FLOATING WINDOWS (scratchpad)
   ======================================== */

.floating-window {
    position: fixed;
    z-index: 500;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 2px solid var(--color-accent);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5), 0 0 20px var(--color-accent-glow);
    display: flex;
    flex-direction: column;
    animation: floatingSlideIn 0.25s ease;
    border-radius: 4px;
}

.floating-window.floating-exit {
    animation: floatingSlideOut 0.2s ease forwards;
}

.floating-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    background: rgba(22, 27, 34, 0.8);
    border-bottom: 1px solid var(--glass-border);
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.floating-titlebar:active {
    cursor: grabbing;
}

.floating-title {
    font-size: var(--font-size-xs);
    color: var(--color-accent);
    font-weight: 500;
}

.floating-controls {
    display: flex;
    gap: 4px;
}

.floating-btn {
    background: none;
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    padding: 0 6px;
    cursor: pointer;
    line-height: 1.4;
    transition: all 0.15s ease;
}

.floating-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.floating-btn-close:hover {
    border-color: var(--color-error);
    color: var(--color-error);
}

.floating-body {
    flex: 1;
    overflow: auto;
    padding: 8px;
}

@keyframes floatingSlideIn {
    from { transform: translateY(-30px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes floatingSlideOut {
    from { transform: translateY(0) scale(1); opacity: 1; }
    to { transform: translateY(-30px) scale(0.95); opacity: 0; }
}

/* Scratchpad overlay backdrop */
.scratchpad-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 499;
    animation: fadeIn 0.2s ease;
}

/* ========================================
   TOUCH DEVICE OPTIMIZATIONS
   ======================================== */

@media (hover: none) and (pointer: coarse) {
    .skip-link:focus {
        top: 10px;
    }

    /* Scroll momentum */
    .panel-content,
    .terminal-output,
    .file-tree {
        -webkit-overflow-scrolling: touch;
    }
}