/* ============================================
   UPKEEP — Global Styles
   ============================================ */

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

:root {
    --bg: #0a0a0f;
    --bg-card: #12121a;
    --bg-card-hover: #1a1a26;
    --bg-input: #0e0e16;
    --border: #1e1e2e;
    --border-focus: #22c55e;
    --text: #e4e4e7;
    --text-muted: #71717a;
    --text-dim: #52525b;
    --accent: #22c55e;
    --accent-glow: rgba(34, 197, 94, 0.15);
    --accent-dark: #16a34a;
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.15);
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.15);
    --info: #3b82f6;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

/* Light theme */
[data-theme="light"] {
    --bg: #f5f5f7;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f0f5;
    --bg-input: #f5f5f7;
    --border: #e2e2e8;
    --border-focus: #22c55e;
    --text: #1a1a2e;
    --text-muted: #6b6b80;
    --text-dim: #9b9baa;
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
}
[data-theme="light"] .toast-success { background: #dcfce7; color: #166534; border-color: rgba(34,197,94,0.3); }
[data-theme="light"] .toast-error { background: #fee2e2; color: #991b1b; border-color: rgba(239,68,68,0.3); }

html { scroll-behavior: smooth; }

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

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

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: var(--accent-dark); box-shadow: 0 8px 30px var(--accent-glow); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

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

.btn-sm { padding: 8px 16px; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.form-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.form-input::placeholder { color: var(--text-dim); }
.form-input:focus { border-color: var(--accent); }
textarea.form-input { resize: vertical; min-height: 80px; line-height: 1.5; }

/* ---- AUTH LAYOUT ---- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px;
}
.auth-logo {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.auth-logo .dot {
    width: 10px; height: 10px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 12px var(--accent);
}
.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 32px;
}
.auth-divider {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.8rem;
    margin: 20px 0;
    position: relative;
}
.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.form-error {
    background: var(--danger-glow);
    border: 1px solid rgba(239,68,68,0.3);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 20px;
    display: none;
}

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

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transition: width 0.25s ease;
    overflow: hidden;
}
.sidebar.collapsed {
    width: 68px;
}
.sidebar.collapsed .sidebar-label {
    display: none;
}
.sidebar.collapsed .sidebar-nav a {
    justify-content: center;
    padding: 12px 0;
}
.sidebar.collapsed .sidebar-nav a .icon {
    width: auto;
    font-size: 1.2rem;
}
.sidebar.collapsed .sidebar-footer {
    padding: 16px 8px;
}
.sidebar.collapsed .user-info {
    justify-content: center;
}
.sidebar.collapsed .sidebar-logo {
    justify-content: center;
    padding: 0;
}
.sidebar.collapsed .sidebar-top {
    flex-direction: column;
    gap: 12px;
}
.sidebar.collapsed .badge {
    position: absolute;
    top: 4px;
    right: 8px;
    margin: 0 !important;
    font-size: 0.6rem;
    padding: 2px 6px;
}
.sidebar.collapsed .sidebar-nav a {
    position: relative;
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    margin-bottom: 32px;
}
.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}
.sidebar-toggle:hover {
    color: var(--text);
    background: rgba(255,255,255,0.05);
}
.sidebar.collapsed .sidebar-toggle {
    padding: 4px;
}

.sidebar-logo {
    font-size: 1.3rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-logo .dot {
    width: 10px; height: 10px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 12px var(--accent);
}
.sidebar-nav { flex: 1; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
}
.sidebar-nav a:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.sidebar-nav a.active { color: var(--accent); background: var(--accent-glow); border-right: 2px solid var(--accent); }
.sidebar-nav a .icon { font-size: 1.1rem; width: 24px; text-align: center; }

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--accent-glow);
    border: 1px solid rgba(34,197,94,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--accent);
}
.user-name { font-size: 0.85rem; font-weight: 600; }
.user-plan { font-size: 0.75rem; color: var(--text-muted); text-transform: capitalize; }

/* Main content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px 40px;
    transition: margin-left 0.25s ease;
}
.sidebar.collapsed ~ .main-content {
    margin-left: 68px;
}

/* Top bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
}
.top-bar h1 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}
.top-bar-actions { display: flex; gap: 12px; align-items: center; }

/* ---- STATS CARDS ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.stat-value {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -1px;
}
.stat-value.green { color: var(--accent); }
.stat-value.red { color: var(--danger); }
.stat-value.yellow { color: var(--warning); }
.stat-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ---- SITE LIST ---- */
.sites-table {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.sites-table-header {
    display: grid;
    grid-template-columns: 2fr 0.8fr 0.8fr 0.8fr 1fr 1fr 180px;
    gap: 16px;
    padding: 14px 24px;
    align-items: center;
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}
.sites-table-header > div:not(:first-child):not(:last-child),
.site-row > div:not(:first-child):not(:last-child) {
    text-align: center;
}
.site-row {
    display: grid;
    grid-template-columns: 2fr 0.8fr 0.8fr 0.8fr 1fr 1fr 180px;
    gap: 16px;
    padding: 18px 24px;
    align-items: center;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.site-row:last-child { border-bottom: none; }
.site-row:hover { background: rgba(255,255,255,0.02); }

.site-info { display: flex; align-items: center; gap: 12px; }
.status-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.up { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.status-dot.down { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.status-dot.degraded { background: var(--warning); box-shadow: 0 0 8px var(--warning); }
.status-dot.pending { background: var(--text-dim); animation: pulse-pending 1.5s ease-in-out infinite; }
@keyframes pulse-pending {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}
.pending-pulse {
    animation: pulse-pending 1.5s ease-in-out infinite;
    color: var(--text-dim);
}

.site-name { font-weight: 600; font-size: 0.9rem; }
.site-url { font-size: 0.8rem; color: var(--text-muted); }

.badge {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-up { background: var(--accent-glow); color: var(--accent); }
.badge-down { background: var(--danger-glow); color: var(--danger); }
.badge-degraded { background: var(--warning-glow); color: var(--warning); }
.badge-pending { background: rgba(82,82,91,0.2); color: var(--text-dim); }

.ssl-good { color: var(--accent); font-weight: 600; font-size: 0.85rem; }
.ssl-warning { color: var(--warning); font-weight: 600; font-size: 0.85rem; }
.ssl-bad { color: var(--danger); font-weight: 600; font-size: 0.85rem; }

.speed-value { font-weight: 600; font-size: 0.85rem; }
.speed-fast { color: var(--accent); }
.speed-medium { color: var(--warning); }
.speed-slow { color: var(--danger); }

.site-actions { display: flex; gap: 8px; }
.icon-btn {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.icon-btn:hover { background: var(--bg-card-hover); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-glow); color: var(--danger); border-color: rgba(239,68,68,0.3); }

/* ---- MODAL ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 24px;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow);
}
.modal h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.modal p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 28px;
}
.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 28px;
}

/* ---- ALERTS LIST ---- */
.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.alert-item:last-child { border-bottom: none; }
.alert-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.alert-icon.down { background: var(--danger-glow); }
.alert-icon.ssl { background: var(--warning-glow); }
.alert-icon.up { background: var(--accent-glow); }
.alert-message { font-size: 0.9rem; font-weight: 500; }
.alert-time { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* ---- EMPTY STATE ---- */
.empty-state {
    text-align: center;
    padding: 80px 24px;
}
.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.3;
}
.empty-state h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.empty-state p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .sites-table-header,
    .site-row { grid-template-columns: 2fr 1fr 1fr auto; }
    .site-row > :nth-child(3),
    .site-row > :nth-child(5),
    .sites-table-header > :nth-child(3),
    .sites-table-header > :nth-child(5) { display: none; }
}

/* Sidebar tooltip on hover when collapsed */
.sidebar.collapsed .sidebar-nav a:hover::after {
    content: attr(title);
    position: absolute;
    left: 68px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: var(--shadow);
    z-index: 100;
}

/* Notification popup */
.notification-popup {
    position: fixed;
    left: 76px;
    bottom: 80px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    z-index: 100;
    max-width: 300px;
    animation: slideIn 0.3s ease;
    display: none;
}
.notification-popup.visible { display: block; }
.notification-popup .notif-header {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.notification-popup .notif-message {
    font-size: 0.85rem;
    font-weight: 500;
}
.notification-popup .notif-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0 !important; padding: 24px 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ---- LOADING SPINNER ---- */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- TOAST ---- */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease;
    max-width: 360px;
}
.toast-success { background: #065f46; color: #a7f3d0; border: 1px solid rgba(34,197,94,0.3); }
.toast-error { background: #7f1d1d; color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ---- REPORTS ---- */
.reports-header {
    grid-template-columns: 2fr 1.5fr 1fr 1fr 1fr auto;
}
.report-row {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 1fr 1fr auto;
    gap: 16px;
    padding: 18px 24px;
    align-items: center;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.report-row:last-child { border-bottom: none; }
.report-row:hover { background: rgba(255,255,255,0.02); }

.report-period {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.report-uptime {
    font-weight: 700;
    font-size: 0.9rem;
}
.report-uptime.excellent { color: var(--accent); }
.report-uptime.good { color: var(--warning); }
.report-uptime.poor { color: var(--danger); }

/* Pro gate */
.pro-gate {
    text-align: center;
    padding: 60px 24px;
}
.pro-gate h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
}
.pro-gate p {
    color: var(--text-muted);
    margin-bottom: 20px;
}
.pro-badge {
    display: inline-flex;
    padding: 3px 8px;
    border-radius: 100px;
    font-size: 0.65rem;
    font-weight: 700;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #000;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Report generation progress */
.report-progress {
    margin-top: 16px;
    display: none;
}
.report-progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}
.report-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}
.report-progress-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 8px;
    text-align: center;
}

/* ---- TOGGLE SWITCH ---- */
.toggle-checkbox { display: none; }
.toggle-label { cursor: pointer; }
.toggle-switch {
    width: 44px; height: 24px;
    background: var(--border);
    border-radius: 12px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
    display: inline-block;
}
.toggle-switch::after {
    content: '';
    width: 18px; height: 18px;
    background: var(--text-muted);
    border-radius: 50%;
    position: absolute;
    top: 3px; left: 3px;
    transition: all 0.2s;
}
.toggle-checkbox:checked + .toggle-switch {
    background: var(--accent-glow);
}
.toggle-checkbox:checked + .toggle-switch::after {
    background: var(--accent);
    transform: translateX(20px);
}

@media (max-width: 1024px) {
    .reports-header,
    .report-row { grid-template-columns: 2fr 1.5fr 1fr auto; }
    .report-row > :nth-child(4),
    .report-row > :nth-child(5),
    .reports-header > :nth-child(4),
    .reports-header > :nth-child(5) { display: none; }
}
