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

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #e0e0e0;
    background: #1a1a2e;
}

/* ===== Top Navigation ===== */
#top-nav {
    display: flex;
    align-items: center;
    gap: 0;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    padding: 0 1rem;
    height: 48px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-title {
    font-weight: 700;
    font-size: 1rem;
    color: #e94560;
    margin-right: 1.5rem;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.tab-btn {
    background: none;
    border: none;
    color: #8a8a9a;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.tab-btn:hover {
    color: #c0c0d0;
}

.tab-btn.active {
    color: #e0e0e0;
    border-bottom-color: #e94560;
}

/* ===== Main Content ===== */
main {
    padding: 1rem 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ===== Cards ===== */
.card {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 6px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card-disabled {
    opacity: 0.5;
}

.card h2 {
    font-size: 1rem;
    font-weight: 600;
    color: #c0c0d0;
    margin-bottom: 1rem;
}

.card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #a0a0b0;
    margin-bottom: 0.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-header h2 {
    margin-bottom: 0;
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ===== Forms ===== */
.form-row {
    margin-bottom: 0.75rem;
}

.form-row label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: #8a8a9a;
    margin-bottom: 0.25rem;
}

.form-row-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

input[type="text"],
input[type="number"],
select {
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
    outline: none;
    transition: border-color 0.15s;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    border-color: #533483;
}

.input-wide {
    flex: 1;
    min-width: 0;
}

.input-mono {
    font-family: "SF Mono", "Consolas", "Liberation Mono", "Menlo", monospace;
    font-size: 0.8rem;
    width: 280px;
}

select {
    cursor: pointer;
}

/* ===== Buttons ===== */
.btn {
    background: #0f3460;
    border: 1px solid #533483;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 0.85rem;
    padding: 0.4rem 0.9rem;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.btn:hover {
    background: #1a4a7a;
}

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

.btn-primary {
    background: #533483;
    border-color: #6b44a0;
}

.btn-primary:hover:not(:disabled) {
    background: #6b44a0;
}

.btn-danger {
    background: #8b1a1a;
    border-color: #a33;
}

.btn-danger:hover:not(:disabled) {
    background: #a33;
}

.btn-sm {
    font-size: 0.78rem;
    padding: 0.25rem 0.6rem;
}

/* ===== Tables ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th {
    text-align: left;
    font-weight: 600;
    color: #8a8a9a;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #0f3460;
}

.data-table td {
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid rgba(15, 52, 96, 0.5);
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: rgba(83, 52, 131, 0.15);
}

.data-table tbody tr.clickable {
    cursor: pointer;
}

.data-table tbody tr.clickable:hover {
    background: rgba(83, 52, 131, 0.25);
}

/* ===== Monospace text ===== */
.mono {
    font-family: "SF Mono", "Consolas", "Liberation Mono", "Menlo", monospace;
    font-size: 0.8rem;
}

/* ===== Status badges ===== */
.badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-ok       { background: #1a4a2a; color: #4caf50; }
.badge-error    { background: #4a1a1a; color: #ef5350; }
.badge-unreachable { background: #4a1a1a; color: #ef5350; }
.badge-staged   { background: #4a3a1a; color: #ffb74d; }
.badge-stalled  { background: #4a3a1a; color: #ffb74d; }
.badge-racing   { background: #1a2a4a; color: #42a5f5; }
.badge-upcoming { background: #1a2a3a; color: #7ab8e0; }
.badge-completed { background: #2a2a2a; color: #9e9e9e; }

/* ===== Banners ===== */
.banner {
    padding: 0.6rem 1rem;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.banner-error {
    background: #3a1a1a;
    border: 1px solid #5a2a2a;
    color: #ef5350;
}

.banner-success {
    background: #1a3a1a;
    border: 1px solid #2a5a2a;
    color: #4caf50;
}

/* ===== Messages ===== */
.msg {
    font-size: 0.85rem;
    padding: 0.4rem 0;
}

.msg-error { color: #ef5350; }
.msg-success { color: #4caf50; }

/* ===== Empty state ===== */
.empty-state {
    color: #6a6a7a;
    font-size: 0.85rem;
    padding: 1rem 0;
    text-align: center;
}

/* ===== Text utilities ===== */
.text-muted {
    color: #6a6a7a;
    font-size: 0.8rem;
}

/* ===== Stat rows ===== */
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(15, 52, 96, 0.4);
}

.stat-label {
    color: #8a8a9a;
    font-size: 0.85rem;
}

.stat-value {
    font-weight: 600;
    color: #e0e0e0;
}

/* ===== Collapsible sections ===== */
.collapsible {
    border-top: 1px solid #0f3460;
    margin-top: 1rem;
}

.collapsible-toggle {
    background: none;
    border: none;
    color: #8a8a9a;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.6rem 0;
    cursor: pointer;
    width: 100%;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.collapsible-toggle:hover {
    color: #c0c0d0;
}

.toggle-icon {
    font-size: 1rem;
    font-weight: 400;
    color: #6a6a7a;
}

.collapsible-content {
    padding-bottom: 0.5rem;
}

/* ===== Detail fields ===== */
.detail-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0.35rem 1rem;
    font-size: 0.85rem;
}

.detail-label {
    color: #8a8a9a;
    font-weight: 500;
}

.detail-value {
    color: #e0e0e0;
}

/* ===== Overlay / Dialog ===== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.dialog {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 8px;
    padding: 24px;
    min-width: 420px;
    max-width: 560px;
}

.dialog h3 {
    margin: 0 0 16px;
    color: #e0e0e0;
}

.progress-log {
    max-height: 200px;
    overflow-y: auto;
    font-size: 13px;
    color: #bbb;
    margin-bottom: 12px;
}

.progress-log .log-line {
    padding: 3px 0;
    border-bottom: 1px solid rgba(15, 52, 96, 0.5);
}

.progress-bar-container {
    height: 6px;
    background: #0f3460;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar {
    height: 100%;
    background: #42a5f5;
    transition: width 0.3s;
}

.progress-summary {
    color: #4caf50;
    font-weight: 600;
    margin-bottom: 12px;
}

/* ===== Spinner ===== */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #0f3460;
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 0.3rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Weather config slider value display */
.slider-val {
    display: inline-block;
    min-width: 2em;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #e94560;
}

input[type="range"] {
    accent-color: #e94560;
}

input[type="password"] {
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
    outline: none;
    transition: border-color 0.15s;
}

input[type="password"]:focus {
    border-color: #e94560;
}

/* ===== Tiles Management ===== */
.config-group { margin-bottom: 1.5rem; }
.config-group label { display: block; font-weight: 600; margin-bottom: 0.5rem; color: #e0e0e0; font-family: monospace; }
.config-textarea { width: 100%; min-height: 150px; background: #1a1a2e; color: #e0e0e0; border: 1px solid #333; border-radius: 4px; padding: 0.75rem; font-family: monospace; font-size: 0.85rem; resize: vertical; }
.config-textarea:focus { border-color: #4a9eff; outline: none; }
.config-actions { margin-top: 0.5rem; display: flex; align-items: center; gap: 0.75rem; }
.config-msg { font-size: 0.85rem; }
.config-msg.success { color: #4caf50; }
.config-msg.error { color: #ef5350; }
.breadcrumb { margin-bottom: 1rem; font-size: 0.9rem; }
.breadcrumb a { color: #4a9eff; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-current { color: #e0e0e0; }
.region-list { list-style: none; padding: 0; }
.region-list li { padding: 0.4rem 0; border-bottom: 1px solid #222; display: flex; align-items: center; justify-content: space-between; }
.region-list li:last-child { border-bottom: none; }
.region-dir { cursor: pointer; color: #4a9eff; }
.region-dir:hover { text-decoration: underline; }
.region-file { color: #9e9e9e; }

/* ===== Tile status feedback ===== */
.badge-pulse {
    animation: badge-pulse 1.5s ease-in-out infinite;
}
@keyframes badge-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.status-detail {
    font-size: 0.75rem;
    color: #7ab8e0;
    margin-top: 0.2rem;
}
.status-detail.status-error {
    color: #ef5350;
}

/* ===== NATS Stream Headers ===== */
.stream-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    margin-top: 0.75rem;
    border-bottom: 1px solid #0f3460;
    background: rgba(15, 52, 96, 0.3);
    border-radius: 3px 3px 0 0;
}

.stream-header:first-child {
    margin-top: 0;
}

.stream-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: #e94560;
    font-family: "SF Mono", "Consolas", "Liberation Mono", "Menlo", monospace;
}

.stream-meta {
    font-size: 0.78rem;
    color: #8a8a9a;
}

/* ===== Nav Utilities ===== */
.nav-spacer { flex: 1; }
.btn-nav { margin-right: 0.75rem; font-size: 0.8rem; }
