/* Brigade Demo Dashboard — clean minimal styling */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    min-height: 100vh;
}

header {
    background: #1e293b;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #334155;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #f8fafc;
}

header .subtitle {
    font-size: 0.875rem;
    color: #94a3b8;
    margin-top: 0.25rem;
}

main {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
}

/* Controls */
.controls {
    background: #1e293b;
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid #334155;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.control-group label {
    font-size: 0.875rem;
    color: #94a3b8;
    min-width: 160px;
}

.control-group input[type="range"] {
    flex: 1;
    max-width: 300px;
    accent-color: #3b82f6;
}

#count-display {
    font-size: 1.25rem;
    font-weight: 700;
    color: #3b82f6;
    min-width: 2rem;
    text-align: center;
}

.control-buttons {
    display: flex;
    gap: 0.75rem;
}

.btn {
    padding: 0.5rem 1.5rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

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

.btn-start {
    background: #22c55e;
    color: #052e16;
}

.btn-start:hover:not(:disabled) {
    background: #16a34a;
}

.btn-stop {
    background: #ef4444;
    color: #fef2f2;
}

.btn-stop:hover:not(:disabled) {
    background: #dc2626;
}

/* Status message */
.status-message {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    min-height: 1.25rem;
}

.status-message.info { color: #60a5fa; }
.status-message.success { color: #4ade80; }
.status-message.error { color: #f87171; }

/* Dashboard cards */
.empty-state {
    text-align: center;
    color: #64748b;
    padding: 3rem;
    font-size: 0.875rem;
}

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

.card {
    background: #1e293b;
    border-radius: 0.5rem;
    border: 1px solid #334155;
    overflow: hidden;
    transition: border-color 0.2s;
}

.card.state-running {
    border-color: #22c55e;
}

.card.state-error {
    border-color: #ef4444;
}

.card.state-stopped {
    border-color: #64748b;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #0f172a;
}

.card-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #f8fafc;
}

.state-badge {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    letter-spacing: 0.05em;
}

.state-running .state-badge {
    background: #052e16;
    color: #4ade80;
}

.state-error .state-badge {
    background: #450a0a;
    color: #f87171;
}

.state-stopped .state-badge {
    background: #1e293b;
    color: #94a3b8;
}

.card-body {
    padding: 1rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.7rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: #e2e8f0;
    margin-top: 0.125rem;
}

/* Bucket panel */
.bucket-panel {
    margin-bottom: 2rem;
}

.bucket-card {
    background: #1e293b;
    border-radius: 0.5rem;
    border: 1px solid #3b82f6;
    overflow: hidden;
}

.bucket-card .card-body {
    padding: 1rem;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 0.75rem;
}

.bucket-ext-link {
    font-size: 0.75rem;
    color: #60a5fa;
    text-decoration: none;
    font-weight: 500;
}

.bucket-ext-link:hover {
    text-decoration: underline;
    color: #93bbfc;
}

.bucket-prefixes {
    border-top: 1px solid #334155;
}

.prefix-grid {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.prefix-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.8rem;
}

.prefix-name {
    color: #94a3b8;
    font-family: "SF Mono", "Fira Code", monospace;
    min-width: 140px;
}

.prefix-stat {
    color: #e2e8f0;
    font-weight: 500;
    min-width: 80px;
    text-align: right;
}

.prefix-row {
    cursor: pointer;
    padding: 0.25rem 0;
    border-radius: 0.25rem;
}

.prefix-row:hover {
    background: rgba(59, 130, 246, 0.1);
}

.prefix-expand {
    font-size: 0.65rem;
    color: #64748b;
    margin-left: auto;
}

/* File browser */
.file-list {
    display: none;
    padding: 0 1rem 0.5rem 1.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.file-loading {
    font-size: 0.75rem;
    color: #64748b;
    padding: 0.5rem 0;
}

.file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.2rem 0;
    border-bottom: 1px solid #1e293b;
}

.file-row:last-child {
    border-bottom: none;
}

.file-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: #60a5fa;
    text-decoration: none;
    font-size: 0.75rem;
    font-family: "SF Mono", "Fira Code", monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-link:hover {
    color: #93bbfc;
    text-decoration: underline;
}

.file-icon {
    font-size: 0.85rem;
    flex-shrink: 0;
}

.file-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 0.7rem;
    color: #64748b;
    white-space: nowrap;
    margin-left: 0.75rem;
    flex-shrink: 0;
}

/* Browse section */
.bucket-browse-section {
    border-top: 1px solid #334155;
    padding: 0.75rem 1rem;
}

.btn-browse {
    background: #334155;
    color: #e2e8f0;
    padding: 0.4rem 1rem;
    border: 1px solid #475569;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
}

.btn-browse:hover {
    background: #475569;
}

#bucket-file-browser {
    display: none;
    margin-top: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
}

.browse-group {
    margin-bottom: 0.75rem;
}

.browse-group-header {
    font-size: 0.8rem;
    font-weight: 600;
    color: #94a3b8;
    font-family: "SF Mono", "Fira Code", monospace;
    padding: 0.3rem 0;
    border-bottom: 1px solid #334155;
    margin-bottom: 0.25rem;
}

.browse-group-count {
    font-weight: 400;
    color: #64748b;
    font-size: 0.7rem;
}

/* ── Visualization + Cards row ────────────── */
.viz-row {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    align-items: stretch;
}

.viz-section {
    flex: 1 1 60%;
    min-width: 0;
    background: #1e293b;
    border-radius: 0.5rem;
    border: 1px solid #334155;
    padding: 1rem;
    overflow: hidden;
    display: flex;
    align-items: center;
}

.cards-column {
    flex: 0 0 320px;
    display: flex;
    flex-direction: column;
}

.cards-column .dashboard {
    flex: 1;
}

.cards-column .cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.cards-column .card-body {
    grid-template-columns: 1fr 1fr;
}

#viz {
    width: 100%;
    height: auto;
    max-height: 500px;
    display: block;
}

.viz-connector {
    fill: none;
    stroke: #334155;
    stroke-width: 2;
    stroke-dasharray: 6 4;
    transition: stroke 0.3s;
}

.viz-label {
    fill: #e2e8f0;
    font-size: 11px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.viz-badge {
    fill: #64748b;
    font-size: 9px;
    font-family: "SF Mono", "Fira Code", monospace;
}
