/* JARVIS Futuristic HUD Theme */
:root {
    --bg-dark: #070a14;
    --bg-surface: rgba(14, 21, 37, 0.75);
    --bg-surface-hover: rgba(22, 33, 56, 0.85);
    --border-color: rgba(0, 242, 254, 0.2);
    --border-glow: rgba(0, 242, 254, 0.5);
    --cyan: #00f2fe;
    --electric-blue: #4facfe;
    --neon-green: #00ffa3;
    --neon-red: #ff3366;
    --neon-amber: #ffaa00;
    --text-primary: #f0f4fc;
    --text-secondary: #8c9bb5;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'Fira Code', monospace;
}

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

body {
    background: radial-gradient(circle at 10% 20%, #0d1527 0%, #060911 90%);
    color: var(--text-primary);
    font-family: var(--font-sans);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.hud-header {
    height: 64px;
    background: rgba(8, 12, 24, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
}

.hud-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hud-logo-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cyan), var(--electric-blue));
    box-shadow: 0 0 12px var(--cyan);
}

.hud-title {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 2px;
    color: var(--cyan);
}

.hud-subtitle {
    display: block;
    font-size: 10px;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.hud-quick-metrics {
    display: flex;
    gap: 16px;
}

.metric-pill {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    font-family: var(--font-mono);
    font-size: 12px;
}

.pill-label {
    color: var(--text-secondary);
    margin-right: 6px;
}

.pill-value {
    color: var(--cyan);
    font-weight: 600;
}

.hud-actions {
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 1px;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #00f2fe, #4facfe);
    color: #030712;
    font-weight: 700;
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.35);
}

.btn-primary:hover {
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.65);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(14, 25, 48, 0.7);
    border: 1px solid rgba(0, 242, 254, 0.28);
    color: var(--cyan);
}

.btn-secondary:hover {
    background: rgba(0, 242, 254, 0.15);
    border-color: var(--cyan);
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.25);
}

.btn-danger {
    background: linear-gradient(135deg, #ff3366, #ff0844);
    color: #fff;
    font-weight: 700;
    border: 1px solid rgba(255, 51, 102, 0.5);
}

.btn-danger:hover {
    box-shadow: 0 0 16px rgba(255, 51, 102, 0.7);
}

.btn-glow {
    box-shadow: 0 0 15px rgba(255, 51, 102, 0.5);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 11px;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    animation: pulse 1.2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.7; }
}

/* Layout */
.workspace-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar-nav {
    width: 240px;
    background: rgba(10, 15, 28, 0.85);
    border-right: 1px solid var(--border-color);
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.nav-tab:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.nav-tab.active {
    background: linear-gradient(90deg, rgba(0, 242, 254, 0.15), rgba(79, 172, 254, 0.05));
    border-left: 3px solid var(--cyan);
    color: var(--cyan);
}

.content-viewport {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    position: relative;
}

.tab-panel {
    display: none;
    animation: fadeIn 0.25s ease-in-out;
}

.tab-panel.active {
    display: block;
}

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

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Cards & Glassmorphism */
.glass-card {
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.telemetry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.metric-big {
    font-family: var(--font-mono);
    font-size: 32px;
    font-weight: 700;
    color: var(--cyan);
    margin: 12px 0 6px 0;
}

.meter-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.meter-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--cyan), var(--electric-blue));
    transition: width 0.3s ease;
}

.metric-sub {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Chat Component */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message-card {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.5;
}

.system-message, .assistant-message {
    align-self: flex-start;
    background: rgba(18, 28, 48, 0.8);
    border: 1px solid var(--border-color);
}

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(0, 198, 255, 0.2), rgba(0, 114, 255, 0.2));
    border: 1px solid rgba(0, 198, 255, 0.4);
}

.msg-author {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--cyan);
    margin-bottom: 6px;
}

