/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: #0f0f14;
    color: #e0e0e8;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ── Header ──────────────────────────────────────────── */
#app-header {
    background: linear-gradient(135deg, #16161d 0%, #1c1c28 100%);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    z-index: 10;
    flex-shrink: 0;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-icon {
    width: 26px;
    height: 26px;
    color: #7c6aef;
    filter: drop-shadow(0 0 6px rgba(124, 106, 239, 0.4));
}

#app-header h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, #a78bfa 0%, #7c6aef 50%, #6366f1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Auth Panel ──────────────────────────────────────── */
#auth-panel {
    display: flex;
    align-items: center;
    gap: 10px;
}

#auth-panel input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e0e0e8;
    padding: 8px 14px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    outline: none;
    transition: all 0.2s ease;
    width: 160px;
}

#auth-panel input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

#auth-panel input:focus {
    border-color: #7c6aef;
    background: rgba(124, 106, 239, 0.06);
    box-shadow: 0 0 0 3px rgba(124, 106, 239, 0.15);
}

#auth-panel button,
#control-bar button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

#login-btn {
    background: linear-gradient(135deg, #7c6aef 0%, #6366f1 100%);
    box-shadow: 0 2px 8px rgba(124, 106, 239, 0.3);
}

#login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(124, 106, 239, 0.45);
}

#login-btn:active {
    transform: translateY(0);
}

.btn-outline {
    background: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #b0b0c0 !important;
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.06) !important;
    border-color: rgba(255, 255, 255, 0.25) !important;
    color: #fff !important;
}

#auth-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    margin-left: 4px;
    font-weight: 500;
}

#login-error {
    color: #f87171;
    font-size: 12px;
    font-weight: 500;
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* ── Control Bar ─────────────────────────────────────── */
#control-bar {
    display: none;
    background: rgba(22, 22, 29, 0.8);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

.control-buttons {
    display: flex;
    gap: 8px;
}

.btn-success {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.25);
}

.btn-success:hover:not(:disabled) {
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.4);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover:not(:disabled) {
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
}

.btn-warning:hover:not(:disabled) {
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
    transform: translateY(-1px);
}

#control-bar button:disabled {
    background: rgba(255, 255, 255, 0.06) !important;
    color: rgba(255, 255, 255, 0.25) !important;
    box-shadow: none !important;
    cursor: not-allowed;
    transform: none !important;
}

#active-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    margin-left: auto;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-weight: 400;
    letter-spacing: 0.3px;
}

/* ── Tabs ────────────────────────────────────────────── */
#tabs {
    display: none;
    background: #13131a;
    padding: 0 16px;
    overflow-x: auto;
    gap: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

#tabs::-webkit-scrollbar { height: 4px; }
#tabs::-webkit-scrollbar-track { background: transparent; }
#tabs::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 2px; }

.tab {
    padding: 10px 20px;
    background: transparent;
    cursor: pointer;
    border: none;
    border-bottom: 2px solid transparent;
    color: rgba(255, 255, 255, 0.45);
    user-select: none;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    position: relative;
}

.tab:hover {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.03);
}

.tab.active {
    color: #fff;
    font-weight: 600;
    border-bottom: 2px solid #7c6aef;
    background: rgba(124, 106, 239, 0.05);
}

/* ── Status Pills ────────────────────────────────────── */
.status-pill {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-left: 10px;
    padding: 3px 8px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
}

.status-running {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.15);
}

.status-stopped {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.35);
}

.status-crashed {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.15);
    animation: pulse-crash 2s ease-in-out infinite;
}

@keyframes pulse-crash {
    0%, 100% { box-shadow: 0 0 8px rgba(239, 68, 68, 0.15); }
    50% { box-shadow: 0 0 14px rgba(239, 68, 68, 0.3); }
}

.status-starting, .status-stopping, .status-restarting {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    animation: pulse-pending 1.5s ease-in-out infinite;
}

@keyframes pulse-pending {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ── Terminals ───────────────────────────────────────── */
#terminals {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: none;
    background: #111118;
}

.terminal-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    padding: 12px 16px;
    flex-direction: column;
}

.terminal-header {
    padding-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    margin-bottom: 6px;
}

.terminal-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    border-radius: 6px;
}

.terminal-container.active {
    display: flex;
}

/* ── Utilities ───────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* ── Selection ───────────────────────────────────────── */
::selection { background: rgba(124, 106, 239, 0.35); color: #fff; }

/* ── Focus Visible ───────────────────────────────────── */
:focus-visible {
    outline: 2px solid rgba(124, 106, 239, 0.5);
    outline-offset: 2px;
}
