/* CSS Variables - Refined Dark Theme */
:root {
    --bg-primary: #09090b;
    --bg-secondary: #0f0f12;
    --bg-tertiary: #16161a;
    --bg-card: #121215;
    --bg-elevated: #1a1a1f;
    --bg-hover: #1e1e24;
    
    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;
    --text-faint: #3f3f46;
    
    --border-color: #27272a;
    --border-subtle: #1f1f23;
    
    --accent: #22c55e;
    --accent-muted: rgba(34, 197, 94, 0.15);
    --accent-hover: #16a34a;
    
    --blue: #3b82f6;
    --blue-muted: rgba(59, 130, 246, 0.12);
    
    --red: #ef4444;
    --red-muted: rgba(239, 68, 68, 0.12);
    
    --amber: #f59e0b;
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
    
    --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--text-primary);
}

.mono {
    font-family: var(--font-mono);
}

/* Layout */
.app {
    min-height: 100vh;
}

.view {
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* Login */
.login-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    background: var(--bg-primary);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    width: 48px;
    height: 48px;
    margin: 0 auto 1.25rem;
    background: var(--accent);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo svg {
    width: 24px;
    height: 24px;
    color: var(--bg-primary);
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

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

.features {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.feature-tag {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0.375rem 0.625rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.login-form {
    width: 100%;
    max-width: 340px;
}

.form-hint {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem 0.875rem;
    font-size: 0.9rem;
    font-family: var(--font-mono);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: border-color var(--transition);
}

.form-group input::placeholder {
    color: var(--text-faint);
}

.form-group input:focus {
    outline: none;
    border-color: var(--text-muted);
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    line-height: 1.4;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.form-actions .btn {
    min-width: 100px;
}

.login-footer {
    margin-top: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

.login-footer a {
    color: var(--text-secondary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: var(--font-sans);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-full { width: 100%; }
.btn-sm { padding: 0.5rem 0.75rem; font-size: 0.8rem; }

.btn-primary {
    background: var(--text-primary);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background: #fff;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-success {
    background: var(--accent);
    color: var(--bg-primary);
}

.btn-success:hover {
    background: var(--accent-hover);
}

.btn-danger {
    background: var(--red-muted);
    color: var(--red);
    border: 1px solid transparent;
}

.btn-danger:hover {
    background: var(--red);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.btn-danger-text {
    color: var(--red);
}

.btn-danger-text:hover {
    color: var(--text-primary);
    background: var(--red-muted);
}

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

.btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn-icon-only {
    background: none;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    padding: 0.25rem;
    margin-left: 0.375rem;
    transition: color var(--transition);
}

.btn-icon-only:hover {
    color: var(--text-secondary);
}

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.nav-brand .logo-sm {
    width: 24px;
    height: 24px;
    background: var(--accent);
    border-radius: 4px;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#user-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Dashboard */
.dashboard-content {
    max-width: 640px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Center Content */
.center-content {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
}

/* Apply Card */
.apply-card {
    text-align: center;
    max-width: 400px;
}

.apply-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.apply-icon svg {
    width: 32px;
    height: 32px;
    color: var(--text-muted);
}

.apply-card h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.apply-card > p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 2rem;
}

.apply-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 2rem;
    text-align: left;
}

.apply-feature {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.apply-feature .dot {
    width: 4px;
    height: 4px;
    background: var(--accent);
    border-radius: 50%;
    flex-shrink: 0;
}

/* Server Info Bar */
.server-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.server-ip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
}

.server-ip svg {
    width: 16px;
    height: 16px;
    color: var(--text-faint);
}

.server-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.server-container svg {
    width: 16px;
    height: 16px;
    color: var(--accent);
}

.server-specs {
    display: flex;
    gap: 0.75rem;
}

.server-specs span {
    font-size: 0.7rem;
    color: var(--text-faint);
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

/* Status Card - Modern Design */
.status-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    overflow: hidden;
}

.status-card.running {
    border-color: var(--accent);
}

.status-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem;
    background: var(--bg-secondary);
}

.status-card-title {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.status-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    color: var(--text-faint);
}

.status-icon svg {
    width: 20px;
    height: 20px;
}

.status-card.running .status-icon {
    background: var(--accent-muted);
    color: var(--accent);
}

.status-card-title h3 {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.125rem;
}

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

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 9999px;
}

.indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-faint);
}

.status-card.running .indicator-dot {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--accent); }
    50% { opacity: 0.7; box-shadow: 0 0 4px var(--accent); }
}

.indicator-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text-faint);
}

.status-card.running .indicator-label {
    color: var(--accent);
}

.status-card-body {
    padding: 1.25rem;
}

.status-metrics {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.metric-label {
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-faint);
}

.metric-value {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-primary);
}

