@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;700&family=Inter:wght@400;500;600;700;800&family=Orbitron:wght@500;700;900&display=swap');

/* ========================================
   Design Tokens
   ======================================== */
:root {
    --bg: #09090b;
    --panel-bg: rgba(17, 17, 24, 0.75);
    --panel-border: rgba(63, 63, 70, 0.4);
    --text-main: #f4f4f5;
    --text-muted: #a1a1aa;
    --accent: #00f0ff;
    --accent-glow: rgba(0, 240, 255, 0.25);
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --font-mono: 'Fira Code', 'Cascadia Code', monospace;
    --font-sans: 'Inter', system-ui, sans-serif;
    --sidebar-width: 300px;
    --intel-width: 360px;
}

/* ========================================
   Reset & Base
   ======================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg);
    color: var(--text-main);
    font-family: var(--font-sans);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-image:
        radial-gradient(at 0% 0%, rgba(0, 240, 255, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(108, 92, 231, 0.05) 0px, transparent 50%);
}

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

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ========================================
   Focus Styles (Accessibility)
   ======================================== */
.level-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    background: rgba(0, 240, 255, 0.05);
}

.action-btn:focus-visible,
.copy-btn:focus-visible,
.sidebar-toggle-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ========================================
   Header
   ======================================== */
#header {
    background: rgba(15, 15, 22, 0.9);
    backdrop-filter: blur(8px);
    padding: 10px 20px;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.sidebar-toggle-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.sidebar-toggle-btn:hover {
    background: rgba(0, 240, 255, 0.1);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

.logo {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    letter-spacing: 2px;
    font-size: 18px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo span {
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent-glow);
}

.header-middle {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    justify-content: center;
    max-width: 600px;
}

.progress-container {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-label {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.progress-bar-outer {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.progress-bar-inner {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #6c5ce7, var(--accent));
    box-shadow: 0 0 8px var(--accent-glow);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* ========================================
   Status Badge
   ======================================== */
.status-badge {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 6px 12px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    display: inline-block;
}

.status-badge.connected {
    border-color: var(--success);
    color: var(--success);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}

.status-badge.connected .status-dot {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse 2s infinite;
}

.status-badge.disconnected {
    border-color: var(--danger);
    color: var(--danger);
}

.status-badge.disconnected .status-dot {
    background: var(--danger);
}

.status-badge.linking {
    border-color: var(--warning);
    color: var(--warning);
}

.status-badge.linking .status-dot {
    background: var(--warning);
    animation: pulse 1s infinite;
}

/* ========================================
   Animations
   ======================================== */
@keyframes pulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========================================
   Layout
   ======================================== */
#main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ========================================
   Sidebar — Level Selector
   ======================================== */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    flex-shrink: 0;
}

.sidebar.collapsed {
    transform: translateX(-100%);
    margin-left: calc(-1 * var(--sidebar-width));
}

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

.sidebar-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-muted);
}

.level-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.category-group {
    margin-bottom: 15px;
}

.category-header {
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 20px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.category-line {
    flex: 1;
    height: 1px;
    background: var(--panel-border);
    margin-left: 10px;
}

.level-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 13px;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.level-item:hover {
    background: rgba(255, 255, 255, 0.03);
    border-left-color: rgba(255, 255, 255, 0.2);
}

.level-item.active {
    background: rgba(0, 240, 255, 0.05);
    border-left-color: var(--accent);
    color: var(--accent);
}

.level-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.level-number {
    font-family: var(--font-mono);
    font-weight: 700;
    width: 45px;
}

.level-label {
    color: var(--text-main);
    transition: color 0.2s ease;
}

.level-item.active .level-label {
    color: var(--accent);
    font-weight: 600;
}

/* Level Status Icons */
.level-status-icon {
    font-size: 11px;
}

.level-status-icon.completed {
    color: var(--success);
    opacity: 1;
    font-weight: bold;
}

.level-status-icon.has-creds {
    color: var(--success);
    opacity: 0.7;
}

.level-status-icon.no-creds {
    color: #555;
}

/* ========================================
   Terminal Area
   ======================================== */
#terminal-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #000;
    position: relative;
}

.terminal-wrapper {
    flex: 1;
    position: relative;
    background: #000;
}

#terminal-container {
    position: absolute;
    top: 15px;
    bottom: 15px;
    left: 15px;
    right: 15px;
    overflow: hidden;
}

.terminal-header {
    background: rgba(15, 15, 22, 0.8);
    border-bottom: 1px solid rgba(63, 63, 70, 0.2);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
}

.terminal-connection-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.terminal-server-badge {
    background: rgba(0, 240, 255, 0.1);
    color: var(--accent);
    border: 1px solid rgba(0, 240, 255, 0.2);
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 10px;
}

/* ========================================
   Intel Panel (Right Sidebar)
   ======================================== */
.intel-panel {
    width: var(--intel-width);
    background: rgba(15, 15, 22, 0.95);
    border-left: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    z-index: 50;
    flex-shrink: 0;
}

.intel-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--panel-border);
    background: rgba(0, 0, 0, 0.2);
    text-align: center;
}

