/* Root Design Tokens */
:root {
    --bg-primary: #08080f;
    --bg-secondary: #0d0d17;
    --bg-gradient: radial-gradient(circle at 50% 0%, #15162a 0%, #070810 100%);
    --card-bg: rgba(18, 19, 35, 0.65);
    --card-border: rgba(255, 255, 255, 0.07);
    --card-border-glow: rgba(155, 93, 229, 0.25);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --accent-primary: #9b5de5;
    --accent-secondary: #00f5d4;
    --accent-glow: #7b2cbf;
    --accent-active: #b5179e;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.3);

    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-display: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --border-radius-lg: 16px;
    --border-radius-md: 10px;
    --border-radius-sm: 6px;

    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background: var(--bg-primary);
    background-image: var(--bg-gradient);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* App Layout */
.app-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: 100vh;
    width: 100vw;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Sidebar Styling */
.sidebar {
    background: rgba(10, 11, 22, 0.85);
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    padding: 24px;
    backdrop-filter: blur(20px);
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.brand-logo {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: #000;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(155, 93, 229, 0.4);
}

.logo-icon {
    color: #0d0d17;
    filter: drop-shadow(0px 1px 1px rgba(255,255,255,0.4));
}

.brand-text h1 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sub-logo {
    font-size: 0.75rem;
    color: var(--accent-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.section-title {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    margin: 20px 0 10px 4px;
}

/* Card glassmorphism */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-lg);
    backdrop-filter: blur(12px);
    transition: var(--transition-smooth);
}

.config-panel {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.config-panel:focus-within {
    border-color: rgba(155, 93, 229, 0.4);
    box-shadow: 0 0 20px var(--card-border-glow);
}

/* Inputs and Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
}

.custom-select, .custom-input, .custom-textarea {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    padding: 10px 14px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition-smooth);
}

.custom-select:focus, .custom-input:focus, .custom-textarea:focus {
    border-color: var(--accent-secondary);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 10px rgba(0, 245, 212, 0.15);
}

.custom-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 40px;
}

.hidden {
    display: none !important;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 11px 18px;
    border-radius: var(--border-radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.primary-btn {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-glow));
    color: #fff;
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(155, 93, 229, 0.4);
}

.primary-btn:active:not(:disabled) {
    transform: translateY(0);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
}

.secondary-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
}

.danger-btn {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 4px 15px var(--danger-glow);
}

.danger-btn:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-1px);
}

.btn-glow {
    position: relative;
    box-shadow: 0 0 15px rgba(155, 93, 229, 0.3);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Active Sessions List */
.sessions-list {
    flex-grow: 1;
    min-height: 120px;
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.empty-sessions {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    margin: auto 0;
    font-style: italic;
}

.session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--border-radius-md);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.session-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(0, 245, 212, 0.3);
}

.session-item.active {
    background: rgba(155, 93, 229, 0.1);
    border-color: var(--accent-primary);
}

.sess-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sess-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.sess-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.sess-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.sess-indicator.exited {
    background: var(--text-muted);
    box-shadow: none;
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 16px;
    border-top: 1px solid var(--card-border);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.online {
    background: var(--accent-secondary);
    box-shadow: 0 0 8px var(--accent-secondary);
    animation: pulse 2s infinite;
}

.status-dot.offline {
    background: var(--danger);
    box-shadow: 0 0 8px var(--danger);
}

.status-text {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.version-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Main Content Workspace */
.main-content {
    display: flex;
    flex-direction: column;
    padding: 24px;
    height: 100vh;
    overflow-y: auto;
    gap: 20px;
}

/* Top bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--card-border);
}

.session-info-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.session-info-header h2 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
}

#active-session-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.online {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge.offline {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.top-controls {
    display: flex;
    gap: 10px;
}

.top-controls .btn {
    padding: 8px 14px;
    font-size: 0.85rem;
}

/* Terminal Wrapper & Container */
.terminal-wrapper {
    flex-grow: 1;
    min-height: 350px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--card-border);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.terminal-wrapper:focus-within {
    border-color: rgba(0, 245, 212, 0.35);
    box-shadow: 0 10px 40px rgba(0, 245, 212, 0.08), 0 0 15px rgba(0, 245, 212, 0.15);
}

.terminal-header {
    background: rgba(7, 8, 15, 0.95);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--card-border);
}

.mac-dots {
    display: flex;
    gap: 6px;
}

.mac-dots .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.mac-dots .dot.close { background: #ff5f56; }
.mac-dots .dot.minimize { background: #ffbd2e; }
.mac-dots .dot.expand { background: #27c93f; }

.terminal-title-text {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.terminal-stats {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.terminal-container {
    flex-grow: 1;
    padding: 12px;
    background: #050508;
    overflow: hidden;
}

/* Customizing Xterm inside container */
.terminal-container .xterm {
    height: 100%;
}

.terminal-container .xterm-viewport {
    background-color: #050508 !important;
}

/* Interaction Grid */
.interaction-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 20px;
    height: 230px;
}

.controller-panel, .shortcuts-panel {
    display: flex;
    flex-direction: column;
    padding: 16px;
}

.card-header {
    margin-bottom: 12px;
}

.card-header h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.panel-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Prompt Box Wrapper */
.prompt-box-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.custom-textarea {
    width: 100%;
    flex-grow: 1;
    resize: none;
    font-size: 0.85rem;
    line-height: 1.4;
    background: rgba(0, 0, 0, 0.4);
    border-radius: var(--border-radius-md);
}

.prompt-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Checkbox design */
.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 28px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    user-select: none;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 0;
    height: 18px;
    width: 18px;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 4px;
    transition: var(--transition-smooth);
}

.checkbox-container:hover input ~ .checkmark {
    background-color: rgba(255, 255, 255, 0.1);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--accent-secondary);
    border-color: var(--accent-secondary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 6px;
    top: 2px;
    width: 4px;
    height: 9px;
    border: solid #0d0d17;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.btn-glow-sm {
    box-shadow: 0 0 10px rgba(155, 93, 229, 0.2);
}

/* Shortcuts Panel */
.shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    flex-grow: 1;
}

.shortcut-btn {
    padding: 8px 10px;
    font-size: 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    border-radius: var(--border-radius-md);
    transition: var(--transition-smooth);
}

.shortcut-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.15);
}

.shortcut-btn:active {
    background: rgba(155, 93, 229, 0.15);
    border-color: var(--accent-primary);
}

.key-cap {
    font-family: var(--font-mono);
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    margin-right: 4px;
}

.tip-banner {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(0, 245, 212, 0.05);
    border: 1px dashed rgba(0, 245, 212, 0.2);
    border-radius: var(--border-radius-md);
}

.tip-icon {
    font-size: 0.9rem;
}

.tip-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.35;
}

/* Animations */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 245, 212, 0.5);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(0, 245, 212, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 245, 212, 0);
    }
}