.status-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.status-card-footer {
    padding: 0.75rem 1.25rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
}

.footer-hint {
    font-size: 0.7rem;
    color: var(--text-faint);
}

/* Section Cards */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 0.75rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
}

.card-header h3 {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header h3 svg {
    width: 16px;
    height: 16px;
    color: var(--text-faint);
}

.card-body {
    padding: 1.25rem;
}

/* Action Buttons Row */
.action-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* SSH Info */
.ssh-grid {
    display: grid;
    gap: 0.875rem;
    margin-bottom: 1rem;
}

.ssh-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0.875rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.ssh-item-label {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-faint);
}

.ssh-item-value {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

/* Specs Row */
.specs-row {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-subtle);
    flex-wrap: wrap;
}

.spec-tag {
    font-size: 0.7rem;
    color: var(--text-faint);
    padding: 0.375rem 0.625rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

/* External Link */
.external-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
}

.external-link:hover {
    color: var(--text-secondary);
}

.external-link svg {
    width: 12px;
    height: 12px;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-large {
    max-width: 800px;
    height: 75vh;
}

.modal-sm {
    max-width: 400px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
    font-size: 0.9rem;
    font-weight: 500;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-close svg {
    width: 16px;
    height: 16px;
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.terminal-body {
    padding: 0;
    background: #000;
}

#terminal-container {
    height: 100%;
    width: 100%;
}

/* Log */
.log-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
}

.toggle input {
    accent-color: var(--accent);
}

.log-container {
    height: 360px;
    overflow-y: auto;
    padding: 0.875rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.7;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.log-placeholder {
    color: var(--text-faint);
    text-align: center;
    padding: 2rem;
}

.log-line {
    padding: 0.125rem 0;
    white-space: pre-wrap;
    word-break: break-all;
}

.log-line .timestamp {
    color: var(--text-faint);
    margin-right: 0.5rem;
}

.log-line .content {
    color: var(--text-secondary);
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 2000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    animation: slideIn 0.2s ease;
}

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

.toast.success { border-color: var(--accent); }
.toast.error { border-color: var(--red); }

.toast svg {
    width: 16px;
    height: 16px;
}

.toast.success svg { color: var(--accent); }
.toast.error svg { color: var(--red); }

/* Spinner */
.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-faint);
}

/* Responsive */
@media (max-width: 640px) {
    .dashboard-content {
        padding: 2rem 1rem;
    }
    
    .apply-features {
        grid-template-columns: 1fr;
    }
    
    .specs-row {
        justify-content: center;
    }
}

/* File Manager Styles */
.file-path-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.file-path-bar #file-current-path {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.file-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.file-list-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-muted);
}

.file-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}

.file-item:hover {
    background: var(--bg-tertiary);
}

.file-item-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--text-muted);
}

.file-item-icon.folder {
    color: var(--accent);
}

.file-item-name {
    flex: 1;
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-item-size {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 60px;
    text-align: right;
}

.file-item-modified {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 100px;
}

.file-item-actions {
    display: flex;
    gap: 0.25rem;
}

.file-item-actions .btn {
    padding: 0.25rem;
}

.file-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-muted);
    gap: 0.5rem;
}

.file-empty svg {
    width: 48px;
    height: 48px;
    opacity: 0.5;
}