.intel-header h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    letter-spacing: 3px;
    color: var(--text-main);
    font-weight: 700;
}

.intel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Intel Cards */
.intel-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
    transition: border-color 0.3s ease;
}

.intel-card:hover {
    border-color: rgba(0, 240, 255, 0.2);
}

.intel-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 6px;
}

.intel-card-title {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.category-badge {
    font-size: 9px;
    font-family: var(--font-sans);
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
}

.intel-text {
    font-size: 13px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.8);
}

/* ========================================
   Intel Panel — Extracted Inline Styles
   ======================================== */
.intel-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-muted);
}

.intel-empty-state .empty-title {
    font-family: var(--font-mono);
    font-size: 14px;
    margin-bottom: 10px;
}

.intel-empty-state .empty-subtitle {
    font-size: 12px;
}

.intel-notes-text {
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--warning);
    line-height: 1.5;
}

.no-creds-msg {
    color: var(--text-muted);
    font-size: 12px;
}

/* ========================================
   Completion Toggle
   ======================================== */
.completion-card {
    padding: 12px 15px;
}

.completion-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.completion-toggle input {
    display: none;
}

.completion-slider {
    width: 40px;
    height: 22px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--panel-border);
    border-radius: 11px;
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.completion-slider::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: var(--text-muted);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all 0.3s ease;
}

.completion-toggle input:checked + .completion-slider {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--success);
}

.completion-toggle input:checked + .completion-slider::after {
    background: var(--success);
    transform: translateX(18px);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.completion-label {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.completion-toggle input:checked ~ .completion-label {
    color: var(--success);
}

/* ========================================
   Skills & Credentials
   ======================================== */
.skills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 5px;
}

.skill-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
}

.credential-item {
    margin-bottom: 10px;
}

.credential-item:last-child {
    margin-bottom: 0;
}

