/* ===== SSH SERVICE STYLES — matches main site design ===== */

/* Reuse CSS variables from main site theme */
:root {
    --bg: #fafafa;
    --bg-card: #ffffff;
    --bg-hover: #f3f0ff;
    --bg-sidebar: #f8f7fc;
    --border: #e8e5f0;
    --text: #1a1a2e;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-light: rgba(124, 58, 237, 0.08);
    --accent-gradient: linear-gradient(135deg, #7c3aed, #a855f7);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.08);
    --success: #10b981;
    --warning: #f59e0b;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --sidebar-width: 260px;
}

[data-theme="dark"] {
    --bg: #0f0f14;
    --bg-card: #16161e;
    --bg-hover: #1e1b2e;
    --bg-sidebar: #12121a;
    --border: #2a2a3a;
    --text: #e4e4ed;
    --text-secondary: #9394a0;
    --text-muted: #5c5d6e;
    --accent: #a78bfa;
    --accent-hover: #8b5cf6;
    --accent-light: rgba(167, 139, 250, 0.1);
    --accent-gradient: linear-gradient(135deg, #7c3aed, #a855f7);
    --danger: #f87171;
    --danger-light: rgba(248, 113, 113, 0.1);
    --success: #34d399;
    --warning: #fbbf24;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    transition: background 0.2s, color 0.2s;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: none; }

/* ===== LAYOUT ===== */
.ssh-layout {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.ssh-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    font-size: 16px;
}

.sidebar-logo:hover { color: var(--accent); }

.sidebar-user {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar-sm {
    width: 36px;
    height: 36px;
    background: var(--accent-gradient);
    color: white;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.user-info { min-width: 0; }
.user-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav { padding: 12px 0; }

.sidebar-section {
    padding: 12px 0;
    border-top: 1px solid var(--border);
}

.sidebar-section-title {
    padding: 4px 20px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.15s;
    cursor: pointer;
}

.nav-item:hover { color: var(--text); background: var(--accent-light); text-decoration: none; }
.nav-item.active { color: var(--accent); background: var(--accent-light); font-weight: 500; }

.nav-icon { font-size: 16px; flex-shrink: 0; }

.nav-server-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.nav-server-ip {
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.btn-logout-sidebar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    width: 100%;
    transition: all 0.15s;
}

.btn-logout-sidebar:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }

/* ===== MAIN ===== */
.ssh-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.ssh-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

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

.sidebar-toggle {
    display: none;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 18px;
    cursor: pointer;
    color: var(--text);
}

.btn-link-back {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.15s;
}

.btn-link-back:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-light); }

.ssh-content {
    flex: 1;
    padding: 24px;
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.15s;
}

.theme-toggle:hover { background: var(--accent-light); border-color: var(--accent); }
.theme-toggle-fixed { position: fixed; top: 16px; right: 16px; z-index: 200; }

/* ===== SHARED COMPONENTS ===== */
.logo-placeholder {
    width: 32px;
    height: 32px;
    background: var(--accent-gradient);
    color: white;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.status-active { background: var(--success); }
.status-inactive { background: var(--text-muted); }

.text-muted { color: var(--text-secondary); font-size: 13px; }

/* ===== AUTH PAGES ===== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-md);
}

.auth-header { margin-bottom: 24px; text-align: center; }
.auth-header h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.auth-header p { font-size: 14px; color: var(--text-secondary); }

.auth-form .form-group { margin-bottom: 16px; }
.auth-footer { text-align: center; padding-top: 16px; border-top: 1px solid var(--border); font-size: 14px; color: var(--text-secondary); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.15s;
    font-family: inherit;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.form-group textarea { resize: vertical; min-height: 64px; }
.hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; display: block; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: inherit;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); color: white; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; }

/* ===== ALERTS ===== */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; font-size: 14px; }
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid var(--danger); }
.alert-success { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid var(--success); }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 80px 24px; }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: var(--text-secondary); }

