/* ═══════════════════════════════════════════════════════════════
   Plesk Login Portal – App Stylesheet
   edugroup CI: Lexend · #3b2b69 · pill inputs · 20px cards
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────────── */
:root {
    --eg-dark:          #3b2b69;
    --eg-medium:        #382a67;
    --eg-bright:        #e2e5fe;
    --eg-border:        #c8c3db;
    --eg-border-light:  #d8d5e1;
    --eg-text-muted:    #c8c3db;
    --eg-bg-light:      #f4f3f8;

    --color-success:    #00a100;
    --color-warning:    #ffcc00;
    --color-danger:     #e53935;
    --color-info:       #0dcaf0;

    --radius-pill:  30px;
    --radius-card:  20px;
    --radius-input: 30px;

    --header-h:     56px;
    --footer-h:     150px;

    --shadow-card:  0 2px 16px rgba(59,43,105,.10);
    --transition:   0.18s ease;
}

/* ── Reset / base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-family: 'Lexend', 'Segoe UI', system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    color: var(--eg-dark);
    background: var(--eg-bright);
}

body { min-height: 100vh; }
a { color: var(--eg-dark); }
a:hover { opacity: .8; }
img { display: block; max-width: 100%; }
code { font-family: monospace; font-size: .9em; background: var(--eg-bg-light); padding: 1px 5px; border-radius: 4px; }

/* ── Page wrapper ──────────────────────────────────────────────── */
.page-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.page-center .main { justify-content: center; }
.page-center { align-items: center; justify-content: center; }
.text-center { text-align: center; }