.credential-label {
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.copy-box {
    display: flex;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
    align-items: stretch;
}

.copy-value {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 12px;
    color: #fff;
    padding: 8px;
    white-space: nowrap;
    overflow-x: auto;
}

.credential-input {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 12px;
    color: #fff;
    padding: 8px;
    background: transparent;
    border: none;
    outline: none;
    width: 100%;
    transition: background 0.2s ease;
}

.credential-input:focus {
    background: rgba(0, 240, 255, 0.05);
}

.copy-value::-webkit-scrollbar {
    height: 3px;
}

.copy-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 12px;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: bold;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-btn:hover {
    background: var(--accent);
    color: #000;
}

.copy-btn.copied {
    background: var(--success);
    color: #000;
}

/* ========================================
   Action Buttons
   ======================================== */
.action-container {
    padding: 15px 20px;
    border-top: 1px solid var(--panel-border);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-btn {
    width: 100%;
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    border: 1px solid transparent;
    text-transform: uppercase;
}

.btn-connect {
    background: var(--accent);
    color: #000;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
}

.btn-connect:hover {
    box-shadow: 0 0 25px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-disconnect {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}

.btn-disconnect:hover {
    background: rgba(239, 68, 68, 0.1);
}

.btn-special {
    background: linear-gradient(135deg, #ef4444, #e67e22);
    color: #fff;
    border: none;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

.btn-special:hover {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

/* ========================================
   Category Colors — Text & Background
   ======================================== */
.color-ssh { color: #00f0ff; }
.bg-ssh { background-color: rgba(0, 240, 255, 0.15); border: 1px solid rgba(0, 240, 255, 0.3); }

.color-file { color: #4ecdc4; }
.bg-file { background-color: rgba(78, 205, 196, 0.15); border: 1px solid rgba(78, 205, 196, 0.3); }

.color-text { color: #45b7d1; }
.bg-text { background-color: rgba(69, 183, 209, 0.15); border: 1px solid rgba(69, 183, 209, 0.3); }

.color-encoding { color: #f9ca24; }
.bg-encoding { background-color: rgba(249, 202, 36, 0.15); border: 1px solid rgba(249, 202, 36, 0.3); }

.color-networking { color: #8c7ae6; }
.bg-networking { background-color: rgba(140, 122, 230, 0.15); border: 1px solid rgba(140, 122, 230, 0.3); }

.color-escalation { color: #e74c3c; }
.bg-escalation { background-color: rgba(231, 76, 60, 0.15); border: 1px solid rgba(231, 76, 60, 0.3); }

.color-cron { color: #e67e22; }
.bg-cron { background-color: rgba(230, 126, 34, 0.15); border: 1px solid rgba(230, 126, 34, 0.3); }

.color-brute { color: #fd79a8; }
.bg-brute { background-color: rgba(253, 121, 168, 0.15); border: 1px solid rgba(253, 121, 168, 0.3); }

.color-git { color: #00b894; }
.bg-git { background-color: rgba(0, 184, 148, 0.15); border: 1px solid rgba(0, 184, 148, 0.3); }

.color-escape { color: #d63031; }
.bg-escape { background-color: rgba(214, 48, 49, 0.15); border: 1px solid rgba(214, 48, 49, 0.3); }

.color-victory { color: #2ecc71; }
.bg-victory { background-color: rgba(46, 204, 113, 0.15); border: 1px solid rgba(46, 204, 113, 0.3); }

/* ========================================
   Category Colors — Card Border Accents
   ======================================== */
.border-ssh      { border-left: 3px solid #00f0ff; }
.border-file     { border-left: 3px solid #4ecdc4; }
.border-text     { border-left: 3px solid #45b7d1; }
.border-encoding { border-left: 3px solid #f9ca24; }
.border-networking { border-left: 3px solid #8c7ae6; }
.border-escalation { border-left: 3px solid #e74c3c; }
.border-cron     { border-left: 3px solid #e67e22; }
.border-brute    { border-left: 3px solid #fd79a8; }
.border-git      { border-left: 3px solid #00b894; }
.border-escape   { border-left: 3px solid #d63031; }
.border-victory  { border-left: 3px solid #2ecc71; }

/* ========================================
   Private Key Viewer
   ======================================== */
.private-key-display {
    font-family: var(--font-mono);
    font-size: 10px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #888;
    padding: 8px;
    border-radius: 4px;
    max-height: 80px;
    overflow-y: auto;
    white-space: pre;
    margin-top: 5px;
    user-select: all;
}

/* ========================================
   Help Modal
   ======================================== */
.help-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.help-modal.active {
    opacity: 1;
    visibility: visible;
}

.help-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.help-content {
    position: relative;
    z-index: 1;
    background: rgba(15, 15, 22, 0.98);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 30px;
    max-width: 480px;
    width: 90%;
    animation: slideIn 0.2s ease;
}

.help-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    letter-spacing: 3px;
    color: var(--accent);
    margin-bottom: 20px;
    text-align: center;
}

.shortcut-list {
    list-style: none;
    padding: 0;
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 13px;
    color: var(--text-muted);
}

.shortcut-item:last-child {
    border-bottom: none;
}

.shortcut-key {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--panel-border);
    padding: 3px 10px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--accent);
    white-space: nowrap;
}

.help-close-hint {
    text-align: center;
    margin-top: 20px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    font-family: var(--font-mono);
}

/* ========================================
   Mobile Responsive
   ======================================== */

/* Tablet landscape */
@media (max-width: 1024px) {
    :root {
        --intel-width: 300px;
    }

    .header-middle {
        max-width: 400px;
    }

    .logo {
        font-size: 15px;
    }
}

/* Tablet portrait */
@media (max-width: 768px) {
    #main-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-height: 220px;
        border-right: none;
        border-bottom: 1px solid var(--panel-border);
    }

    .sidebar.collapsed {
        transform: translateY(-100%);
        margin-left: 0;
        max-height: 0;
        overflow: hidden;
    }

    .intel-panel {
        width: 100%;
        flex: 0 0 auto;
        max-height: 280px;
        border-left: none;
        border-top: 1px solid var(--panel-border);
    }

    .header-middle {
        max-width: 300px;
    }

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

/* Phone */
@media (max-width: 480px) {
    #header {
        padding: 8px 12px;
        height: 50px;
        gap: 8px;
    }

    .header-middle {
        display: none;
    }

    .logo {
        font-size: 13px;
    }

    .sidebar-toggle-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .sidebar {
        max-height: 180px;
    }

    .intel-panel {
        max-height: 240px;
    }

    .intel-content {
        padding: 12px;
    }

    .intel-card {
        padding: 10px;
        margin-bottom: 10px;
    }

    .action-container {
        padding: 10px 12px;
    }
}