.chat-input-bar {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: rgba(10, 15, 26, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-input-bar input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 12px 16px;
    color: #fff;
    font-family: var(--font-sans);
    outline: none;
}

.chat-input-bar input:focus {
    border-color: var(--cyan);
}

/* File explorer */
.file-explorer-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    height: calc(100vh - 200px);
}

.file-tree {
    list-style: none;
    margin-top: 12px;
    overflow-y: auto;
    max-height: calc(100% - 40px);
}

.file-tree li {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 13px;
    color: var(--text-secondary);
}

.file-tree li:hover {
    background: var(--bg-surface-hover);
    color: var(--cyan);
}

.code-view {
    font-family: var(--font-mono);
    font-size: 12px;
    color: #c9d8f0;
    overflow: auto;
    height: 100%;
}

/* Audit log viewer */
.audit-log-viewer {
    font-family: var(--font-mono);
    font-size: 12px;
    background: rgba(0, 0, 0, 0.4);
    padding: 16px;
    border-radius: 8px;
    max-height: 500px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.audit-entry {
    padding: 8px;
    border-left: 3px solid var(--cyan);
    background: rgba(255, 255, 255, 0.02);
}

.audit-entry.CRITICAL, .audit-entry.SECURITY_ALERT {
    border-left-color: var(--neon-red);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(3, 5, 10, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    width: 400px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input, select {
    width: 100%;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #fff;
    font-family: var(--font-sans);
}

.btn-block {
    width: 100%;
}

.error-text {
    color: var(--neon-red);
    font-size: 12px;
    margin-top: 8px;
}

.badge {
    background: var(--neon-red);
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-family: var(--font-mono);
}

.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.full-width { width: 100%; }

/* Remote Desktop & Web AnyDesk Styles */
#remote-viewport-container {
    touch-action: none;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
}

#remote-screen-img {
    touch-action: none;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
}

#remote-viewport-container:fullscreen {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border: none;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

#remote-viewport-container:fullscreen #remote-screen-img {
    max-height: 100vh;
    width: auto;
}

/* Quick Action Command Pills */
.pill-btn {
    background: rgba(0, 242, 254, 0.08);
    border: 1px solid rgba(0, 242, 254, 0.3);
    color: var(--cyan);
    padding: 5px 12px;
    border-radius: 14px;
    font-size: 11px;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.pill-btn:hover {
    background: rgba(0, 242, 254, 0.2);
    border-color: var(--cyan);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.4);
    transform: translateY(-1px);
}

/* Remote Workstation Unlock Toolbar & Power Controls */
.remote-unlock-toolbar {
    transition: all 0.25s ease;
}
.remote-unlock-toolbar:focus-within {
    border-color: var(--cyan) !important;
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.25);
}

/* Mobile Virtual Keyboard & Touchpad Dock */
#mobile-keyboard-dock {
    transition: all 0.3s ease;
}
#mobile-keyboard-dock .remote-hotkey,
#mobile-keyboard-dock .remote-combo {
    transition: all 0.15s ease;
}
#mobile-keyboard-dock .remote-hotkey:active,
#mobile-keyboard-dock .remote-combo:active {
    transform: scale(0.95);
    background: rgba(0, 242, 254, 0.3);
}

/* Form Inputs Cyber Styling */
input[type="text"], input[type="password"] {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input[type="text"]:focus, input[type="password"]:focus {
    border-color: var(--cyan) !important;
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.4) !important;
    outline: none;
}

/* =========================================================================
   RESPONSIVE DESIGN & MEDIA QUERIES (Mobile, Tablet, Desktop, Landscape)
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. TABLET BREAKPOINT (max-width: 1024px)
   ------------------------------------------------------------------------- */
