/* === CSS Variables — Theme === */
:root,
[data-theme="dark"] {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #1e2130;
    --bg-input: #252838;
    --border: #2d3148;
    --text-primary: #e4e6ef;
    --text-secondary: #8f93a8;
    --text-muted: #5c6078;
    --accent: #5b8def;
    --accent-hover: #4a7de0;
    --success: #34d399;
    --danger: #f87171;
    --warning: #fbbf24;
    --navbar-bg: #151722;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

[data-theme="light"] {
    --bg-primary: #f5f6fa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f0f1f5;
    --border: #dcdee6;
    --text-primary: #1a1d2e;
    --text-secondary: #5c6078;
    --text-muted: #8f93a8;
    --accent: #4a7de0;
    --accent-hover: #3a6cd0;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --navbar-bg: #ffffff;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

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

/* === Navbar === */
.navbar {
    display: flex;
    align-items: center;
    padding: 0 24px;
    height: 56px;
    background: var(--navbar-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    margin-right: 32px;
}

.nav-links { display: flex; gap: 4px; }
.nav-links a {
    padding: 8px 16px;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}
.nav-links a:hover { color: var(--text-primary); background: var(--bg-secondary); text-decoration: none; }
.nav-links a.active { color: var(--accent); background: rgba(91,141,239,0.1); }

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

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

/* === Theme Toggle === */
.theme-toggle {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-icon { font-size: 18px; color: var(--text-primary); }

/* === Container === */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* === Cards === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
}

/* === Stats === */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-number { font-size: 32px; font-weight: 700; }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.stat-online .stat-number { color: var(--success); }
.stat-offline .stat-number { color: var(--danger); }
.stat-unknown .stat-number { color: var(--text-muted); }

/* === Providers Grid === */
.provider-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.provider-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.provider-name { font-size: 16px; font-weight: 600; margin-bottom: 12px; }

.provider-stats {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.badge {
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 20px;
    font-weight: 600;
}
.badge-total { background: var(--bg-input); color: var(--text-secondary); }
.badge-online { background: rgba(52,211,153,0.15); color: var(--success); }
.badge-offline { background: rgba(248,113,113,0.15); color: var(--danger); }
.badge-unknown { background: var(--bg-input); color: var(--text-muted); }

.provider-bar {
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    display: flex;
    overflow: hidden;
    margin-bottom: 12px;
}
.bar-online { background: var(--success); }
.bar-offline { background: var(--danger); }

.provider-actions { display: flex; gap: 8px; }

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    background: var(--bg-input);
    color: var(--text-primary);
    text-decoration: none;
}
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { opacity: 0.85; }
.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--text-secondary); color: var(--text-primary); }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }

/* === Forms === */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}

textarea { resize: vertical; font-family: 'Consolas', 'Monaco', monospace; font-size: 13px; }

.form-row { display: flex; gap: 16px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.form-hint code {
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

/* === Table === */
.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(91,141,239,0.04); }

.ip-cell { font-family: 'Consolas', 'Monaco', monospace; font-weight: 500; }

/* === Status Dot === */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}
.status-online { background: var(--success); box-shadow: 0 0 6px rgba(52,211,153,0.5); }
.status-offline { background: var(--danger); box-shadow: 0 0 6px rgba(248,113,113,0.5); }
.status-unknown { background: var(--text-muted); }

/* === Filters === */
.filters { margin-bottom: 16px; }
.filter-form { display: flex; gap: 12px; flex-wrap: wrap; }
.filter-form select { width: auto; min-width: 180px; }

/* === Progress === */
.progress-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s;
    width: 0%;
}

#progress-text { font-size: 13px; color: var(--text-secondary); white-space: nowrap; }

/* === Actions Bar === */
.actions-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.actions-cell { white-space: nowrap; }
.actions-cell .btn { margin-right: 4px; }

/* === Alerts === */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-error { background: rgba(248,113,113,0.15); color: var(--danger); border: 1px solid rgba(248,113,113,0.3); }
.alert-success { background: rgba(52,211,153,0.15); color: var(--success); border: 1px solid rgba(52,211,153,0.3); }

/* === Login === */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px 32px;
    box-shadow: var(--shadow);
}

.login-header { text-align: center; margin-bottom: 32px; }
.login-header h1 { font-size: 24px; color: var(--accent); }
.login-header p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

/* === Install === */
.install-log { margin-top: 16px; }
.install-msg {
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 6px;
    font-size: 14px;
}
.install-msg.success { background: rgba(52,211,153,0.1); color: var(--success); }
.install-msg.error { background: rgba(248,113,113,0.1); color: var(--danger); }

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

/* === Count === */
.count { font-weight: 400; color: var(--text-muted); font-size: 0.7em; }

h1, h2 { margin-bottom: 16px; }

/* === Daemon Indicator === */
.daemon-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.daemon-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.daemon-active .daemon-dot {
    background: var(--success);
    box-shadow: 0 0 6px rgba(52,211,153,0.6);
    animation: pulse-dot 2s infinite;
}

.daemon-inactive .daemon-dot {
    background: var(--text-muted);
}

.daemon-text { color: var(--text-secondary); }
.daemon-last { color: var(--text-muted); margin-left: 4px; }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* === Auto-refresh animations === */
.number-updated {
    animation: flash-number 0.6s ease;
}

@keyframes flash-number {
    0% { transform: scale(1); }
    30% { transform: scale(1.15); color: var(--accent); }
    100% { transform: scale(1); }
}

.row-updated {
    animation: flash-row 2s ease;
}

@keyframes flash-row {
    0% { background: rgba(91,141,239,0.15); }
    100% { background: transparent; }
}

.stat-number, .badge {
    transition: all 0.3s ease;
}

/* === Responsive === */
@media (max-width: 768px) {
    .navbar { padding: 0 12px; flex-wrap: wrap; height: auto; min-height: 56px; }
    .nav-links { order: 3; width: 100%; padding: 8px 0; }
    .container { padding: 16px; }
    .form-row { flex-direction: column; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .provider-grid { grid-template-columns: 1fr; }
    .filter-form { flex-direction: column; }
    .filter-form select { width: 100%; }
}
