/* Night Tales Dashboard — Dark Horror Theme */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #16161f;
    --bg-input: #1a1a25;
    --border: #2a2a3a;
    --text-primary: #e0e0e8;
    --text-secondary: #8888a0;
    --text-muted: #55556a;
    --accent: #6c5ce7;
    --accent-hover: #7d6ff0;
    --success: #2ed573;
    --error: #ff4757;
    --warning: #ffa502;
    --running: #6c5ce7;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* === Navbar === */

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-icon {
    font-size: 20px;
}

.brand-text {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: var(--accent);
}

.logout-link {
    color: var(--text-muted);
}

.mac-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
}

.indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.mac-indicator.online .indicator-dot {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.mac-indicator.offline .indicator-dot {
    background: var(--text-muted);
}

.mac-indicator.online {
    color: var(--success);
}

.mac-indicator.offline {
    color: var(--text-muted);
}

/* === Container === */

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* === Cards === */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
    letter-spacing: 0.3px;
}

/* === Pipeline Status === */

.pipeline-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pipeline-label {
    color: var(--text-secondary);
    font-size: 13px;
}

.pipeline-value {
    font-weight: 600;
    font-size: 15px;
}

.pipeline-meta {
    display: flex;
    gap: 20px;
    font-size: 12px;
    color: var(--text-muted);
}

.pipeline-meta code {
    font-family: var(--font-mono);
    background: var(--bg-input);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
}

/* === Reference Channel === */

.ref-card {
    padding: 12px 24px;
}

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

.ref-label {
    color: var(--text-muted);
}

.ref-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

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

.ref-video-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 12px;
}

.ref-video-link:hover {
    text-decoration: underline;
}

.ref-video-link-sm {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
}

.ref-video-link-sm:hover {
    color: var(--accent);
}

/* === Step Badge === */

.step-badge {
    display: inline-block;
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    margin-right: 6px;
}

/* === 10-Step Pipeline Grid === */

.steps-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border-radius: var(--radius);
    background: var(--bg-input);
    text-align: center;
    transition: all 0.3s;
    border: 1px solid transparent;
}

.step-item.done {
    background: rgba(46, 213, 115, 0.08);
    border-color: rgba(46, 213, 115, 0.2);
}

.step-item.active {
    background: rgba(108, 92, 231, 0.15);
    border-color: var(--accent);
    animation: pulse 2s infinite;
}

.step-item.pending {
    opacity: 0.4;
}

.step-emoji {
    font-size: 18px;
}

.step-num {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
}

.step-name {
    font-size: 10px;
    color: var(--text-secondary);
    line-height: 1.2;
}

.step-item.done .step-name {
    color: var(--success);
}

.step-item.active .step-name {
    color: var(--accent);
    font-weight: 600;
}

/* === Progress Bar === */

.progress-container {
    width: 100%;
    height: 28px;
    background: var(--bg-input);
    border-radius: 14px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #a29bfe);
    border-radius: 14px;
    transition: width 0.6s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    min-width: 40px;
}

.progress-text {
    font-size: 11px;
    font-weight: 700;
    color: white;
}

.stage-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--accent);
    text-align: center;
}

.substep-text {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-top: 4px;
    font-family: var(--font-mono);
}

/* === Stage Timeline === */

.stage-timeline {
    margin-top: 8px;
    padding-left: 16px;
    border-left: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

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

.timeline-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
    margin-left: -19px;
}

.timeline-stage {
    color: var(--text-primary);
    font-weight: 500;
}

.timeline-time {
    color: var(--text-muted);
    font-size: 11px;
    font-family: var(--font-mono);
    margin-left: auto;
}

/* === Pipeline Idle === */

.pipeline-idle {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
}

.idle-icon {
    font-size: 36px;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* === Run List === */

.runs-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.run-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: var(--bg-input);
    transition: background 0.2s;
}

.run-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.run-status-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.run-status-badge.complete {
    background: rgba(46, 213, 115, 0.15);
    color: var(--success);
}

.run-status-badge.failed {
    background: rgba(255, 71, 87, 0.15);
    color: var(--error);
}

.run-status-badge.running {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent);
    animation: pulse 2s infinite;
}

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

.run-details {
    flex: 1;
    min-width: 0;
}

.run-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.run-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.yt-link {
    color: var(--accent);
    text-decoration: none;
}

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

/* === History Table === */

.table-container {
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.history-table th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.history-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

.history-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.status-badge.complete {
    background: rgba(46, 213, 115, 0.15);
    color: var(--success);
}

.status-badge.failed {
    background: rgba(255, 71, 87, 0.15);
    color: var(--error);
}

.status-badge.running {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent);
}

.status-badge.queued {
    background: rgba(255, 165, 2, 0.15);
    color: var(--warning);
}

.run-status-badge.queued {
    background: rgba(255, 165, 2, 0.15);
    color: var(--warning);
}

.title-cell {
    max-width: 300px;
}

.run-title-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.run-id {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

.time-cell {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.error-text {
    color: var(--error);
    cursor: help;
    font-size: 11px;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 32px;
    font-size: 14px;
}

/* === Login === */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
}

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

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 36px 28px;
    box-shadow: var(--shadow);
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-icon {
    font-size: 40px;
    display: block;
    margin-bottom: 8px;
}

.login-header h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 1px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--accent);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.btn-full {
    width: 100%;
}

.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-error {
    background: rgba(255, 71, 87, 0.12);
    color: var(--error);
    border: 1px solid rgba(255, 71, 87, 0.2);
}

/* === Footer === */

.footer {
    text-align: center;
    padding: 16px;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

/* === Responsive === */

@media (max-width: 640px) {
    .navbar {
        flex-direction: column;
        height: auto;
        padding: 12px;
        gap: 8px;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    .pipeline-meta {
        flex-direction: column;
        gap: 4px;
    }

    .history-table {
        font-size: 12px;
    }

    .title-cell {
        max-width: 150px;
    }
}
