/* Server Dashboard layout & component styles (rewrite). Uses theme.css tokens. */

/* ---------- Layout ---------- */
.dash-layout {
    display: flex;
    min-height: 100vh;
}

.dash-sidebar {
    width: 250px;
    flex: 0 0 250px;
    background: var(--surface, #0c0c1a);
    border-right: 1px solid var(--border, rgba(167,139,250,0.09));
    padding: 18px 14px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dash-sidebar .brand {
    font-size: 18px;
    font-weight: 700;
    color: var(--text, #f1f1f9);
    margin-bottom: 10px;
}

.server-chip {
    background: var(--accent-soft, rgba(99,102,241,0.10));
    border: 1px solid var(--border-light, rgba(167,139,250,0.16));
    border-radius: var(--radius-xs, 8px);
    padding: 9px 12px;
    margin-bottom: 12px;
}

.server-chip-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary, #a6a9c8);
}

.dash-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-section-label {
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-muted, #62658a);
    padding: 14px 8px 4px;
    font-weight: 700;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-xs, 8px);
    color: var(--text-secondary, #a6a9c8);
    font-size: 13px;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.nav-item:hover { background: rgba(255,255,255,.05); color: var(--text, #f1f1f9); }

.nav-item.active {
    background: var(--accent, #6366f1);
    color: #fff;
    font-weight: 600;
}

.sidebar-foot {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border, rgba(167,139,250,0.09));
}

.dash-content {
    flex: 1;
    padding: 28px 32px 60px;
    overflow-x: hidden;
    max-width: 1100px;
}

/* ---------- Panels / cards ---------- */
.panel { display: block; animation: fadeIn .18s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

.section-card {
    background: var(--card, #101025);
    border: 1px solid var(--border, rgba(167,139,250,0.09));
    border-radius: var(--radius-sm, 12px);
    padding: 22px 24px;
    margin-bottom: 20px;
}

.section-card h3 {
    font-size: 17px;
    margin: 0 0 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text, #f1f1f9);
}

.section-card h3 i { color: var(--accent, #6366f1); }

.section-desc {
    color: var(--text-muted, #62658a);
    font-size: 13px;
    margin: 0 0 18px;
    line-height: 1.5;
}

.page-head { margin-bottom: 22px; }
.page-head h2 { font-size: 24px; margin: 0 0 4px; }
.page-desc { color: var(--text-muted, #62658a); margin: 0 0 22px; font-size: 14px; }

/* ---------- Top bar / login (theme has top-bar) ---------- */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    border-bottom: 1px solid var(--border, rgba(167,139,250,0.09));
    background: var(--surface, #0c0c1a);
}

.top-bar .brand { font-size: 17px; font-weight: 700; color: var(--text, #f1f1f9); }
.top-bar .brand i { color: var(--accent, #6366f1); margin-right: 6px; }
.top-actions { display: flex; gap: 10px; }

.page-wrap { padding: 40px 28px; max-width: 900px; margin: 0 auto; }

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

.login-box {
    background: var(--card, #101025);
    border: 1px solid var(--border-light, rgba(167,139,250,0.16));
    border-radius: var(--radius, 18px);
    padding: 42px 46px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg, 0 12px 60px rgba(0,0,0,0.6));
}

.login-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 18px;
    border-radius: 16px;
    background: var(--grad-shield, linear-gradient(135deg,#6366f1,#a78bfa));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: #fff;
}

.login-box h1 { font-size: 22px; margin: 0 0 8px; color: var(--text, #f1f1f9); }
.login-box p { font-size: 13px; color: var(--text-secondary, #a6a9c8); line-height: 1.6; margin: 0 0 24px; }

/* ---------- Forms ---------- */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary, #a6a9c8);
}

.form-group .label-sub {
    font-size: 11px;
    color: var(--text-muted, #62658a);
    font-weight: 400;
}

.form-group input[type=text],
.form-group input[type=number],
.form-group input[type=url],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--surface, #0c0c1a);
    border: 1px solid var(--border, rgba(167,139,250,0.09));
    border-radius: var(--radius-xs, 8px);
    color: var(--text, #f1f1f9);
    font-size: 13px;
    outline: none;
    font-family: var(--font, 'Inter', sans-serif);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--accent, #6366f1);
}

.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-muted, #62658a); }
.form-group textarea { min-height: 90px; resize: vertical; }

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.btn-block { width: 100%; }

/* ---------- Toggles ---------- */
.toggle-wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toggle-wrap .toggle-label { flex: 1; }
.toggle-wrap .toggle-label .label-sub { display: block; font-weight: 400; }

.toggle {
    position: relative;
    width: 46px;
    height: 26px;
    background: #3a3f4b;
    border-radius: 26px;
    cursor: pointer;
    transition: background .2s;
    flex: 0 0 46px;
}

.toggle .knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
}

.toggle.on { background: var(--green, #22c55e); }
.toggle.on .knob { transform: translateX(20px); }

/* ---------- Tables ---------- */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border, rgba(167,139,250,0.09));
    border-radius: var(--radius-sm, 12px);
    background: var(--card, #101025);
}

.table-wrap table { width: 100%; border-collapse: collapse; min-width: 640px; }

.table-wrap th, .table-wrap td {
    padding: 10px 14px;
    text-align: left;
    font-size: 13px;
    border-bottom: 1px solid var(--border, rgba(167,139,250,0.09));
    white-space: nowrap;
    color: var(--text, #f1f1f9);
}

.table-wrap th {
    background: rgba(255,255,255,.03);
    color: var(--text-muted, #62658a);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.table-wrap tr:last-child td { border-bottom: none; }
.table-wrap tr:hover td { background: rgba(255,255,255,.02); }

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell img { border-radius: 50%; }

.tag-code {
    font-family: var(--mono, monospace);
    background: var(--accent-soft, rgba(99,102,241,0.10));
    color: #b0b8ff;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 12px;
    word-break: break-all;
    white-space: normal;
}

.flex-actions { display: flex; gap: 6px; flex-wrap: nowrap; }

.action-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    background: rgba(255,255,255,.05);
    color: var(--text-secondary, #a6a9c8);
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
}

.pagination .page-btn {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border-radius: var(--radius-xs, 8px);
    background: var(--surface, #0c0c1a);
    border: 1px solid var(--border, rgba(167,139,250,0.09));
    color: var(--text-secondary, #a6a9c8);
    font-size: 13px;
    cursor: pointer;
}

.pagination .page-btn:hover { border-color: var(--accent, #6366f1); }
.pagination .page-btn.active { background: var(--accent, #6366f1); border-color: var(--accent, #6366f1); color: #fff; }
.pagination .page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Search / filters ---------- */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.search-bar input {
    flex: 1;
    min-width: 200px;
    padding: 9px 12px;
    background: var(--surface, #0c0c1a);
    border: 1px solid var(--border, rgba(167,139,250,0.09));
    border-radius: var(--radius-xs, 8px);
    color: var(--text, #f1f1f9);
    font-size: 13px;
    outline: none;
}

.search-bar input:focus { border-color: var(--accent, #6366f1); }

/* ---------- Empty / loader states ---------- */
.loader-wrap { text-align: center; padding: 60px 20px; color: var(--text-muted, #62658a); }
.loader-wrap p { margin-top: 14px; font-size: 13px; }

.empty-state {
    text-align: center;
    padding: 46px 20px;
    color: var(--text-muted, #62658a);
    border: 1px dashed var(--border, rgba(167,139,250,0.09));
    border-radius: var(--radius-sm, 12px);
    margin: 12px 0;
}

.empty-state i { font-size: 34px; margin-bottom: 10px; display: block; color: #4a4f5c; }
.empty-state h3 { color: var(--text-secondary, #a6a9c8); margin: 0 0 6px; font-size: 15px; }
.empty-state p { margin: 0; font-size: 13px; }

/* ---------- Modal (theme has .modal only) ---------- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,.6);
    align-items: center;
    justify-content: center;
}

.modal.active { display: flex; }

.modal-content {
    background: var(--card, #101025);
    border: 1px solid var(--border-light, rgba(167,139,250,0.16));
    border-radius: var(--radius, 18px);
    width: min(560px, calc(100vw - 32px));
    max-height: 82vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg, 0 12px 60px rgba(0,0,0,0.6));
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border, rgba(167,139,250,0.09));
}

.modal-header h3 { margin: 0; font-size: 15px; color: var(--text, #f1f1f9); }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted, #62658a);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}

.modal-body { padding: 20px; font-size: 13px; color: var(--text-secondary, #a6a9c8); line-height: 1.6; }
.modal-body h4 { margin: 14px 0 6px; color: var(--text, #f1f1f9); font-size: 14px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border, rgba(167,139,250,0.09));
}

/* ---------- Misc ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }

.logs-box {
    max-height: 340px;
    overflow-y: auto;
    background: var(--bg-deep, #050509);
    border: 1px solid var(--border, rgba(167,139,250,0.09));
    border-radius: var(--radius-sm, 12px);
    padding: 12px 14px;
    font-family: var(--mono, monospace);
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-secondary, #a6a9c8);
}

.an-table td { white-space: normal; }
.an-table .mod-label { font-weight: 600; color: var(--text, #f1f1f9); }
.an-table .mod-desc { font-size: 12px; color: var(--text-muted, #62658a); }

/* ---------- Shared resource pickers (selectors.js) ---------- */
.rs-picker {
    position: relative;
}

.rs-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 6px 12px;
    background: var(--surface, #0c0c1a);
    border: 1px solid var(--border, rgba(167,139,250,0.09));
    border-radius: var(--radius-sm, 12px);
    cursor: pointer;
    user-select: none;
    transition: border-color .12s, box-shadow .12s;
}

.rs-trigger:hover { border-color: rgba(167,139,250,0.28); }

.rs-picker.rs-open .rs-trigger,
.rs-trigger:focus-visible {
    border-color: var(--accent, #6366f1);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.14);
}

.rs-caret {
    margin-left: auto;
    flex: 0 0 auto;
    color: var(--text-muted, #62658a);
    font-size: 12px;
    transition: transform .15s ease;
}

.rs-picker.rs-open .rs-caret { transform: rotate(180deg); }

.rs-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 100;
    display: none;
    background: var(--card, #101025);
    border: 1px solid var(--border-light, rgba(167,139,250,0.16));
    border-radius: var(--radius-sm, 12px);
    box-shadow: var(--shadow-lg, 0 12px 40px rgba(0,0,0,0.55));
    overflow: hidden;
    animation: rsFade .16s ease;
}

.rs-picker.rs-open .rs-panel { display: block; }

@keyframes rsFade {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

.rs-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.rs-value { display: inline-flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }

.rs-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-soft, rgba(99,102,241,0.14));
    border: 1px solid var(--border-light, rgba(167,139,250,0.16));
    color: #cfd2ff;
    font-size: 12px;
    padding: 3px 6px 3px 9px;
    border-radius: 16px;
    max-width: 100%;
}

.rs-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rs-chip-warn {
    background: rgba(245,158,11,.12);
    border-color: rgba(245,158,11,.35);
    color: #ffd88a;
}

.rs-chip-x {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 0 3px;
    opacity: .75;
}

.rs-chip-x:hover { opacity: 1; color: #fff; }

.rs-empty-chip { color: var(--text-muted, #62658a); font-size: 13px; }

.rs-clear {
    background: none;
    border: 1px solid var(--border, rgba(167,139,250,0.14));
    color: var(--text-muted, #62658a);
    border-radius: 16px;
    padding: 3px 9px;
    font-size: 11px;
    cursor: pointer;
    margin-left: auto;
    flex: 0 0 auto;
}

.rs-clear:hover { color: var(--red, #f87171); border-color: var(--red, #f87171); }

.rs-search-wrap { display: flex; align-items: center; gap: 8px; padding: 10px 10px 4px; }

.rs-search {
    flex: 1;
    min-width: 0;
    padding: 8px 11px;
    background: var(--bg-deep, #050509);
    border: 1px solid var(--border, rgba(167,139,250,0.09));
    border-radius: var(--radius-xs, 8px);
    color: var(--text, #f1f1f9);
    font-size: 13px;
    outline: none;
}

.rs-search:focus { border-color: var(--accent, #6366f1); }

.rs-count { color: var(--text-muted, #62658a); font-size: 11px; white-space: nowrap; }

.rs-list {
    overflow-y: auto;
    padding: 4px 0;
}

.rs-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted, #62658a);
    padding: 10px 12px 4px;
}

.rs-group i { color: var(--text-muted, #62658a); font-size: 11px; }

.rs-opt {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 12px;
    cursor: pointer;
    color: var(--text-secondary, #a6a9c8);
}

.rs-opt:hover { background: rgba(255,255,255,.04); }

.rs-opt.sel { background: rgba(99,102,241,.10); color: var(--text, #f1f1f9); }

.rs-opt.disabled { opacity: .45; cursor: not-allowed; }

.rs-opt.disabled:hover { background: none; }

.rs-opt input { accent-color: var(--accent, #6366f1); flex: 0 0 auto; }

.rs-opt-col { display: flex; flex-direction: column; min-width: 0; flex: 1; }

.rs-opt-name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rs-opt-name i { width: 16px; text-align: center; color: var(--text-muted, #62658a); }

.rs-opt-sub { font-size: 11px; color: var(--text-muted, #62658a); }

.rs-role-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    flex: 0 0 11px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
}

.rs-user-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex: 0 0 20px;
}

.rs-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
    white-space: nowrap;
    margin-left: auto;
    flex: 0 0 auto;
}

.rs-badge-warn { background: rgba(245,158,11,.16); color: #ffd88a; }
.rs-badge-neutral { background: rgba(255,255,255,.06); color: var(--text-muted, #62658a); }
.rs-badge-accent { background: var(--accent-soft, rgba(99,102,241,0.16)); color: #a5b4fc; }

.rs-note {
    padding: 12px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted, #62658a);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.rs-note i { color: var(--text-muted, #62658a); }

.rs-note-loading { color: var(--text-secondary, #a6a9c8); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .dash-layout { flex-direction: column; }
    .dash-sidebar {
        width: 100%;
        flex: none;
        height: auto;
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 4px;
        padding: 12px 12px 10px;
    }
    .dash-sidebar .brand { width: 100%; margin-bottom: 6px; }
    .dash-nav { flex: none; flex-direction: row; flex-wrap: wrap; width: 100%; gap: 4px; }
    .nav-item { padding: 7px 10px; font-size: 12px; white-space: nowrap; }
    .nav-section-label { display: none; }
    .sidebar-foot { width: 100%; flex-direction: row; }
    .dash-content { padding: 18px 16px 54px; }
    .modal-content { width: calc(100vw - 24px); }
    .form-row, .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
    .login-box { padding: 30px 22px; }
    .page-wrap { padding: 24px 14px; }
    .top-bar { padding: 12px 14px; }
    .page-head h2 { font-size: 20px; }
    .section-card { padding: 16px; }
}
