/* ==========================================================================
   Website Health & Security Platform - Design System
   Modern Vanilla CSS with CSS Custom Properties, Dark/Light Mode & Glassmorphism
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    /* Color Palette - Dark Mode Default */
    --bg-base: #0b0f19;
    --bg-surface: #111827;
    --bg-surface-elevated: #1f2937;
    --bg-surface-hover: #263346;
    --bg-glass: rgba(17, 24, 39, 0.75);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Brand / Accent */
    --brand-primary: #3b82f6;
    --brand-primary-hover: #2563eb;
    --brand-glow: rgba(59, 130, 246, 0.25);
    --brand-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --brand-gradient-subtle: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);

    /* Semantic Status Colors */
    --status-healthy: #10b981;
    --status-healthy-bg: rgba(16, 185, 129, 0.12);
    --status-healthy-border: rgba(16, 185, 129, 0.3);

    --status-warning: #f59e0b;
    --status-warning-bg: rgba(245, 158, 11, 0.12);
    --status-warning-border: rgba(245, 158, 11, 0.3);

    --status-degraded: #f97316;
    --status-degraded-bg: rgba(249, 115, 22, 0.12);
    --status-degraded-border: rgba(249, 115, 22, 0.3);

    --status-down: #ef4444;
    --status-down-bg: rgba(239, 68, 68, 0.12);
    --status-down-border: rgba(239, 68, 68, 0.3);

    --status-unknown: #64748b;
    --status-unknown-bg: rgba(100, 116, 139, 0.12);
    --status-unknown-border: rgba(100, 116, 139, 0.3);

    /* Spacing & Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 25px var(--brand-glow);

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 70px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

[data-theme="light"] {
    --bg-base: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #f8fafc;
    --bg-surface-hover: #e2e8f0;
    --bg-glass: rgba(255, 255, 255, 0.85);
    --border-subtle: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.16);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --brand-glow: rgba(59, 130, 246, 0.15);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* ==========================================================================
   Base Styles & Reset
   ========================================================================== */

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

html, body {
    height: 100%;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    background-color: var(--bg-base);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--brand-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

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

code, pre {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
}

/* ==========================================================================
   Layout Architecture
   ========================================================================== */

.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: transform var(--transition-normal);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.brand-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: var(--brand-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-glow);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-section-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 700;
    padding: 0.75rem 0.75rem 0.35rem 0.75rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-item:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--brand-gradient-subtle);
    color: var(--brand-primary);
    font-weight: 600;
    border-left: 3px solid var(--brand-primary);
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--header-height);
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.content-body {
    flex: 1;
    padding: 2rem;
}

/* ==========================================================================
   Theme Switcher & User Dropdown
   ========================================================================== */

.theme-toggle-btn {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--brand-primary);
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.user-role-tag {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
}

/* ==========================================================================
   Card System & Glassmorphism
   ========================================================================== */

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    margin-bottom: 1.5rem;
    transition: border-color var(--transition-normal);
}

.card:hover {
    border-color: var(--border-strong);
}

.card-glass {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

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

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface-elevated);
}

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

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border-subtle);
}

.stat-card.stat-healthy::before { background: var(--status-healthy); }
.stat-card.stat-warning::before { background: var(--status-warning); }
.stat-card.stat-degraded::before { background: var(--status-degraded); }
.stat-card.stat-down::before { background: var(--status-down); }
.stat-card.stat-primary::before { background: var(--brand-primary); }

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

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.stat-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* ==========================================================================
   Buttons & Form Controls
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: var(--brand-primary);
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    background: var(--brand-primary-hover);
    color: #ffffff;
}

.btn-secondary {
    background: var(--bg-surface-elevated);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-strong);
}

.btn-danger {
    background: var(--status-down-bg);
    border-color: var(--status-down-border);
    color: var(--status-down);
}

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

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

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

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius-md);
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-glow);
}

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

.form-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

.form-error {
    font-size: 0.78rem;
    color: var(--status-down);
    margin-top: 0.35rem;
}

