/* ============================================================
   WCS Panel — Layout & Component Styles
   ============================================================ */

/* ── Auth pages ──────────────────────────────────────────── */
.auth-body {
    background: var(--bg-soft);
    min-height: 100vh;
}

.auth-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
}

.auth-layout-centered {
    grid-template-columns: 1fr;
    place-items: center;
    padding: 2rem;
}

.auth-left {
    background: var(--navy);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    position: relative;
    overflow: hidden;
}
.auth-left::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(30,136,255,.18) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(20,184,166,.15) 0%, transparent 55%);
}
.auth-left-content {
    position: relative;
    z-index: 1;
    max-width: 380px;
}
.auth-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2.5rem;
}
.brand-icon-lg {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: rgba(255,255,255,.08);
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,.12);
}
.auth-logo-text {
    font-size: 1.75rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
}
.auth-tagline {
    font-size: 1.25rem;
    color: rgba(255,255,255,.65);
    line-height: 1.5;
    margin-bottom: 2.5rem;
}
.auth-tagline strong { color: rgba(255,255,255,.9); }
.auth-features { display: flex; flex-direction: column; gap: 0.85rem; }
.auth-feature {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: rgba(255,255,255,.75);
    font-size: 0.9375rem;
}
.feature-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.feature-dot.ok { background: var(--primary-2); box-shadow: 0 0 8px rgba(20,184,166,.5); }

.auth-right {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg-soft);
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
}
.auth-card-wide { max-width: 780px; }
.auth-card-header { margin-bottom: 2rem; }
.auth-card-header h2 {
    font-size: 1.625rem;
    font-weight: 800;
    margin-bottom: 0.375rem;
    margin-top: 0.5rem;
}
.auth-card-header p { font-size: 0.9375rem; }
.auth-icon-wrap {
    width: 52px;
    height: 52px;
    background: rgba(30,136,255,.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}
.auth-form { display: flex; flex-direction: column; gap: 1rem; }

/* TOTP setup grid */
.totp-setup-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2.5rem;
    align-items: start;
}
.totp-qr-section { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
.qr-box {
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 2px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.qr-box img { display: block; }
.qr-label { font-size: 0.8125rem; color: var(--muted); text-align: center; }
.secret-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    width: 100%;
}
.secret-label { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.secret-code {
    font-size: 0.8125rem;
    font-family: 'Fira Code', monospace;
    color: var(--navy);
    word-break: break-all;
    flex: 1;
    background: none;
    border: none;
    padding: 0;
}
.btn-copy {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    padding: 0.2rem;
    display: flex;
    align-items: center;
    transition: color var(--transition);
}
.btn-copy:hover { color: var(--primary); }

.totp-input {
    text-align: center;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 0.5rem;
    padding: 0.75rem;
    font-family: 'Fira Code', monospace;
}

.setup-steps { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.5rem; }
.setup-step { display: flex; gap: 0.75rem; align-items: flex-start; }
.step-num {
    width: 26px;
    height: 26px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 0.1rem;
}
.step-text { font-size: 0.9rem; color: var(--muted); }
.step-text strong { color: var(--text); }

/* ── Panel layout ────────────────────────────────────────── */
.panel-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.panel-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 60px;
    padding: 0 1.5rem;
    background: var(--navy);
    border-bottom: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 2px 12px rgba(0,0,0,.25);
}

.topbar-brand { flex-shrink: 0; }
.brand-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: #fff;
}
.brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,.08);
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,.1);
    flex-shrink: 0;
}
.brand-name {
    font-size: 1rem;
    color: rgba(255,255,255,.75);
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.brand-name strong { color: #fff; font-weight: 700; }

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 1rem;
    flex: 1;
    min-width: 0;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.9rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(255,255,255,.6);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}
.nav-item:hover {
    background: rgba(255,255,255,.08);
    color: rgba(255,255,255,.9);
}
.nav-item.active {
    background: rgba(30,136,255,.25);
    color: #fff;
}
.nav-label { /* always visible by default */ }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    margin-left: auto;
}
.user-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.75rem;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 99px;
}
.user-avatar {
    width: 26px;
    height: 26px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}
.user-email {
    font-size: 0.8125rem;
    color: rgba(255,255,255,.8);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.topbar-actions .btn-outline {
    color: rgba(255,255,255,.7);
    border-color: rgba(255,255,255,.25);
    font-size: 0.8125rem;
    padding: 0.35rem 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.topbar-actions .btn-outline:hover {
    background: rgba(255,255,255,.12);
    border-color: rgba(255,255,255,.4);
    color: #fff;
}

.panel-main {
    flex: 1;
    padding: 2rem 2rem 1rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* ── Page header ─────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
}
.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}
.page-subtitle { font-size: 0.9rem; color: var(--muted); }

/* ── Stat cards ──────────────────────────────────────────── */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon-red    { background: rgba(229,62,62,.1); color: var(--red); }
.stat-icon-blue   { background: rgba(30,136,255,.1); color: var(--primary); }
.stat-icon-teal   { background: rgba(20,184,166,.1); color: var(--primary-2); }
.stat-icon-purple { background: rgba(128,90,213,.1); color: var(--purple); }

.stat-body { flex: 1; }
.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 0.3rem;
}
.stat-value {
    font-size: 1.625rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
    line-height: 1;
}
.stat-sub {
    font-size: 0.8125rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.stat-bar-wrap { margin-top: 0.25rem; }
.stat-bar {
    height: 6px;
    background: var(--line);
    border-radius: 99px;
    overflow: hidden;
}
.stat-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 99px;
    transition: width 0.6s ease;
}
.stat-bar-teal  { background: var(--primary-2); }

