/* ============================================
   Admin Panel - Dark Theme
   Matches DAT Workspace design language
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #222636;
    --bg-input: #2a2e3f;
    --border: #2e3348;
    --text-primary: #f5f6fa;
    --text-secondary: #cdd1e0;
    --text-muted: #a0a4b8;
    --accent: #6c8cff;
    --accent-hover: #8ba4ff;
    --green: #4ade80;
    --yellow: #facc15;
    --red: #f87171;
    --orange: #fb923c;
    --radius: 8px;

    --header-height: 52px;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* ---------- Header ---------- */
.header {
    background: rgba(15, 17, 23, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(108, 140, 255, 0.1);
    padding: 0 20px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header__back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.header__back:hover {
    background: rgba(108, 140, 255, 0.15);
    color: var(--text-primary);
}

.header__back svg {
    width: 20px;
    height: 20px;
}

.header__title {
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent) 0%, hsla(270, 50%, 65%, 1) 50%, hsla(40, 80%, 60%, 1) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ---------- Access Denied ---------- */
.access-denied {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    height: calc(100vh - var(--header-height));
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
}

.access-denied h2 {
    color: var(--red);
    font-size: 1.3rem;
}

.access-denied p {
    font-size: 0.9rem;
}

.access-denied svg {
    color: var(--red);
    opacity: 0.6;
}

/* ---------- Main ---------- */
.main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* ---------- Toolbar ---------- */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.toolbar__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ---------- Buttons ---------- */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    transition: background 0.15s, opacity 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    text-decoration: none;
}

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

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

.btn--accent:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn--primary {
    background: rgba(108, 140, 255, 0.15);
    color: var(--text-secondary);
    border: 1px solid rgba(108, 140, 255, 0.2);
}

.btn--primary:hover:not(:disabled) {
    background: rgba(108, 140, 255, 0.25);
    color: var(--text-primary);
}

.btn--secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn--secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn--danger {
    background: rgba(248, 113, 113, 0.12);
    color: var(--red);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.btn--danger:hover {
    background: rgba(248, 113, 113, 0.22);
}

.btn--small {
    padding: 4px 10px;
    font-size: 0.8rem;
}

/* ---------- Status Bar ---------- */
.status-bar {
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: var(--radius);
    margin-bottom: 12px;
    display: none;
}

.status-bar.is-visible {
    display: block;
}

.status-bar--success {
    background: rgba(74, 222, 128, 0.1);
    color: var(--green);
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.status-bar--error {
    background: rgba(248, 113, 113, 0.1);
    color: var(--red);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

/* ---------- Table Card ---------- */
.table-card {
    background: rgba(34, 38, 54, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    min-width: 800px;
    border-collapse: collapse;
    font-size: 0.85rem;
    table-layout: auto;
}

.table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(46, 51, 72, 0.5);
    vertical-align: middle;
}

.table tbody tr:hover td {
    background: rgba(108, 140, 255, 0.04);
}

.col-username {
    font-weight: 600;
}

.col-services {
    line-height: 1.8;
}

.col-services .service-pill {
    margin-right: 4px;
}

.col-actions {
    white-space: nowrap;
}

.col-actions .btn + .btn {
    margin-left: 4px;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 32px 16px;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge--admin {
    background: rgba(108, 140, 255, 0.15);
    color: var(--accent);
    border: 1px solid rgba(108, 140, 255, 0.25);
}

.badge--user {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* ---------- Service Pills ---------- */
.service-pill {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.service-pill--gpu        { color: var(--green);  border-color: rgba(74,222,128,0.25); background: rgba(74,222,128,0.08); }
.service-pill--llm        { color: var(--accent); border-color: rgba(108,140,255,0.25); background: rgba(108,140,255,0.08); }
.service-pill--food-spec  { color: var(--orange); border-color: rgba(251,146,60,0.25); background: rgba(251,146,60,0.08); }
.service-pill--forecast   { color: var(--yellow); border-color: rgba(250,204,21,0.25); background: rgba(250,204,21,0.08); }
.service-pill--bloodgas   { color: #f472b6;       border-color: rgba(244,114,182,0.25); background: rgba(244,114,182,0.08); }
.service-pill--humanizer { color: #a78bfa;       border-color: rgba(167,139,250,0.25); background: rgba(167,139,250,0.08); }
.service-pill--coffee-rag { color: #c4956a;      border-color: rgba(196,149,106,0.25); background: rgba(196,149,106,0.08); }

/* ---------- Status Dot ---------- */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

.status-dot.online  { background: var(--green); box-shadow: 0 0 6px rgba(74,222,128,0.4); }
.status-dot.offline { background: var(--red);   box-shadow: 0 0 6px rgba(248,113,113,0.3); }

/* ---------- Modal ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.modal.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.modal__card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px 28px 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.modal__close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.modal__title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.modal__form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal__error {
    font-size: 0.85rem;
    color: var(--red);
    min-height: 18px;
}

.modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

/* ---------- Form Fields ---------- */
.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-field input[type="text"],
.form-field input[type="password"] {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 9px 12px;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

.form-field input:focus {
    border-color: var(--accent);
}

.form-field input[readonly] {
    opacity: 0.6;
    cursor: not-allowed;
}

.form-field--inline {
    flex-direction: row;
    align-items: center;
}

/* ---------- Checkbox ---------- */
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-input);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s;
}

.checkbox-label input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox-label input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.service-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
    .main {
        padding: 16px 12px;
    }

    .table th,
    .table td {
        padding: 8px 10px;
    }

    .modal__card {
        margin: 12px;
    }
}
