/* MS2 Research System — Stylesheet */

:root {
    --color-bg: #1a1a2e;
    --color-surface: #16213e;
    --color-surface-alt: #0f3460;
    --color-text: #e0e0e0;
    --color-text-muted: #a0a0b0;
    --color-accent: #4da8da;
    --color-green: #4caf50;
    --color-blue: #2196f3;
    --color-amber: #ff9800;
    --color-red: #f44336;
    --color-gray: #616161;
    --color-border: #2a2a4a;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─── Header / Nav ─── */

#mock-banner {
    background: rgba(255, 152, 0, 0.15);
    border-bottom: 1px solid var(--color-amber);
    color: var(--color-amber);
    padding: 0.4rem 1.5rem;
    font-size: 0.85rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

#mock-banner button {
    background: none;
    border: none;
    color: var(--color-amber);
    cursor: pointer;
    font-size: 1rem;
    padding: 0 0.25rem;
    opacity: 0.7;
}

#mock-banner button:hover {
    opacity: 1;
}

header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0 1.5rem;
}

nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    max-width: 1400px;
    margin: 0 auto;
}

.logo {
    color: var(--color-accent);
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 600;
}

.auto-refresh {
    color: var(--color-green);
    font-size: 0.85rem;
}

/* ─── Main ─── */

main {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    width: 100%;
}

h1 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--color-text);
}

h2 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--color-text-muted);
}

/* ─── Footer ─── */

footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 0.75rem 1.5rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.footer-auth {
    margin-bottom: 0.4rem;
}

.footer-auth a {
    color: var(--color-accent);
    text-decoration: none;
    font-size: 0.8rem;
    cursor: pointer;
}

.footer-auth a:hover {
    text-decoration: underline;
}

/* ─── System Matrix Table ─── */

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: var(--radius);
    overflow: hidden;
}

thead th {
    background: var(--color-surface-alt);
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-weight: 500;
    white-space: nowrap;
}

tbody tr {
    border-top: 1px solid var(--color-border);
    cursor: pointer;
    transition: background 0.15s;
}

tbody tr:hover {
    background: var(--color-surface-alt);
}

tbody td {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

td.empty {
    text-align: center;
    color: var(--color-text-muted);
    padding: 2rem;
}

.imei-sub {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-weight: 400;
}

/* ─── Status Indicators ─── */

.status-recording {
    color: var(--color-green);
    font-weight: 600;
}

.status-online {
    color: var(--color-blue);
}

.status-offline {
    color: var(--color-gray);
}

.status-converging {
    color: var(--color-amber);
}

.node-connected {
    color: var(--color-green);
}

.node-lost {
    color: var(--color-red);
}

.node-unknown {
    color: var(--color-text-muted);
}

/* ─── Device Console ─── */

.device-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.back-link {
    color: var(--color-accent);
    text-decoration: none;
    font-size: 0.9rem;
}

.back-link:hover {
    text-decoration: underline;
}

.device-shadow {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.shadow-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}

.shadow-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
}

.shadow-item .label {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.shadow-item .state {
    font-weight: 600;
}

/* ─── Controls ─── */

.controls {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.button-group {
    display: flex;
    gap: 1rem;
}

.btn {
    padding: 0.6rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: opacity 0.2s;
}

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

.btn-start {
    background: var(--color-green);
    color: white;
}

.btn-stop {
    background: var(--color-red);
    color: white;
}

.btn:not(:disabled):hover {
    opacity: 0.85;
}

/* ─── Event Log ─── */

.event-log {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.event-list {
    max-height: 400px;
    overflow-y: auto;
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    font-size: 0.82rem;
    line-height: 1.6;
}

.event-entry {
    padding: 0.2rem 0.4rem;
    border-bottom: 1px solid var(--color-border);
}

.event-entry:last-child {
    border-bottom: none;
}

.event-time {
    color: var(--color-text-muted);
    margin-right: 0.5rem;
}

.event-level-info {
    color: var(--color-text);
}

.event-level-warning {
    color: var(--color-amber);
}

.event-level-error {
    color: var(--color-red);
}

.event-empty {
    color: var(--color-text-muted);
    text-align: center;
    padding: 2rem;
}

/* ─── Responsive ─── */

@media (max-width: 768px) {
    main {
        padding: 1rem;
    }

    .shadow-grid {
        grid-template-columns: 1fr;
    }

    .button-group {
        flex-direction: column;
    }

    table {
        font-size: 0.8rem;
    }

    thead th,
    tbody td {
        padding: 0.5rem;
    }
}