@media screen and (max-width: 1024px) {
    .hud-header {
        padding: 0 16px;
    }

    .sidebar-nav {
        width: 200px;
        padding: 12px 6px;
    }

    .nav-tab {
        padding: 10px 12px;
        font-size: 12px;
        gap: 8px;
    }

    .content-viewport {
        padding: 16px;
    }

    .telemetry-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        gap: 14px;
    }

    .file-explorer-layout {
        grid-template-columns: 240px 1fr;
        gap: 14px;
    }

    .hud-quick-metrics {
        gap: 8px;
    }

    .metric-pill {
        padding: 4px 8px;
        font-size: 11px;
    }
}

/* -------------------------------------------------------------------------
   2. MOBILE BREAKPOINT (max-width: 768px)
   ------------------------------------------------------------------------- */
@media screen and (max-width: 768px) {
    body {
        height: 100dvh;
        overflow-x: hidden;
    }

    /* Fluid Header with Wrapping */
    .hud-header {
        height: auto;
        min-height: 56px;
        padding: 10px 14px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .hud-brand {
        gap: 8px;
    }

    .hud-title {
        font-size: 14px;
        letter-spacing: 1px;
    }

    .hud-subtitle {
        display: none; /* Hide subtitle to keep mobile header clean */
    }

    /* Horizontal scrollable metrics bar on mobile */
    .hud-quick-metrics {
        width: 100%;
        order: 3;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 4px 0 2px 0;
        gap: 8px;
        scrollbar-width: none;
    }

    .hud-quick-metrics::-webkit-scrollbar {
        display: none;
    }

    .metric-pill {
        flex-shrink: 0;
        padding: 4px 10px;
        font-size: 11px;
    }

    .hud-actions {
        order: 2;
        gap: 6px;
        margin-left: auto;
    }

    .hud-actions .btn {
        padding: 5px 8px;
        font-size: 10px;
        letter-spacing: 0.5px;
    }

    #btn-emergency-stop {
        padding: 5px 10px;
        font-size: 10px;
    }

    /* Responsive Workspace Layout: Column layout with top horizontal tab bar */
    .workspace-layout {
        flex-direction: column;
        flex: 1;
        overflow: hidden;
    }

    .sidebar-nav {
        width: 100%;
        height: auto;
        flex-direction: row;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 6px 8px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        gap: 6px;
        white-space: nowrap;
        background: rgba(10, 15, 28, 0.95);
        scrollbar-width: none;
        flex-shrink: 0;
    }

    .sidebar-nav::-webkit-scrollbar {
        display: none;
    }

    .nav-tab {
        flex-shrink: 0;
        padding: 8px 12px;
        border-radius: 20px;
        font-size: 12px;
        gap: 6px;
        border-left: none !important;
        background: rgba(255, 255, 255, 0.03);
    }

    .nav-tab.active {
        background: linear-gradient(135deg, rgba(0, 242, 254, 0.25), rgba(79, 172, 254, 0.15));
        border: 1px solid var(--cyan) !important;
        color: var(--cyan);
        box-shadow: 0 0 10px rgba(0, 242, 254, 0.2);
    }

    .content-viewport {
        padding: 12px 10px;
        overflow-y: auto;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 14px;
        padding-bottom: 8px;
    }

    .panel-header h2 {
        font-size: 16px;
    }

    /* Cards & Grids */
    .glass-card {
        padding: 14px 12px;
        border-radius: 10px;
    }

    .telemetry-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .metric-big {
        font-size: 24px;
    }

    /* AI Command & Chat Container */
    .chat-container {
        height: calc(100dvh - 210px);
        border-radius: 8px;
    }

    .chat-messages {
        padding: 12px 8px;
        gap: 10px;
    }

    .message-card {
        max-width: 94%;
        padding: 10px 12px;
        font-size: 13px;
        border-radius: 8px;
    }

    .chat-input-bar {
        padding: 10px 8px;
        gap: 8px;
    }

    .chat-input-bar input {
        padding: 10px 12px;
        font-size: 14px; /* Prevents auto-zoom in mobile Safari */
    }

    .quick-command-pills {
        overflow-x: auto;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        scrollbar-width: none;
    }

    .quick-command-pills::-webkit-scrollbar {
        display: none;
    }

    .pill-btn {
        flex-shrink: 0;
        padding: 5px 10px;
        font-size: 11px;
    }

    /* Remote Desktop / Web AnyDesk Mobile Tuning */
    #remote-viewport-container {
        min-height: 240px;
        max-height: 52vh;
        border-radius: 6px;
    }

    #remote-viewport-container #remote-screen-placeholder {
        padding: 40px 12px;
    }

    #remote-viewport-container #remote-screen-placeholder h3 {
        font-size: 15px;
    }

    #remote-viewport-container #remote-screen-placeholder p {
        font-size: 12px;
    }

    /* Remote Desktop Hotkeys Grid */
    .remote-hotkey, .remote-combo {
        padding: 6px 8px !important;
        font-size: 11px !important;
        flex: 1 1 calc(25% - 6px);
        text-align: center;
    }

    /* File Explorer Mobile Single Column */
    .file-explorer-layout {
        grid-template-columns: 1fr;
        height: auto;
        gap: 12px;
    }

    .code-view {
        min-height: 250px;
        max-height: 380px;
    }

    /* Modals Responsive */
    .modal-card {
        width: 92vw;
        max-width: 380px;
        padding: 18px 14px;
        margin: auto;
    }

    .form-group input, .form-group select {
        padding: 10px 12px;
        font-size: 16px; /* Prevents iOS auto-zoom */
    }
}