.form-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   Data Tables & Badges
   ========================================================================== */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th {
    background: var(--bg-surface-elevated);
    padding: 0.85rem 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    vertical-align: middle;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid transparent;
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
}

.badge-healthy {
    background: var(--status-healthy-bg);
    color: var(--status-healthy);
    border-color: var(--status-healthy-border);
}
.badge-healthy .badge-dot { background: var(--status-healthy); }

.badge-warning {
    background: var(--status-warning-bg);
    color: var(--status-warning);
    border-color: var(--status-warning-border);
}
.badge-warning .badge-dot { background: var(--status-warning); }

.badge-degraded {
    background: var(--status-degraded-bg);
    color: var(--status-degraded);
    border-color: var(--status-degraded-border);
}
.badge-degraded .badge-dot { background: var(--status-degraded); }

.badge-down {
    background: var(--status-down-bg);
    color: var(--status-down);
    border-color: var(--status-down-border);
}
.badge-down .badge-dot { background: var(--status-down); }

.badge-unknown {
    background: var(--status-unknown-bg);
    color: var(--status-unknown);
    border-color: var(--status-unknown-border);
}
.badge-unknown .badge-dot { background: var(--status-unknown); }

/* ==========================================================================
   Alerts & Notifications
   ========================================================================== */

.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--status-healthy-bg);
    color: var(--status-healthy);
    border-color: var(--status-healthy-border);
}

.alert-error {
    background: var(--status-down-bg);
    color: var(--status-down);
    border-color: var(--status-down-border);
}

.alert-warning {
    background: var(--status-warning-bg);
    color: var(--status-warning);
    border-color: var(--status-warning-border);
}

/* ==========================================================================
   Tabs Component
   ========================================================================== */

.tabs-nav {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.tab-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.tab-link:hover {
    color: var(--text-primary);
}

.tab-link.active {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
}

/* ==========================================================================
   Login / Guest Layout
   ========================================================================== */

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.12), transparent 40%),
                radial-gradient(circle at bottom left, rgba(139, 92, 246, 0.12), transparent 40%),
                var(--bg-base);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
}

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

.auth-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-top: 1rem;
    letter-spacing: -0.02em;
}

.auth-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

/* ==========================================================================
   Pagination Component
   ========================================================================== */

.pagination-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    width: 100%;
}

.pagination-container.pagination-simple {
    justify-content: flex-end;
}

.pagination-summary {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.pagination-highlight {
    font-weight: 700;
    color: var(--text-primary);
}

.pagination-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.pagination-pages {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-width: 36px;
    height: 36px;
    padding: 0 0.75rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    user-select: none;
    transition: all var(--transition-fast);
}

.pagination-btn:hover:not(.disabled):not(.active) {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.pagination-btn.active {
    background: var(--brand-primary);
    color: #ffffff;
    border-color: var(--brand-primary);
    font-weight: 700;
    box-shadow: 0 2px 8px var(--brand-glow);
    cursor: default;
}

.pagination-btn.disabled {
    opacity: 0.38;
    cursor: not-allowed;
    pointer-events: none;
    color: var(--text-muted);
}

.pagination-btn-prev,
.pagination-btn-next {
    padding: 0 0.85rem;
    font-weight: 600;
}

.pagination-page-btn {
    min-width: 36px;
    padding: 0 0.5rem;
}

.pagination-icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 36px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    user-select: none;
}

/* ==========================================================================
   Responsive Utilities
   ========================================================================== */

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .mobile-toggle {
        display: block;
    }

    .content-body {
        padding: 1.25rem;
    }

    .topbar {
        padding: 0 1.25rem;
    }
}

@media (max-width: 640px) {
    .pagination-container {
        flex-direction: column;
        align-items: stretch;
        gap: 0.875rem;
    }

    .pagination-summary {
        text-align: center;
        justify-content: center;
    }

    .pagination-controls {
        justify-content: space-between;
        width: 100%;
    }

    .pagination-pages {
        display: none;
    }

    .pagination-btn-prev,
    .pagination-btn-next {
        flex: 1;
    }
}

