/* CSS Variables for theming */
:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --text-primary: #eaeaea;
    --text-secondary: #a0a0a0;
    --text-muted: #6a6a6a;
    --border-color: #2a2a4a;
    --accent-primary: #e94560;
    --status-healthy: #00d26a;
    --status-degraded: #ffc107;
    --status-unhealthy: #e94560;
    --status-pending: #ffc107;
    --status-processing: #00b4d8;
    --status-completed: #00d26a;
    --status-failed: #e94560;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --radius: 8px;
}

/* Light mode support */
@media (prefers-color-scheme: light) {
    :root {
        --bg-primary: #f5f5f5;
        --bg-secondary: #ffffff;
        --bg-card: #ffffff;
        --text-primary: #1a1a2e;
        --text-secondary: #4a4a4a;
        --text-muted: #8a8a8a;
        --border-color: #e0e0e0;
        --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.refresh-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--status-healthy);
    animation: pulse 2s infinite;
}

.refresh-indicator.error {
    background-color: var(--status-unhealthy);
    animation: none;
}

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

.last-updated {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Panels */
.panel {
    background-color: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.panel-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 15px;
}

.panel-header .panel-title {
    margin-bottom: 0;
}

/* Health Cards */
.health-cards {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.health-card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    padding: 15px 20px;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s;
}

.health-card:hover {
    transform: translateY(-2px);
}

.health-card.loading {
    opacity: 0.6;
}

.health-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.health-indicator.healthy {
    background-color: var(--status-healthy);
    box-shadow: 0 0 8px var(--status-healthy);
}

.health-indicator.degraded,
.health-indicator.unhealthy {
    background-color: var(--status-unhealthy);
    box-shadow: 0 0 8px var(--status-unhealthy);
}

.health-indicator.unknown {
    background-color: var(--status-degraded);
}

.health-name {
    font-weight: 500;
    text-transform: capitalize;
}

.health-latency {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.health-error {
    font-size: 0.75rem;
    color: var(--status-unhealthy);
    text-align: center;
}

/* Stats Cards */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
}

.stat-card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    transition: transform 0.2s;
    cursor: pointer;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-count {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card.pending .stat-count {
    color: var(--status-pending);
}

.stat-card.processing .stat-count {
    color: var(--status-processing);
}

.stat-card.completed .stat-count {
    color: var(--status-completed);
}

.stat-card.failed .stat-count {
    color: var(--status-failed);
}

/* Filter Controls */
.filter-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-controls label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.filter-controls select {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 0.875rem;
    cursor: pointer;
}

.filter-controls select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Jobs Table */
.jobs-table-container {
    overflow-x: auto;
}

.jobs-table {
    width: 100%;
    border-collapse: collapse;
}

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

.jobs-table th {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.jobs-table tbody tr {
    cursor: pointer;
    transition: background-color 0.2s;
}

.jobs-table tbody tr:hover {
    background-color: var(--bg-card);
}

.loading-row {
    text-align: center;
    color: var(--text-muted);
    padding: 30px !important;
}

.empty-row {
    text-align: center;
    color: var(--text-muted);
    padding: 30px !important;
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-badge.pending {
    background-color: rgba(255, 193, 7, 0.15);
    color: var(--status-pending);
}

.status-badge.pending::before {
    background-color: var(--status-pending);
}

.status-badge.processing {
    background-color: rgba(0, 180, 216, 0.15);
    color: var(--status-processing);
}

.status-badge.processing::before {
    background-color: var(--status-processing);
    animation: pulse 1s infinite;
}

.status-badge.completed {
    background-color: rgba(0, 210, 106, 0.15);
    color: var(--status-completed);
}

.status-badge.completed::before {
    background-color: var(--status-completed);
}

.status-badge.failed {
    background-color: rgba(233, 69, 96, 0.15);
    color: var(--status-failed);
}

.status-badge.failed::before {
    background-color: var(--status-failed);
}

/* GitHub Link */
.github-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 0.875rem;
}

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

.no-link {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Title Cell */
.title-cell {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

/* Error Banner */
.error-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--status-failed);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow);
    z-index: 1000;
}

.error-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal {
    background-color: var(--bg-secondary);
    border-radius: var(--radius);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(80vh - 60px);
}

/* Job Detail in Modal */
.job-detail {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.detail-row {
    display: flex;
    gap: 10px;
}

.detail-label {
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 120px;
}

.detail-value {
    color: var(--text-primary);
    word-break: break-all;
}

.detail-value.error {
    color: var(--status-failed);
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .health-cards {
        justify-content: center;
    }

    .stats-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .panel-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .jobs-table th:nth-child(4),
    .jobs-table td:nth-child(4) {
        display: none;
    }
}
