/* =========================================================
   Admin Panel — Base Stylesheet
   ========================================================= */

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

:root {
    --color-bg:          #0f1117;
    --color-surface:     #1a1d27;
    --color-surface-2:   #21253a;
    --color-border:      #2e3450;
    --color-primary:     #5b7cf6;
    --color-primary-h:   #4a68e8;
    --color-success:     #34d399;
    --color-warning:     #fbbf24;
    --color-danger:      #f87171;
    --color-text:        #e2e8f0;
    --color-muted:       #8892b0;
    --radius:            10px;
    --shadow:            0 8px 32px rgba(0,0,0,0.4);
    --font:              'Segoe UI', system-ui, -apple-system, sans-serif;
}

html[data-theme="light"] {
    --color-bg:          #f4f7fb;
    --color-surface:     #ffffff;
    --color-surface-2:   #edf2f8;
    --color-border:      #d6ddea;
    --color-primary:     #3358e6;
    --color-primary-h:   #2646c6;
    --color-success:     #0f9d63;
    --color-warning:     #b7791f;
    --color-danger:      #d64545;
    --color-text:        #172033;
    --color-muted:       #5e6b84;
    --shadow:            0 10px 28px rgba(16,24,40,0.08);
}

html, body {
    min-height: 100vh;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
}

/* ---- Auth / Install Card ---- */

.login-page,
.install-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 460px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px 36px;
}

.auth-header {
    text-align: center;
    margin-bottom: 28px;
    position: relative;
    padding-right: 110px;
}

.theme-toggle {
    gap: 8px;
    min-width: 92px;
}

.theme-toggle .theme-icon {
    font-size: 0.95rem;
    line-height: 1;
}

.theme-toggle .theme-label {
    white-space: nowrap;
}

.auth-theme-toggle {
    position: absolute;
    top: 0;
    right: 0;
}

.auth-logo {
    font-size: 2.4rem;
    margin-bottom: 12px;
}

.auth-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-text);
}

.auth-subtitle {
    color: var(--color-muted);
    margin-top: 4px;
    font-size: 0.9rem;
}

/* Steps indicator */
.steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
    font-size: 0.82rem;
}

.step {
    color: var(--color-muted);
    padding: 3px 12px;
    border-radius: 20px;
    background: var(--color-surface-2);
}

.step.active {
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
}

.step.done {
    background: var(--color-success);
    color: #0f1117;
    font-weight: 600;
}

.step-sep {
    color: var(--color-muted);
}

/* ---- Form ---- */

.auth-card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--color-text);
}

.form-group {
    margin-bottom: 18px;
}

.form-group-half {
    max-width: 140px;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-muted);
    margin-bottom: 6px;
}

label small {
    font-weight: 400;
    color: var(--color-muted);
    font-size: 0.78rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"] {
    width: 100%;
    padding: 10px 14px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text);
    font-size: 0.95rem;
    transition: border-color 0.15s;
    outline: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(91,124,246,0.15);
}

/* ---- Buttons ---- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 22px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, box-shadow 0.15s;
    border: none;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-h);
    box-shadow: 0 4px 16px rgba(91,124,246,0.35);
}

.btn-secondary {
    background: var(--color-surface-2);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

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

.btn-sm {
    padding: 6px 14px;
    font-size: 0.82rem;
}

.btn-full {
    width: 100%;
    margin-top: 8px;
}

/* ---- Alerts ---- */

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 18px;
    font-size: 0.88rem;
    line-height: 1.5;
}

.alert p { margin: 0; }
.alert p + p { margin-top: 4px; }

.alert-error {
    background: rgba(248,113,113,0.12);
    border: 1px solid rgba(248,113,113,0.35);
    color: #fca5a5;
}

.alert-warning {
    background: rgba(251,191,36,0.10);
    border: 1px solid rgba(251,191,36,0.30);
    color: #fcd34d;
}

.alert-success {
    background: rgba(52,211,153,0.10);
    border: 1px solid rgba(52,211,153,0.30);
    color: #6ee7b7;
}

/* ---- Install done ---- */

.install-done {
    text-align: center;
    padding: 16px 0;
}

.install-done-icon {
    font-size: 3rem;
    color: var(--color-success);
    margin-bottom: 12px;
}

.install-done h2 {
    font-size: 1.3rem;
    margin-bottom: 10px;
}

.install-done p {
    color: var(--color-muted);
    margin-bottom: 12px;
}