/* ── Topbar ────────────────────────────────────────────────────── */
.topbar {
    background: var(--eg-dark);
    color: #fff;
    height: var(--header-h);
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.topbar-inner {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 clamp(12px, 3vw, 40px);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}
.topbar-logo {
    height: clamp(26px, 4vh, 36px);
    width: auto;
}
.topbar-title {
    font-size: clamp(.9rem, 2vw, 1.1rem);
    font-weight: 700;
    letter-spacing: .04em;
    color: #fff;
    white-space: nowrap;
}
.topbar-subtitle {
    display: block;
    font-size: .72rem;
    color: rgba(255,255,255,.7);
    line-height: 1;
    margin-top: 2px;
}
.topbar-logout {
    font-size: .78rem;
    color: #c8c3db;
    text-decoration: none;
    border: 1px dashed rgba(255,255,255,.35);
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    transition: color var(--transition), border-color var(--transition);
}
.topbar-logout:hover { color: #fff; border-color: rgba(255,255,255,.7); opacity: 1; }

/* ── Footer ────────────────────────────────────────────────────── */
.footer {
    background: var(--eg-medium);
    color: #fff;
    flex-shrink: 0;
    margin-top: auto;
}
.footer-row {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 clamp(12px, 3vw, 40px);
    display: flex;
    align-items: center;
    gap: 16px;
}
.footer-top {
    padding-top: clamp(14px, 2vh, 22px);
    padding-bottom: clamp(10px, 1.5vh, 16px);
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.footer-bottom {
    padding-top: clamp(8px, 1vh, 12px);
    padding-bottom: clamp(10px, 1.5vh, 16px);
    border-top: 1px solid rgba(255,255,255,.12);
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.footer-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}
.footer-logo { height: clamp(36px, 5vh, 52px); width: auto; }
.footer-tagline {
    font-size: clamp(.72rem, 1.3vw, .82rem);
    color: rgba(255,255,255,.7);
    font-weight: 400;
}
.footer-sites {
    display: flex;
    align-items: center;
    gap: clamp(10px, 2vw, 24px);
    flex-wrap: wrap;
}
.footer-sites a {
    color: rgba(255,255,255,.75);
    text-decoration: none;
    font-size: clamp(.72rem, 1.3vw, .82rem);
    font-weight: 500;
    transition: color var(--transition);
}
.footer-sites a:hover { color: #fff; opacity: 1; }
.footer-copy {
    font-size: clamp(.62rem, 1.2vw, .75rem);
    color: rgba(255,255,255,.5);
}
.footer-legal {
    display: flex;
    align-items: center;
    gap: clamp(10px, 2vw, 22px);
    flex-wrap: wrap;
}
.footer-legal a {
    color: rgba(255,255,255,.65);
    text-decoration: none;
    font-size: clamp(.62rem, 1.2vw, .75rem);
    transition: color var(--transition);
}
.footer-legal a:hover { color: #fff; opacity: 1; }
.footer-ooe { height: 28px; width: auto; margin-left: 6px; }

/* ── Main / center ─────────────────────────────────────────────── */
.main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(24px, 6vh, 60px) clamp(16px, 4vw, 40px);
}

/* ── Login box ─────────────────────────────────────────────────── */
.loginbox {
    background: #fff;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: clamp(24px, 4vh, 44px) clamp(20px, 4vw, 40px);
    width: 100%;
    max-width: 400px;
}
.loginbox h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--eg-dark);
    margin-bottom: 1.2rem;
}

/* ── Forms ─────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
    display: block;
    font-size: .82rem;
    font-weight: 500;
    color: var(--eg-dark);
    margin-bottom: 5px;
}
.form-label small { font-weight: 400; color: #888; }
.form-input {
    width: 100%;
    padding: 9px 16px;
    border: 1px solid var(--eg-border);
    border-radius: var(--radius-input);
    font-family: inherit;
    font-size: .92rem;
    color: var(--eg-dark);
    background: #fff;
    outline: none;
    transition: border-color var(--transition);
}
.form-input:focus { border-color: var(--eg-dark); }
.form-input:disabled { opacity: .45; cursor: not-allowed; background: var(--eg-bg-light); }
.form-textarea {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--eg-border);
    border-radius: 16px;
    font-family: inherit;
    font-size: .9rem;
    color: var(--eg-dark);
    resize: vertical;
    outline: none;
    transition: border-color var(--transition);
    min-height: 80px;
}
.form-textarea:focus { border-color: var(--eg-dark); box-shadow: 0 0 0 2px rgba(59,43,105,.12); }
.form-hint { font-size: .78rem; color: #888; margin-top: 4px; line-height: 1.4; }
.form-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.form-group-grow { flex: 1; min-width: 160px; }
.form-group-port { width: 90px; flex-shrink: 0; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }

/* Toggle label */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: .9rem;
    font-weight: 500;
}
.toggle-label input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; border-radius: 4px; }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 22px;
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-size: .9rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: 2px solid transparent;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    white-space: nowrap;
}
.btn-primary {
    background: var(--eg-dark);
    color: #fff;
    border-color: var(--eg-dark);
}
.btn-primary:hover { background: #fff; color: var(--eg-dark); opacity: 1; }
.btn-outline {
    background: #fff;
    color: var(--eg-dark);
    border-color: var(--eg-border);
}
.btn-outline:hover { border-color: var(--eg-dark); opacity: 1; }
.btn-danger {
    background: var(--color-danger);
    color: #fff;
    border-color: var(--color-danger);
}
.btn-danger:hover { background: #fff; color: var(--color-danger); opacity: 1; }
.btn-full  { width: 100%; }
.btn-sm    { padding: 5px 14px; font-size: .8rem; }

/* ── Alerts ────────────────────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: .88rem;
    margin-bottom: 14px;
    line-height: 1.5;
}
.alert-error   { background: #fde8e8; color: #b71c1c; border: 1px solid #f5c6c6; }
.alert-success { background: #e8f5e9; color: #1b5e20; border: 1px solid #c3e6cb; }
.alert-warning { background: #fffde7; color: #5d4037; border: 1px solid #ffe082; }

/* ── Flash wrapper (admin) ─────────────────────────────────────── */
.flash-wrap {
    max-width: 1200px;
    margin: 16px auto 0;
    padding: 0 clamp(12px, 3vw, 32px);
}

/* ── Server selection ──────────────────────────────────────────── */
.select-hint { font-size: .88rem; color: #555; margin-bottom: 1rem; line-height: 1.5; }
.server-list { display: flex; flex-direction: column; gap: 8px; }
.server-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border: 1px solid var(--eg-border);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}
.server-option:has(input:checked) { border-color: var(--eg-dark); background: var(--eg-bright); }
.server-option input { flex-shrink: 0; width: 16px; height: 16px; cursor: pointer; accent-color: var(--eg-dark); }
.server-name { font-weight: 600; font-size: .9rem; }
.server-host { font-size: .78rem; color: #888; margin-left: auto; font-family: monospace; }

/* ── Redirect spinner ──────────────────────────────────────────── */
.redirect-spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--eg-bright);
    border-top-color: var(--eg-dark);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Captcha ───────────────────────────────────────────────────── */
.captcha-wrap { display: flex; justify-content: center; }

/* ── Setup ─────────────────────────────────────────────────────── */
.main-setup { align-items: flex-start; padding-top: clamp(24px, 4vh, 48px); }
.setup-box {
    background: #fff;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: clamp(24px, 4vh, 44px) clamp(20px, 4vw, 40px);
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
}
.setup-box h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: .8rem; }
.setup-hint   { font-size: .86rem; color: #555; margin-bottom: 1.2rem; line-height: 1.55; }

/* Step indicator */
.setup-steps {
    display: flex;
    align-items: center;
    margin-bottom: 1.8rem;
    gap: 0;
    flex-wrap: nowrap;
    overflow: hidden;
}
.setup-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
}
.step-num {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--eg-bg-light);
    color: #aaa;
    font-size: .8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.setup-step.active .step-num  { background: var(--eg-dark); color: #fff; }
.setup-step.done   .step-num  { background: var(--color-success); color: #fff; }
.step-label { font-size: .7rem; color: #aaa; text-align: center; }
.setup-step.active .step-label { color: var(--eg-dark); font-weight: 600; }
.setup-step.done   .step-label { color: var(--color-success); }
.step-divider { flex: 1; height: 2px; background: var(--eg-border-light); flex-shrink: 1; max-width: 32px; }

/* ── Admin nav ─────────────────────────────────────────────────── */
.admin-nav {
    background: #fff;
    border-bottom: 1px solid var(--eg-border-light);
    flex-shrink: 0;
}
.admin-nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 clamp(12px, 3vw, 32px);
    display: flex;
    gap: 4px;
    overflow-x: auto;
}
.admin-nav-item {
    display: inline-block;
    padding: 13px 18px;
    font-size: .88rem;
    font-weight: 500;
    color: #777;
    text-decoration: none;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    transition: color var(--transition), border-color var(--transition);
}
.admin-nav-item:hover { color: var(--eg-dark); opacity: 1; }
.admin-nav-item.active { color: var(--eg-dark); border-bottom-color: var(--eg-dark); font-weight: 700; }

/* ── Admin main ────────────────────────────────────────────────── */
.admin-body { background: var(--eg-bg-light); }
.admin-main { flex: 1; padding: clamp(16px, 3vh, 32px) clamp(12px, 3vw, 32px); }
.admin-content { max-width: 1200px; margin: 0 auto; }
.admin-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
    gap: 10px;
}
.admin-page-header h1 {
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    font-weight: 800;
    color: var(--eg-dark);
}
.muted { color: #999; font-size: .85rem; }

/* Admin cards */
.admin-card {
    background: #fff;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}
.admin-card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--eg-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}
.admin-card-header h2 {
    font-size: .95rem;
    font-weight: 700;
    color: var(--eg-dark);
    margin: 0;
}
.admin-card form,
.admin-card > *:not(.admin-card-header):not(.table-wrap) {
    padding: 16px 20px;
}
.admin-card .table-wrap { padding: 0; }

/* Stat grid */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: #fff;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 20px 24px;
    text-align: center;
}
.stat-value { font-size: 2rem; font-weight: 800; color: var(--eg-dark); line-height: 1; }
.stat-label { font-size: .8rem; color: #888; margin-top: 6px; }
.empty-hint { padding: 24px 20px; color: #aaa; font-size: .9rem; text-align: center; }

/* ── Tables ────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .86rem;
}
.data-table th {
    padding: 10px 16px;
    text-align: left;
    font-size: .76rem;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid var(--eg-border-light);
    background: #fafafa;
    white-space: nowrap;
}
.data-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--eg-border-light);
    vertical-align: middle;
}
.data-table tbody tr:hover td { background: #fafbff; }
.data-table tbody tr:last-child td { border-bottom: none; }
.td-mono  { font-family: monospace; font-size: .82rem; }
.td-small { font-size: .78rem; }
.td-time  { white-space: nowrap; color: #666; }
.edit-row td { background: #fafbff; padding: 16px; }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.badge-found      { background: #e8f5e9; color: #1b5e20; }
.badge-redirected { background: #e3f2fd; color: #0d47a1; }
.badge-not_found  { background: #fde8e8; color: #b71c1c; }
.badge-multiple   { background: #fff8e1; color: #5d4037; }
.badge-error      { background: #fce4ec; color: #880e4f; }

/* Action row */
.action-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* Hidden utility */
.hidden { display: none !important; }

/* Spacing utilities */
.m-0  { margin: 0; }
.mt-2 { margin-top: .5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }

/* Form utilities */
.form-inline       { display: inline; }
.form-group--top-pad { padding-top: 1.8rem; }

/* Stats page */
.stat-items-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; padding: .25rem 1.5rem 0; }
.stat-page-meta  { font-size: .85rem; color: #888; }
.stat-offline    { color: #888; padding: .75rem 0; }

/* Login page */
.login-back      { margin-top: 1.2rem; text-align: center; font-size: .85rem; }
.login-back a    { color: var(--eg-dark); }

/* ── Pagination ────────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 14px 16px;
    flex-wrap: wrap;
}
.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border-radius: var(--radius-pill);
    font-size: .84rem;
    text-decoration: none;
    color: var(--eg-dark);
    border: 1px solid var(--eg-border-light);
    background: #fff;
    transition: background var(--transition), border-color var(--transition);
}
.page-btn:hover { border-color: var(--eg-dark); opacity: 1; }
.page-btn.active { background: var(--eg-dark); color: #fff; border-color: var(--eg-dark); font-weight: 700; }
.page-ellipsis { color: #aaa; padding: 0 4px; }

/* ── Search ────────────────────────────────────────────────────── */
.search-form { margin-bottom: 1rem; }
.search-row  { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search-input { max-width: 320px; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (min-width: 768px) {
    .setup-box { margin-top: 0; }
}

/* ── Stats loading overlay ─────────────────────────────────────────────────── */
#stats-loading {
    position: fixed; inset: 0; background: rgba(226,229,254,.85);
    backdrop-filter: blur(4px); z-index: 999;
    display: none; align-items: center; justify-content: center;
}
#stats-loading.is-visible {
    display: flex;
}
.stats-loading-inner { text-align: center; }
.stats-spinner {
    width: 52px; height: 52px; margin: 0 auto 1.25rem;
    border: 5px solid var(--eg-border);
    border-top-color: var(--eg-dark);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
.stats-loading-text { font-weight: 600; color: var(--eg-dark); font-size: 1rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Server stats page ─────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.stat-card-total { background: var(--eg-bright); border-radius: var(--radius-card); padding: 1.25rem 1.5rem; text-align: center; }
.stat-card-total .stat-label { font-size: .8rem; color: #666; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .4rem; }
.stat-card-total .stat-value  { font-size: 2rem; font-weight: 800; color: var(--eg-dark); }
.stat-item { padding: 1rem 1rem 1rem 0; border-bottom: 1px solid var(--eg-border); }
.stat-item:nth-last-child(-n+4) { border-bottom: none; }
.stat-item-label { font-size: .72rem; color: #888; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .35rem; }
.stat-item-value { font-size: .95rem; font-weight: 600; color: var(--eg-dark); }
.stat-item-number { font-size: 1.5rem; font-weight: 800; color: var(--eg-dark); }

@media (max-width: 640px) {
    .form-row { flex-direction: column; }
    .form-group-port { width: 100%; }
    .admin-nav-item { padding: 11px 12px; font-size: .82rem; }
    .action-row .btn-sm { padding: 4px 10px; }
    .data-table th, .data-table td { padding: 8px 10px; }
    .loginbox { border-radius: 16px; }
    .setup-box { border-radius: 16px; }
    .step-label { display: none; }
}

@media (max-width: 480px) {
    .topbar-title { font-size: .88rem; }
    .topbar-subtitle { display: none; }
    .topbar-logout { padding: 3px 10px; font-size: .72rem; }
    .stat-value { font-size: 1.6rem; }
}
