/* === DAT Workspace — Dark Theme === */

: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;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* === Top Bar === */

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    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);
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 8px;
}

.topbar__logo {
    width: 28px;
    height: 28px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.topbar__title {
    font-size: 16px;
    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;
    white-space: nowrap;
}

.topbar__nav {
    display: flex;
    gap: 2px;
    background: rgba(34, 38, 54, 0.5);
    border-radius: 10px;
    padding: 3px;
    border: 1px solid rgba(46, 51, 72, 0.6);
}

.topbar__nav-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

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

.topbar__nav-btn.active {
    color: #fff;
    background: rgba(108, 140, 255, 0.2);
    box-shadow: 0 0 12px rgba(108, 140, 255, 0.15);
}

.topbar__status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.offline { background: var(--red); box-shadow: 0 0 6px var(--red); }
.status-dot.loading { background: var(--yellow); animation: pulse 1.5s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* === Layout === */

.main {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

.section { display: none; }
.section.active { display: block; }

/* === Service Health === */

.service-health {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
}

.service-health__item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(34, 38, 54, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 14px;
    font-size: 13px;
}

.service-health__item .status-dot {
    width: 8px;
    height: 8px;
    flex-shrink: 0;
}

.service-health__name {
    font-weight: 500;
    color: var(--text-primary);
}

/* === System Overview === */

.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.stat-card .label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
}

/* === GPU Cards === */

.gpu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.gpu-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.gpu-card .gpu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.gpu-card .gpu-name {
    font-size: 14px;
    font-weight: 600;
}

.gpu-card .gpu-id {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 4px;
}

.gpu-card .gpu-temp {
    font-size: 13px;
    color: var(--text-secondary);
}

.gpu-metric {
    margin-bottom: 12px;
}

.gpu-metric .metric-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* === Progress Bar === */

.progress-bar {
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
    background: var(--accent);
}

.progress-bar .fill.green { background: var(--green); }
.progress-bar .fill.yellow { background: var(--yellow); }
.progress-bar .fill.orange { background: var(--orange); }
.progress-bar .fill.red { background: var(--red); }

/* === vLLM Panel === */

.vllm-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.vllm-panel h3 {
    font-size: 15px;
    margin-bottom: 12px;
}

.vllm-info {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-secondary);
}

.vllm-info .info-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* === Chat === */

.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
}

.chat-msg.assistant {
    align-self: flex-start;
    background: var(--bg-input);
    color: var(--text-primary);
}

.chat-msg .tokens {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.chat-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-form,
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.chat-form textarea,
.chat-input,
.chat-input-area textarea {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    min-height: 44px;
    max-height: 120px;
}

.chat-form textarea:focus,
.chat-input:focus,
.chat-input-area textarea:focus {
    border-color: var(--accent);
}

/* === Buttons === */

.btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

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

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

.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-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-danger {
    background: var(--red);
}

.btn-danger:hover {
    background: #ef4444;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* === Models Table === */

.models-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.models-table th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.models-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

/* === Empty state === */

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
    font-size: 14px;
}

/* === Particle Network Background === */

.particle-network-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

.particle-network-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* === Service Hub === */

.service-hub {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    padding: 40px 24px;
    max-width: 1100px;
    margin: 0 auto;
}

.service-hub__heading {
    grid-column: 1 / -1;
    text-align: center;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
}

.service-hub__heading h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 6px;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

.service-hub__heading p {
    color: var(--text-secondary);
    font-size: 14px;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}

.widget-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: rgba(34, 38, 54, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px 20px 24px;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow);
}

.widget-card:hover {
    transform: translateY(-4px);
    border-color: var(--widget-accent, var(--accent));
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--widget-accent, var(--accent));
}

.widget-card__status {
    position: absolute;
    top: 14px;
    left: 14px;
}

.widget-card__status .status-dot {
    width: 10px;
    height: 10px;
}

.widget-card__external {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 14px;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}

.widget-card__external:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

.widget-card__icon {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    color: var(--widget-accent, var(--accent));
    transition: transform 0.2s;
}

.widget-card:hover .widget-card__icon {
    transform: scale(1.08);
}

