/* ToxMessenger.Admin — dark premium admin theme.
   Background #0F0F14, glass cards, purple-blue gradient accents (#667eea -> #764ba2). */

:root {
    --bg: #0F0F14;
    --bg-raised: rgba(255, 255, 255, 0.04);
    --bg-hover: rgba(255, 255, 255, 0.07);
    --border: rgba(255, 255, 255, 0.09);
    --text: #E8E8F0;
    --text-dim: #9A9AB0;
    --grad-from: #667eea;
    --grad-to: #764ba2;
    --green: #34d399;
    --amber: #fbbf24;
    --red: #f87171;
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

h1, h2, h3 {
    font-weight: 600;
}

.mono {
    font-family: "Cascadia Code", Consolas, "Courier New", monospace;
    font-size: 0.9em;
}

.nowrap {
    white-space: nowrap;
}

/* ---------- Layout ---------- */

.layout {
    display: flex;
    min-height: 100vh;
}

.layout-plain {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar {
    width: 230px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    border-right: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.3px;
    padding: 4px 10px 18px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-dim);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.22), rgba(118, 75, 162, 0.22));
    color: var(--text);
    box-shadow: inset 0 0 0 1px rgba(102, 126, 234, 0.35);
}

.sidebar-footer {
    padding: 12px 10px 2px;
    font-size: 11px;
    color: var(--text-dim);
    opacity: 0.7;
}

.main-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
}

.topbar-title {
    flex: 1;
}

.topbar-user {
    color: var(--text-dim);
}

.content {
    padding: 24px;
    flex: 1;
}

.content-narrow {
    display: flex;
    justify-content: center;
}

.page-title {
    margin: 0 0 18px;
    font-size: 22px;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.page-header .page-title {
    margin: 0;
}

/* ---------- Privacy banner ---------- */

.privacy-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 24px 0;
    padding: 12px 16px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.18), rgba(118, 75, 162, 0.18));
    border: 1px solid rgba(102, 126, 234, 0.45);
    color: var(--text);
    font-weight: 500;
}

.layout-plain .privacy-banner {
    margin: 16px auto 0;
    max-width: 720px;
}

.privacy-lock {
    flex-shrink: 0;
    color: var(--grad-from);
}

/* ---------- Glass cards ---------- */

.glass-card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.card-title {
    margin: 0 0 14px;
    font-size: 15px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-size: 12px;
}

/* ---------- Stat cards ---------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: linear-gradient(180deg, var(--grad-from), var(--grad-to));
    opacity: 0.9;
}

.stat-title {
    color: var(--text-dim);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    margin-top: 4px;
}

.stat-value-sm {
    font-size: 20px;
}

.stat-sub {
    color: var(--text-dim);
    font-size: 12px;
    margin-top: 4px;
}

.accent-green::before {
    background: var(--green);
}

.accent-amber::before {
    background: var(--amber);
}

.accent-red::before {
    background: var(--red);
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 14px;
}

.relay-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ---------- Donut chart ---------- */

.donut-row {
    display: flex;
    align-items: center;
    gap: 22px;
}

.donut {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.donut-hole {
    width: 74px;
    height: 74px;
    border-radius: 50%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: var(--text-dim);
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 8px;
}

.legend-android {
    background: var(--grad-from);
}

.legend-ios {
    background: var(--grad-to);
}

/* ---------- Tables ---------- */

.table-card {
    padding: 8px;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 12px 14px;
    color: var(--text-dim);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.check-col {
    width: 34px;
}

.actions-col {
    width: 1%;
}

.row-actions {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

.details-cell {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-green {
    background: rgba(52, 211, 153, 0.15);
    color: var(--green);
    box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.35);
}

.badge-amber {
    background: rgba(251, 191, 36, 0.15);
    color: var(--amber);
    box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.35);
}

.badge-red {
    background: rgba(248, 113, 113, 0.15);
    color: var(--red);
    box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.35);
}

.badge-gray {
    background: rgba(154, 154, 176, 0.15);
    color: var(--text-dim);
    box-shadow: inset 0 0 0 1px rgba(154, 154, 176, 0.3);
}

.role-badge {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.25), rgba(118, 75, 162, 0.25));
    color: var(--text);
    box-shadow: inset 0 0 0 1px rgba(102, 126, 234, 0.5);
}