.hint {
    font-size: 0.82rem;
    background: rgba(251,191,36,0.08);
    border: 1px solid rgba(251,191,36,0.25);
    border-radius: 6px;
    padding: 10px 14px;
    color: #fcd34d;
    text-align: left;
}

.hint code {
    font-family: 'Courier New', monospace;
    background: rgba(0,0,0,0.3);
    padding: 1px 5px;
    border-radius: 3px;
}

/* =========================================================
   Dashboard
   ========================================================= */

.dashboard-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top nav */
.topnav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    height: 56px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topnav-brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--color-primary);
    letter-spacing: 0.01em;
}

.topnav-user {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.88rem;
    color: var(--color-muted);
}

/* Main content */
.dashboard-main {
    flex: 1;
    padding: 36px 32px;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
}

.dashboard-header {
    margin-bottom: 32px;
}

.dashboard-header h1 {
    font-size: 1.7rem;
    font-weight: 700;
}

.text-muted { color: var(--color-muted); }
.text-success { color: var(--color-success); }

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 22px 24px;
}

.stat-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-muted);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-detail {
    font-size: 0.78rem;
    color: var(--color-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Section */
.dashboard-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 18px;
}

/* Action grid */
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.action-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 28px 16px;
    text-align: center;
    text-decoration: none;
    color: var(--color-text);
    transition: border-color 0.15s, transform 0.15s;
}

.action-card:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
}

.action-icon {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.action-label {
    font-size: 0.85rem;
    font-weight: 600;
}

.news-preview {
    margin: 18px 0 16px;
    padding: 18px;
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(91,124,246,0.10), rgba(91,124,246,0.04));
    border: 1px solid var(--color-border);
}

.news-preview-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    align-items: center;
}

.news-preview-kicker {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--color-primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.news-preview-status {
    font-size: 0.78rem;
    color: var(--color-muted);
    font-weight: 600;
}

.news-preview-title {
    font-size: 1.22rem;
    line-height: 1.35;
    margin: 0 0 8px;
    color: var(--color-text);
}

.news-preview-meta {
    font-size: 0.78rem;
    color: var(--color-muted);
    margin-bottom: 10px;
}

.news-preview-excerpt {
    margin: 0 0 12px;
    color: var(--color-text);
    opacity: 0.9;
}

.news-preview-body {
    padding: 14px;
    border-radius: 8px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    min-height: 120px;
    white-space: normal;
    line-height: 1.7;
}

html[data-theme="light"] .news-preview {
    background: linear-gradient(180deg, rgba(51,88,230,0.08), rgba(51,88,230,0.03));
}

html[data-theme="light"] body,
html[data-theme="light"] .dashboard-page,
html[data-theme="light"] .login-page,
html[data-theme="light"] .install-page {
    background: var(--color-bg);
}

html[data-theme="light"] .topnav,
html[data-theme="light"] .auth-card,
html[data-theme="light"] .stat-card,
html[data-theme="light"] .action-card {
    box-shadow: var(--shadow);
}

html[data-theme="light"] [style*="background:#0f172a"] {
    background: var(--color-surface) !important;
    color: var(--color-text) !important;
}

html[data-theme="light"] [style*="background:rgba(255,255,255,0.03)"],
html[data-theme="light"] [style*="background:rgba(255,255,255,0.06)"] {
    background: var(--color-surface-2) !important;
}

html[data-theme="light"] [style*="border:1px solid rgba(255,255,255,0.08)"],
html[data-theme="light"] [style*="border-top:1px solid rgba(255,255,255,0.06)"] {
    border-color: var(--color-border) !important;
}

html[data-theme="light"] [style*="color:#94a3b8"],
html[data-theme="light"] [style*="color:rgba(255,255,255,0.45)"],
html[data-theme="light"] [style*="color:rgba(255,255,255,0.6)"] {
    color: var(--color-muted) !important;
}

html[data-theme="light"] [style*="color:#fff"],
html[data-theme="light"] [style*="color: rgba(255,255,255,0.65)"],
html[data-theme="light"] [style*="color:rgba(255,255,255,0.65)"] {
    color: var(--color-text) !important;
}

/* ---- Responsive ---- */
@media (max-width: 520px) {
    .auth-card { padding: 28px 20px; }
    .topnav { padding: 0 16px; }
    .dashboard-main { padding: 24px 16px; }
    .auth-header { padding-right: 0; }
    .auth-theme-toggle {
        position: static;
        margin-top: 10px;
    }
}