/* Responsive constraints */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: auto;
    }
    .sidebar {
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--card-border);
    }
    .main-content {
        height: calc(100vh - 120px);
    }
    .interaction-grid {
        grid-template-columns: 1fr;
        height: auto;
    }
}

/* Connect Mobile Deck Styles */
.connect-mobile {
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.qrcode-options {
    display: flex;
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--border-radius-sm);
    padding: 2px;
    border: 1px solid var(--card-border);
}

.qr-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-smooth);
}

.qr-btn.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(155, 93, 229, 0.3);
}

.qrcode-img-container {
    background: white;
    padding: 10px;
    border-radius: var(--border-radius-md);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    width: 160px;
    height: 160px;
}

.qrcode-img-container img {
    width: 140px;
    height: 140px;
}

.qrcode-address {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--accent-secondary);
    word-break: break-all;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
    padding: 6px 10px;
    border-radius: var(--border-radius-sm);
    width: 100%;
    border: 1px solid rgba(0, 245, 212, 0.1);
}

/* Login Landing Page Styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    padding: 60px 20px;
    max-width: 900px;
    margin: 0 auto;
    min-height: 100vh;
}

.login-card {
    flex: 1.2;
    padding: 32px;
    max-width: 440px;
}

.login-form h2 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 24px;
}

.login-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--border-radius-sm);
    font-size: 0.85rem;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 500;
}

.divider {
    height: 1px;
    background: var(--card-border);
    margin: 24px 0;
}

.downloads-section h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.downloads-subtitle {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-bottom: 16px;
}

.downloads-buttons {
    display: flex;
    gap: 12px;
}

.download-btn {
    flex: 1;
    font-size: 0.8rem;
    padding: 10px 12px;
}

.download-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.connect-mobile-landing {
    flex: 0.8;
    padding: 24px;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .login-container {
        flex-direction: column;
        align-items: center;
        padding: 40px 20px;
        gap: 24px;
    }
    .login-card, .connect-mobile-landing {
        width: 100%;
        max-width: 440px;
    }
}