.integrity-badge {
    padding: 6px 12px;
    font-size: 12.5px;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text);
    background: var(--bg-hover);
    transition: filter 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover:not(:disabled) {
    filter: brightness(1.15);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--grad-from), var(--grad-to));
    box-shadow: 0 4px 14px rgba(102, 126, 234, 0.35);
}

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text-dim);
}

.btn-ghost:hover:not(:disabled) {
    color: var(--text);
    background: var(--bg-hover);
}

.btn-danger {
    background: rgba(248, 113, 113, 0.18);
    color: var(--red);
    box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.45);
}

.btn-warning {
    background: rgba(251, 191, 36, 0.15);
    color: var(--amber);
    box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.4);
}

.btn-success {
    background: rgba(52, 211, 153, 0.15);
    color: var(--green);
    box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.4);
}

.btn-outline-danger {
    background: transparent;
    border-color: rgba(248, 113, 113, 0.55);
    color: var(--red);
}

.btn-xs {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 8px;
}

.btn-block {
    width: 100%;
    margin-top: 6px;
}

/* ---------- Forms ---------- */

.input {
    width: 100%;
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus {
    border-color: var(--grad-from);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.input::placeholder {
    color: var(--text-dim);
    opacity: 0.7;
}

select.input option {
    background: #17171f;
    color: var(--text);
}

input[type="date"].input {
    color-scheme: dark;
}

.form-field {
    margin-bottom: 14px;
}

.form-field label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
    padding: 14px;
}

.filter-bar .input {
    width: auto;
    min-width: 140px;
}

.filter-bar .filter-search {
    flex: 1;
    min-width: 200px;
}

.bulk-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 10px 14px;
    color: var(--text-dim);
}

/* ---------- Modal ---------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 10, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-card {
    width: 100%;
    max-width: 440px;
    background: #17171f;
}

.modal-title {
    margin: 0 0 8px;
    font-size: 17px;
}

.modal-message {
    color: var(--text-dim);
    margin: 0 0 14px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

/* ---------- Alerts & misc ---------- */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-weight: 500;
}

.alert-error {
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: var(--red);
}

.alert-warning {
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.4);
    color: var(--amber);
}

.alert-success {
    background: rgba(52, 211, 153, 0.12);
    border: 1px solid rgba(52, 211, 153, 0.4);
    color: var(--green);
}

.loading,
.empty {
    padding: 30px;
    text-align: center;
    color: var(--text-dim);
}

.empty-state {
    max-width: 480px;
    margin: 60px auto;
    text-align: center;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 10px 6px;
}

.pager-info {
    color: var(--text-dim);
    font-size: 12.5px;
}

.bar {
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    margin-top: 10px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--grad-from), var(--grad-to));
    transition: width 0.4s ease;
}

.bar-fill.bar-good {
    background: var(--green);
}

.bar-fill.bar-warn {
    background: var(--amber);
}

.bar-fill.bar-bad {
    background: var(--red);
}

/* ---------- Login ---------- */

.login-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 40px 16px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 30px;
}

.login-brand {
    text-align: center;
    margin-bottom: 22px;
}

.login-brand h1 {
    font-size: 20px;
    margin: 12px 0 6px;
}

.login-sub {
    color: var(--text-dim);
    margin: 0;
    font-size: 13px;
}

.totp-input {
    text-align: center;
    font-size: 20px;
    letter-spacing: 8px;
}

/* ---------- Blazor error UI ---------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 20px;
    background: #2a1215;
    color: var(--red);
    border-top: 1px solid rgba(248, 113, 113, 0.4);
    z-index: 2000;
}

#blazor-error-ui .reload {
    color: var(--text);
    margin-left: 8px;
}

#blazor-error-ui .dismiss {
    float: right;
    cursor: pointer;
    color: var(--text-dim);
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        flex-direction: row;
        align-items: center;
        gap: 10px;
        padding: 10px 14px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        overflow-x: auto;
    }

    .sidebar-brand {
        padding: 4px 6px;
    }

    .sidebar-nav {
        flex-direction: row;
    }

    .nav-item {
        white-space: nowrap;
    }

    .sidebar-footer {
        display: none;
    }

    .privacy-banner {
        margin: 12px 14px 0;
        font-size: 12.5px;
    }

    .content {
        padding: 14px;
    }
}