.widget-card__icon svg {
    width: 100%;
    height: 100%;
}

.widget-card__title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}

.widget-card__desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Widget accent colors */
.widget-card--gpu { --widget-accent: #6c8cff; }
.widget-card--llm { --widget-accent: #a78bfa; }
.widget-card--food-spec { --widget-accent: #f59e0b; }
.widget-card--forecast { --widget-accent: #34d399; }
.widget-card--blood-gas { --widget-accent: #f87171; }
.widget-card--humanizer { --widget-accent: #22d3ee; }
.widget-card--coffee-rag { --widget-accent: #c4956a; }
.widget-card--qb-review { --widget-accent: #a78bfa; }
.widget-card--energy-equity { --widget-accent: #4ade80; }
.widget-card--unipolicy { --widget-accent: #f0abfc; }
.widget-card--cv { --widget-accent: #fb923c; }

.widget-card__wip {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(251, 146, 60, 0.2);
    color: #fb923c;
    border: 1px solid rgba(251, 146, 60, 0.3);
    margin-bottom: 4px;
}

/* === Footer === */

.footer {
    position: fixed;
    bottom: 12px;
    right: 16px;
    z-index: 1;
    text-align: right;
}

.footer__thanks {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.footer__copy {
    font-size: 11px;
    color: var(--text-muted);
}

/* === Topbar Auth === */

.topbar__auth {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    margin-right: 12px;
}

.topbar__user {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.topbar__admin-link {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    transition: border-color 0.15s, color 0.15s;
}

.topbar__admin-link:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.topbar__login-btn {
    background: rgba(108, 140, 255, 0.15);
    border: 1px solid rgba(108, 140, 255, 0.25);
    color: var(--accent);
    padding: 4px 14px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}

.topbar__login-btn:hover {
    background: rgba(108, 140, 255, 0.25);
    color: var(--accent-hover);
}

.topbar__logout-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 4px 12px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.topbar__logout-btn:hover {
    border-color: var(--red);
    color: var(--red);
}

/* === Login Modal === */

.login-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;
}

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

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

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

.login-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;
}

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

.login-modal__title {
    font-size: 22px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 4px;
}

.login-modal__subtitle {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 28px;
}

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

.login-modal__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-modal__field label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.login-modal__field input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

.login-modal__field input:focus {
    border-color: var(--accent);
}

.login-modal__error {
    font-size: 13px;
    color: var(--red);
    min-height: 20px;
}

.login-modal__submit {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 11px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.login-modal__submit:hover {
    background: var(--accent-hover);
}

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

/* === Access Denied Modal === */

.denied-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;
}

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

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

.denied-modal__card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid rgba(248, 113, 113, 0.25);
    border-radius: 16px;
    padding: 36px 32px 28px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.denied-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;
}

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

.denied-modal__icon {
    width: 48px;
    height: 48px;
    color: var(--red);
    opacity: 0.8;
}

.denied-modal__title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--red);
}

.denied-modal__message {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    max-width: 300px;
}

.denied-modal__btn {
    margin-top: 6px;
    background: rgba(248, 113, 113, 0.12);
    color: var(--red);
    border: 1px solid rgba(248, 113, 113, 0.25);
    padding: 9px 32px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}

.denied-modal__btn:hover {
    background: rgba(248, 113, 113, 0.22);
}

/* === Scrollbar === */

::-webkit-scrollbar { width: 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: 960px) {
    .service-hub { grid-template-columns: repeat(3, 1fr); padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 768px) {
    .topbar { padding: 8px 12px; gap: 6px; }
    .topbar__title { font-size: 14px; }
    .topbar__nav-btn { padding: 5px 10px; font-size: 12px; }
    .topbar__status span:not(.status-dot) { display: none; }
    .main { padding: 16px; }
    .gpu-grid { grid-template-columns: 1fr; }
    .overview-grid { grid-template-columns: repeat(2, 1fr); }
    .service-hub { grid-template-columns: repeat(2, 1fr); gap: 16px; padding: 24px 12px; }
}

@media (max-width: 480px) {
    .service-hub { grid-template-columns: 1fr; }
}
