/* orchestrator/static/css/dashboard.css */

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

:root {
    --color-bg: #f5f6fa;
    --color-white: #ffffff;
    --color-text: #2d3436;
    --color-text-muted: #636e72;
    --color-primary: #6c5ce7;
    --color-primary-hover: #5a4bd1;
    --color-sidebar: #2d3436;
    --color-sidebar-text: #dfe6e9;
    --color-sidebar-active: #6c5ce7;
    --color-border: #e0e0e0;
    --color-success: #00b894;
    --color-warning: #fdcb6e;
    --color-danger: #d63031;
    --color-info: #0984e3;

    /* Status badge colors */
    --status-queued: #b2bec3;
    --status-in-progress: #0984e3;
    --status-completed: #00b894;
    --status-awaiting-review: #e17055;
    --status-delivering: #fdcb6e;
    --status-fulfilled: #00b894;
    --status-failed: #d63031;
    --status-dead: #2d3436;
    --status-cancelled: #b2bec3;

    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
        Ubuntu, Cantarell, sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

    --sidebar-width: 260px;
    --header-height: 64px;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    font-size: 14px;
}

/* === Layout === */
.layout {
    display: flex;
    min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar);
    color: var(--color-sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 2px;
}

.sidebar-subtitle {
    font-size: 12px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    list-style: none;
    flex: 1;
    padding: 12px 0;
}

.sidebar-nav li a {
    display: block;
    padding: 12px 20px;
    color: var(--color-sidebar-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.sidebar-nav li a.active {
    background: rgba(108, 92, 231, 0.15);
    color: #fff;
    border-left-color: var(--color-sidebar-active);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user {
    display: block;
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

/* === Main Content === */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    height: var(--header-height);
}

.content-header h1 {
    font-size: 20px;
    font-weight: 600;
}

.content-body {
    padding: 24px 32px;
}

/* === Login Page === */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-bg);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 16px;
}

.login-card {
    background: var(--color-white);
    padding: 40px 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.login-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

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

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

/* === Forms === */
.form-group {
    margin-bottom: 16px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: var(--font-family);
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

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

.btn-success {
    background: var(--color-success);
    color: #fff;
}

.btn-success:hover {
    background: #00a381;
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-secondary {
    background: transparent;
    color: var(--color-sidebar-text);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    font-size: 12px;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-full {
    width: 100%;
}

/* === Alerts === */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
}

.alert-error {
    background: #ffeaa7;
    color: #d63031;
    border: 1px solid #fdcb6e;
}

.alert-success {
    background: #dfe6e9;
    color: #00b894;
    border: 1px solid #00b894;
}

.alert-info {
    background: #dfe6e9;
    color: #0984e3;
    border: 1px solid #74b9ff;
}

/* === Stats Bar === */
.stats-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.stat-card {
    background: var(--color-white);
    padding: 16px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    flex: 1;
    min-width: 140px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === Tables === */
.table-container {
    background: var(--color-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

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

thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    border-bottom: 2px solid var(--color-border);
    background: var(--color-bg);
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    font-size: 13px;
}

tbody tr:hover {
    background: rgba(108, 92, 231, 0.03);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* === Status Badges === */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #fff;
}

.badge-queued { background: var(--status-queued); }
.badge-in_progress { background: var(--status-in-progress); }
.badge-completed { background: var(--status-completed); }
.badge-awaiting_review { background: var(--status-awaiting-review); }
.badge-delivering { background: var(--status-delivering); color: var(--color-text); }
.badge-fulfilled { background: var(--status-fulfilled); }
.badge-failed { background: var(--status-failed); }
.badge-dead { background: var(--status-dead); }
.badge-cancelled { background: var(--status-cancelled); }

/* === Tier Badges === */
.tier-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}

.tier-essential { background: #dfe6e9; color: var(--color-text); }
.tier-full { background: #a29bfe; color: #fff; }
.tier-premium { background: #fdcb6e; color: var(--color-text); }

/* === Filters Bar === */
.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: end;
}

.filters-bar .form-group {
    margin-bottom: 0;
    min-width: 150px;
}

.filters-bar .form-group label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
}

.filters-bar .form-group input,
.filters-bar .form-group select {
    padding: 8px 10px;
    font-size: 13px;
}

/* === Cards === */
.card {
    background: var(--color-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

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

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
}

/* === Timeline === */
.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--color-border);
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: -20px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2px solid var(--color-white);
}

.timeline-item .timeline-time {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-bottom: 2px;
}

.timeline-item .timeline-content {
    font-size: 13px;
}

/* === Review Studio === */
.review-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    height: calc(100vh - var(--header-height) - 80px);
}

.review-pdf {
    background: var(--color-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.review-pdf iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.review-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.review-panel textarea {
    flex: 1;
    min-height: 200px;
    resize: vertical;
}

.review-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* === Confirmation Dialog === */
.confirm-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.confirm-overlay.active {
    display: flex;
}

.confirm-dialog {
    background: var(--color-white);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.confirm-dialog h3 {
    margin-bottom: 12px;
}

.confirm-dialog p {
    color: var(--color-text-muted);
    margin-bottom: 24px;
}

.confirm-dialog .confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* === Health indicators === */
.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.health-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.health-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.health-dot.alive { background: var(--color-success); }
.health-dot.dead { background: var(--color-danger); }

/* === Error display === */
.error-trace {
    background: #2d3436;
    color: #dfe6e9;
    padding: 16px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* === HTMX loading indicator === */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

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

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--color-text);
}

/* === Responsive === */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }

    .review-layout {
        grid-template-columns: 1fr;
    }

    .stats-bar {
        flex-direction: column;
    }
}