/* -------------------------------------------------------------------------
   3. SMALL SMARTPHONES (max-width: 480px)
   ------------------------------------------------------------------------- */
@media screen and (max-width: 480px) {
    .hud-title {
        font-size: 13px;
    }

    .hud-logo-icon {
        width: 20px;
        height: 20px;
    }

    .btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    .hud-actions #btn-voice-toggle {
        display: none; /* Hide toggle text on narrow screens; voice icon in chat bar remains */
    }

    .message-card {
        max-width: 98%;
        font-size: 12.5px;
    }

    .cards-grid {
        grid-template-columns: 1fr !important;
    }
}

/* -------------------------------------------------------------------------
   4. MOBILE LANDSCAPE ORIENTATION (max-height: 520px and orientation: landscape)
   ------------------------------------------------------------------------- */
@media screen and (max-height: 520px) and (orientation: landscape) {
    .hud-header {
        min-height: 44px;
        height: 44px;
        padding: 0 12px;
    }

    .hud-quick-metrics {
        display: none; /* Maximize vertical height for remote desktop or terminal */
    }

    .workspace-layout {
        flex-direction: row;
    }

    .sidebar-nav {
        width: 68px;
        flex-direction: column;
        padding: 6px 4px;
        overflow-y: auto;
        white-space: normal;
    }

    .nav-tab {
        padding: 8px 4px;
        flex-direction: column;
        gap: 2px;
        font-size: 9px;
        text-align: center;
    }

    .nav-tab .nav-icon {
        font-size: 16px;
    }

    .content-viewport {
        padding: 8px 12px;
    }

    .chat-container {
        height: calc(100dvh - 80px);
    }

    #remote-viewport-container {
        min-height: 200px;
        max-height: 75vh;
    }
}

/* -------------------------------------------------------------------------
   5. TOUCHSCREEN COARSE POINTER ACCESSIBILITY
   ------------------------------------------------------------------------- */
@media (hover: none) and (pointer: coarse) {
    /* Touch target comfort */
    button, .btn, .nav-tab, .pill-btn {
        min-height: 34px;
        touch-action: manipulation;
    }

    .btn-sm {
        min-height: 28px;
    }

    /* Prevent accidental text highlight on mobile touch navigation */
    .hud-header, .sidebar-nav, .nav-tab, .pill-btn {
        -webkit-tap-highlight-color: transparent;
        user-select: none;
    }
}
