/* Conductor Dashboard Styles */

:root {
    --bg: #1a1a2e;
    --bg-secondary: #16213e;
    --accent: #0f3460;
    --text: #e5e5e5;
    --text-muted: #9ca3af;
    --border: #374151;
    --success: #34d399;
    --warning: #f59e0b;
    --error: #ef4444;
    --grid: #333;

    /* Stage colors */
    --stage-queued: #6b7280;
    --stage-dev: #a78bfa;
    --stage-test: #60a5fa;
    --stage-review: #34d399;
    --stage-blocked: #f59e0b;
    --stage-done: #34d399;
    --stage-failed: #ef4444;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #ffffff;
        --bg-secondary: #f3f4f6;
        --accent: #e5e7eb;
        --text: #1f2937;
        --text-muted: #6b7280;
        --border: #d1d5db;
        --grid: #e5e7eb;
    }
}

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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 24px;
}

.logo {
    font-size: 20px;
    font-weight: 600;
}

.nav {
    display: flex;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 6px;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.nav-link:hover, .nav-link.active {
    color: var(--text);
    background: var(--accent);
}

/* Main content */
.main {
    padding: 16px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}

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

.btn.active {
    background: var(--accent);
    border-color: var(--text-muted);
}

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

.btn-primary {
    background: var(--stage-dev);
    border-color: var(--stage-dev);
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
}

.button-group {
    display: flex;
    gap: 4px;
}

/* Banners */
.banner {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.banner-warning {
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid var(--warning);
    color: var(--warning);
}

.banner-error {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid var(--error);
    color: var(--error);
}

/* Counter chips */
.counter-chips {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.chip {
    padding: 8px 16px;
    border-radius: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    min-height: 44px;
}

.chip:hover, .chip.active {
    background: var(--accent);
    border-color: var(--text-muted);
}

/* Agent cards */
.agent-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.agent-card {
    display: block;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s;
}

.agent-card:hover {
    border-color: var(--text-muted);
}

.agent-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-idle {
    background: var(--stage-queued);
}

.status-busy {
    background: var(--stage-dev);
}

.status-stale {
    background: var(--warning);
    animation: pulse 2s infinite;
}

.status-offline {
    background: transparent;
    border: 2px solid var(--stage-queued);
}

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

.agent-name {
    font-weight: 500;
}

.role-badge {
    font-size: 12px;
    padding: 2px 8px;
    background: var(--accent);
    border-radius: 4px;
    color: var(--text-muted);
}

.agent-ticket {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-stage {
    display: flex;
    align-items: center;
    gap: 8px;
}

.agent-idle {
    color: var(--text-muted);
    font-size: 14px;
}

/* Stage pill */
.stage-pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    color: white;
}

.time-in-stage {
    font-size: 14px;
    color: var(--text-muted);
}

/* Ticket board */
.ticket-board {
    margin-top: 24px;
}

.board-tabs {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
}

@media (max-width: 899px) {
    .board-tabs {
        flex-direction: column;
    }
}

.board-column {
    flex: 1;
    min-width: 200px;
}

.column-header {
    font-size: 14px;
    font-weight: 500;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 6px 6px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.column-header .count {
    background: var(--accent);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

.column-tickets {
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 400px;
    overflow-y: auto;
}

.ticket-card {
    display: block;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
}

.ticket-card:last-child {
    border-bottom: none;
}

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

.ticket-id {
    font-weight: 500;
    font-size: 14px;
}

.ticket-title {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px;
}

.ticket-agent {
    font-size: 12px;
    color: var(--text-muted);
}

.ticket-time {
    font-size: 12px;
    color: var(--text-muted);
    float: right;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-muted);
}

/* Timeline page */
.timeline-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group label {
    font-size: 14px;
    color: var(--text-muted);
}

.nav-buttons {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.summary {
    font-size: 14px;
    color: var(--text-muted);
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
}

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

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

.chart-container {
    overflow-x: auto;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 8px;
}

.chart-container svg {
    display: block;
}

/* Detail sheet */
.detail-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 200;
}

.detail-sheet.hidden {
    display: none;
}

.detail-content {
    background: var(--bg-secondary);
    border-radius: 16px 16px 0 0;
    padding: 24px;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    min-height: 44px;
    min-width: 44px;
}

.detail-content h3 {
    margin-bottom: 16px;
    padding-right: 40px;
}

.detail-content dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
    margin-bottom: 16px;
}

.detail-content dt {
    color: var(--text-muted);
    font-size: 14px;
}

.detail-content dd {
    font-size: 14px;
}

/* Ticket page */
.ticket-page {
    max-width: 1000px;
}

.ticket-header {
    margin-bottom: 16px;
}

.ticket-header h1 {
    font-size: 24px;
    margin-bottom: 8px;
}

.external-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 16px;
}

.ticket-meta {
    display: flex;
    gap: 8px;
    align-items: center;
}

.priority-badge {
    font-size: 12px;
    padding: 2px 8px;
    background: var(--warning);
    color: white;
    border-radius: 4px;
}

.ticket-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
}

.stat-value {
    font-size: 16px;
    font-weight: 500;
}

.view-toggle {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}

.ticket-timeline {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
}

/* Intervals table */
.intervals-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.intervals-table th,
.intervals-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.intervals-table th {
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-secondary);
}

.intervals-table tr:hover td {
    background: var(--accent);
}

.intervals-table .note {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-pass { color: var(--success); }
.result-fail { color: var(--error); }
.result-aborted { color: var(--warning); }

.running {
    color: var(--stage-dev);
    font-weight: 500;
}

@media (max-width: 768px) {
    .intervals-table {
        display: block;
    }

    .intervals-table thead {
        display: none;
    }

    .intervals-table tbody {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .intervals-table tr {
        display: block;
        background: var(--bg-secondary);
        border-radius: 8px;
        padding: 12px;
        border: 1px solid var(--border);
    }

    .intervals-table td {
        display: block;
        border: none;
        padding: 4px 0;
    }

    .intervals-table td::before {
        content: attr(data-label);
        font-weight: 500;
        margin-right: 8px;
        color: var(--text-muted);
    }
}

/* Login page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 16px;
}

.login-container {
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.login-container h1 {
    margin-bottom: 24px;
}

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

.form-group {
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--text-muted);
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 16px;
}

.form-group input:focus {
    outline: none;
    border-color: var(--stage-dev);
}

.error-message {
    color: var(--error);
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 6px;
    margin-bottom: 8px;
}

.login-hint {
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-muted);
}

.login-hint code {
    background: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Not found page */
.not-found-page {
    text-align: center;
    padding: 48px 16px;
}

.not-found-page h1 {
    margin-bottom: 16px;
}

.not-found-page p {
    margin-bottom: 24px;
    color: var(--text-muted);
}

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

.data-age {
    font-size: 14px;
    color: var(--text-muted);
}

/* Logout form */
.logout-form {
    margin: 0;
}
