/* ═══════════════════════════════════════════════════════════════
   VPS Monitor — Design System
   Dark theme, glassmorphism, modern aesthetics
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
    /* Base colors */
    --bg-primary: #0a0f1e;
    --bg-secondary: #111827;
    --bg-card: rgba(30, 41, 59, 0.65);
    --bg-card-hover: rgba(30, 41, 59, 0.85);
    --bg-input: rgba(15, 23, 42, 0.8);

    /* Borders */
    --border-color: rgba(148, 163, 184, 0.12);
    --border-glow: rgba(99, 102, 241, 0.3);

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Status colors */
    --green: #22c55e;
    --green-glow: rgba(34, 197, 94, 0.25);
    --red: #ef4444;
    --red-glow: rgba(239, 68, 68, 0.25);
    --yellow: #eab308;
    --yellow-glow: rgba(234, 179, 8, 0.2);

    /* Accent */
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);

    /* Misc */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-pill: 50px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    /* Subtle animated gradient background */
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(34, 197, 94, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(239, 68, 68, 0.04) 0%, transparent 50%);
    background-attachment: fixed;
}

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

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

code {
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.9em;
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

/* ── Navbar ────────────────────────────────────────────────── */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 64px;
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-icon {
    font-size: 1.5rem;
}

.nav-title {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--transition);
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.1);
}

.nav-link.active {
    color: var(--accent);
    background: rgba(99, 102, 241, 0.15);
}

.nav-link-icon {
    font-size: 1.1rem;
}

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

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

.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ── Stats Grid ────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.stat-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-total:hover { border-color: var(--accent); }
.stat-online:hover { border-color: var(--green); }
.stat-offline:hover { border-color: var(--red); }
.stat-unknown:hover { border-color: var(--yellow); }

.stat-icon {
    font-size: 2rem;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    transition: all var(--transition);
}

.stat-value.value-changed {
    animation: valueFlash 0.5s ease;
}

@keyframes valueFlash {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); color: var(--accent); }
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-top: 0.25rem;
}

/* ── Section Header ────────────────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.auto-refresh-badge {
    font-size: 0.75rem;
    padding: 4px 12px;
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent);
    border-radius: var(--radius-pill);
    font-weight: 500;
}

/* ── Server Grid (Dashboard Cards) ─────────────────────────── */
.server-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.server-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.server-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
    transition: all var(--transition);
}

.server-card.status-online::before { background: var(--green); }
.server-card.status-offline::before { background: var(--red); }
.server-card.status-unknown::before { background: var(--yellow); }

.server-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.server-card.status-online:hover { border-color: rgba(34, 197, 94, 0.3); }
.server-card.status-offline:hover { border-color: rgba(239, 68, 68, 0.3); }

.server-card.checking {
    animation: pulseCheck 1s ease infinite;
}

@keyframes pulseCheck {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.server-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.server-name-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.server-name {
    font-size: 1rem;
    font-weight: 600;
}

/* ── Status Dot ────────────────────────────────────────────── */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
}

.status-dot.online {
    background: var(--green);
    box-shadow: 0 0 8px var(--green-glow);
    animation: pulseGreen 2s ease-in-out infinite;
}

.status-dot.offline {
    background: var(--red);
    box-shadow: 0 0 8px var(--red-glow);
    animation: pulseRed 1.5s ease-in-out infinite;
}

.status-dot.unknown {
    background: var(--yellow);
    box-shadow: 0 0 8px var(--yellow-glow);
}

@keyframes pulseGreen {
    0%, 100% { box-shadow: 0 0 4px var(--green-glow); }
    50% { box-shadow: 0 0 12px var(--green-glow), 0 0 20px rgba(34, 197, 94, 0.1); }
}

@keyframes pulseRed {
    0%, 100% { box-shadow: 0 0 4px var(--red-glow); }
    50% { box-shadow: 0 0 12px var(--red-glow), 0 0 20px rgba(239, 68, 68, 0.15); }
}

/* ── Check Type Badge ──────────────────────────────────────── */
.check-type-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent);
    letter-spacing: 0.05em;
}

/* ── Server Card Details ───────────────────────────────────── */
.server-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.server-detail {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.detail-label {
    color: var(--text-muted);
    font-weight: 500;
}

.detail-value {
    color: var(--text-primary);
    font-weight: 500;
}

.detail-target {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.server-card-actions {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

/* ── Status Badge (for tables) ─────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-badge.online {
    background: var(--green-glow);
    color: var(--green);
}

.status-badge.offline {
    background: var(--red-glow);
    color: var(--red);
}

.status-badge.unknown {
    background: var(--yellow-glow);
    color: var(--yellow);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #4f46e5);
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

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

.btn-accent {
    background: rgba(34, 197, 94, 0.15);
    color: var(--green);
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.btn-accent:hover {
    background: rgba(34, 197, 94, 0.25);
}

.btn-ghost {
    background: rgba(148, 163, 184, 0.08);
    color: var(--text-secondary);
    border: 1px solid transparent;
}

.btn-ghost:hover {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-primary);
    border-color: var(--border-color);
}

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

.btn-danger-ghost:hover {
    background: rgba(239, 68, 68, 0.12);
    color: var(--red);
    border-color: rgba(239, 68, 68, 0.25);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

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

/* ── Cards ─────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.card-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.card-description .link {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-card {
    border-color: var(--border-glow);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    padding: 0.65rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    transition: all var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.form-group select {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.form-group select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

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

.form-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

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

.settings-form .form-group input {
    max-width: 500px;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.data-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tbody tr {
    transition: background var(--transition);
}

.data-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

.server-name-cell {
    font-weight: 600;
}

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

/* ── Log Table (Modal) ─────────────────────────────────────── */
.log-table {
    width: 100%;
    border-collapse: collapse;
}

.log-table th,
.log-table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
}

.log-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
}

.log-row.status-offline {
    background: rgba(239, 68, 68, 0.05);
}

.error-cell {
    color: var(--red);
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.loading, .empty, .error {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem !important;
}

/* ── Toggle Switch ─────────────────────────────────────────── */
.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--text-muted);
    border-radius: 22px;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
}

.toggle input:checked + .toggle-slider {
    background: var(--green);
    box-shadow: 0 0 8px var(--green-glow);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all var(--transition);
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
    background: rgba(148, 163, 184, 0.15);
}

.modal-body {
    overflow-y: auto;
    padding: 0;
}

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

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* ── Info Card ─────────────────────────────────────────────── */
.info-card {
    border-color: rgba(99, 102, 241, 0.15);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}

.info-item {
    display: flex;
    gap: 0.75rem;
}

.info-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.info-item strong {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.info-item p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

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

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    font-size: 0.875rem;
    font-weight: 500;
    animation: toastIn 0.35s ease;
    min-width: 260px;
    max-width: 400px;
}

.toast.success {
    border-left: 3px solid var(--green);
}

.toast.error {
    border-left: 3px solid var(--red);
}

.toast.removing {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(50px); }
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        height: auto;
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    .nav-links {
        width: 100%;
        justify-content: center;
    }

    .main-content {
        padding: 1rem;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .server-grid {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

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

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }
}