/* ── Charts ──────────────────────────────────────────────── */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}
.chart-card .card-header { padding: 0.875rem 1.25rem; }
.chart-hint { font-size: 0.75rem; color: var(--muted); font-weight: 400; }
.chart-wrap { padding: 1rem 1.25rem 1.25rem; }
.chart-doughnut-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
}
.doughnut-center {
    position: absolute;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
    pointer-events: none;
}

/* ── Sites section ───────────────────────────────────────── */
.sites-section { margin-bottom: 2rem; }
.section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}
.section-sub { font-size: 0.875rem; color: var(--muted); }

/* Sites table — scrollable on mobile */
.sites-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.sites-table-wrap table {
    min-width: 640px;
}

.domain-cell {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.domain-icon {
    width: 30px;
    height: 30px;
    background: rgba(30,136,255,.1);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
}
.domain-name { font-weight: 600; color: var(--text); }
.domain-vhost { font-size: 0.75rem; color: var(--muted); }

.ssl-ok   { color: var(--green); font-weight: 600; }
.ssl-warn { color: var(--orange); font-weight: 600; }
.ssl-bad  { color: var(--red); font-weight: 600; }
.ssl-none { color: var(--muted); }

.table-loading,
.table-error,
.table-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 3rem 2rem;
    color: var(--muted);
    font-size: 0.9375rem;
}
.table-error { flex-direction: row; color: var(--red); }

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--line);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.spinner-sm {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11,30,58,.55);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    background: var(--bg-card);
    border-radius: 14px;
    box-shadow: 0 16px 48px rgba(0,0,0,.2);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.2s ease;
}
.modal-sm { max-width: 380px; }
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}
.modal-header h3 { font-size: 1.0625rem; }
.modal-header-danger { border-bottom-color: rgba(229,62,62,.2); }
.modal-header-danger h3 { color: var(--red); }

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

.modal-body {
    padding: 1.5rem;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--line);
    background: var(--bg-soft);
    border-radius: 0 0 14px 14px;
    position: sticky;
    bottom: 0;
}

/* ── Toast ───────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.875rem 1.25rem;
    background: var(--navy);
    color: #fff;
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,.25);
    font-size: 0.875rem;
    font-weight: 500;
    min-width: 280px;
    max-width: 420px;
    pointer-events: all;
    animation: toastIn 0.25s ease;
}
.toast.toast-success { border-left: 4px solid var(--primary-2); }
.toast.toast-error   { border-left: 4px solid var(--red); }
.toast.toast-info    { border-left: 4px solid var(--primary); }
@keyframes toastIn {
    from { transform: translateX(110%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(110%); opacity: 0; }
}

/* ── Footer ──────────────────────────────────────────────── */
.panel-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--line);
    padding: 0.875rem 2rem;
}
.footer-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8125rem;
    color: var(--muted);
}
.footer-sep { color: var(--line); }

/* ── Checkbox toggle ─────────────────────────────────────── */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    padding: 0.5rem 0;
}
.form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}
.form-check-label {
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}
.form-check-hint {
    font-size: 0.8125rem;
    color: var(--muted);
    margin-top: 0.2rem;
    margin-left: 1.6rem;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1100px) {
    .charts-grid { grid-template-columns: 1fr 1fr; }
    .chart-card:first-child { grid-column: span 2; }
}

@media (max-width: 768px) {
    /* Auth */
    .auth-layout { grid-template-columns: 1fr; }
    .auth-left { display: none; }
    .totp-setup-grid { grid-template-columns: 1fr; }

    /* Topbar */
    .panel-topbar { padding: 0 1rem; gap: 0.5rem; height: 56px; }
    .topbar-nav { margin-left: 0.5rem; gap: 0; }
    .nav-item { padding: 0.45rem 0.6rem; gap: 0; }
    .nav-label { display: none; }
    .user-email { display: none; }
    .user-pill { padding: 0.3rem 0.4rem; }
    .topbar-actions { gap: 0.5rem; }
    .topbar-actions .btn-outline { padding: 0.35rem 0.6rem; gap: 0; }

    /* Content */
    .panel-main { padding: 1.25rem 1rem; }
    .page-header { flex-direction: column; align-items: stretch; }
    .page-header .btn { align-self: flex-start; }

    /* Stats */
    .stat-cards { grid-template-columns: 1fr 1fr; }

    /* Charts */
    .charts-grid { grid-template-columns: 1fr; }
    .chart-card:first-child { grid-column: span 1; }

    /* Sites */
    .section-header { flex-direction: column; align-items: flex-start; }

    /* Modals */
    .modal-overlay { padding: 0.75rem; align-items: flex-end; }
    .modal { max-width: 100%; border-radius: 14px 14px 0 0; max-height: 85vh; }
    .modal-sm { max-width: 100%; }
    @keyframes slideUp {
        from { transform: translateY(100%); opacity: 1; }
        to   { transform: translateY(0); opacity: 1; }
    }
}

@media (max-width: 480px) {
    /* Topbar: hide nav entirely, keep brand icon only */
    .brand-name { display: none; }
    .topbar-nav { display: none; }
    .panel-topbar { padding: 0 0.875rem; }

    /* Stats: single column */
    .stat-cards { grid-template-columns: 1fr; }

    /* Modal footer: full-width buttons */
    .modal-footer { flex-direction: column-reverse; }
    .modal-footer .btn { width: 100%; justify-content: center; }

    /* Toast: full width */
    #toast-container { left: 0.75rem; right: 0.75rem; bottom: 0.75rem; }
    .toast { min-width: unset; width: 100%; max-width: 100%; }
}