/* ===== DASHBOARD ===== */
.dashboard-page { max-width: 900px; }

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.dashboard-header h1 { font-size: 24px; font-weight: 700; }

.servers-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.server-overview-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: all 0.15s;
}

.server-overview-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px); }

.server-overview-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.server-overview-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.server-overview-name h3 { font-size: 16px; font-weight: 600; }

.server-overview-actions { flex-shrink: 0; }

.server-overview-details { display: grid; gap: 8px; }

.detail-item {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

.detail-item:last-child { border-bottom: none; }
.detail-label { color: var(--text-secondary); }
.detail-value { font-weight: 500; }

/* ===== ADD SERVER PAGE ===== */
.add-server-page { max-width: 600px; }

.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.page-header h1 { font-size: 24px; font-weight: 700; }

.btn-back {
    color: var(--text-secondary);
    font-size: 14px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.15s;
}

.btn-back:hover { color: var(--accent); border-color: var(--accent); }

.add-server-form-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

/* ===== SERVER DETAIL PAGE ===== */
.server-detail-page { max-width: 1000px; }

.server-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.server-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.server-title h1 { font-size: 28px; font-weight: 700; }

.server-header-actions { display: flex; gap: 8px; align-items: center; }

.auto-refresh-status {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 8px;
}

.server-info-bar {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
}

.info-bar-item { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.info-bar-label { color: var(--text-secondary); }
.info-bar-value { font-weight: 500; }

/* ===== INSTALL REQUESTS ===== */
.install-requests-section {
    background: var(--bg-card);
    border: 1px solid var(--warning);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
}

.install-requests-section h3 { margin-bottom: 12px; }

.install-request-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.package-name { font-weight: 500; font-size: 14px; }
.install-request-actions { display: flex; gap: 6px; }

/* ===== METRICS ===== */
.metrics-section h2 { font-size: 20px; font-weight: 700; margin-bottom: 16px; }

.metric-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 32px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
}

.metric-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.metric-label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.metric-value { font-size: 18px; font-weight: 700; }

.metric-bar {
    height: 8px;
    background: var(--bg);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 6px;
}

.metric-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 99px;
    transition: width 0.5s ease;
}

.metric-detail { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.load-avg-details { display: grid; gap: 4px; margin-top: 8px; }
.load-item { font-size: 13px; color: var(--text-secondary); }

.network-details { display: grid; gap: 4px; margin-top: 8px; }
.network-item { font-size: 13px; color: var(--text-secondary); }

/* ===== CHARTS ===== */
.charts-section { margin-top: 32px; }
.charts-section h3 { font-size: 18px; font-weight: 600; margin-bottom: 16px; }

.charts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.time-range-selector {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
}

.time-btn {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}

.time-btn:hover { background: var(--accent-light); color: var(--accent); }
.time-btn.active { background: var(--accent); color: white; }

.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 16px;
}

.chart-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
}

.chart-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 768px) {
    .chart-row { grid-template-columns: 1fr; }
}

/* ===== INSTALL PACKAGE ===== */
.install-package-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-top: 24px;
}

.install-package-section h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.install-package-section .text-muted { margin-bottom: 12px; }

.install-package-form {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.input-package {
    flex: 1;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
}

.input-package:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

/* ===== EMPTY METRICS ===== */
.empty-metrics { text-align: center; padding: 60px 24px; }

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal.show { display: flex; }
.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 480px;
    box-shadow: var(--shadow-md);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: all 0.15s;
}
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 20px; }
.modal-body p { margin-bottom: 8px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .ssh-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    .ssh-layout.sidebar-open .ssh-sidebar {
        transform: translateX(0);
    }
    .ssh-main {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: flex;
    }
    .servers-dashboard {
        grid-template-columns: 1fr;
    }
    .metric-cards {
        grid-template-columns: 1fr 1fr;
    }
    .server-detail-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .server-info-bar {
        flex-direction: column;
        gap: 8px;
    }
    .install-package-form {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .metric-cards {
        grid-template-columns: 1fr;
    }
}
