/* ===== Cron Job Monitor Dashboard ===== */
/* Blue-Violet gradient | BG: #0A0E1A */

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

:root {
    --primary: #3B82F6;
    --primary-light: #60A5FA;
    --primary-dim: rgba(59, 130, 246, 0.12);
    --primary-glow: rgba(59, 130, 246, 0.25);
    --purple: #8B5CF6;
    --purple-dim: rgba(139, 92, 246, 0.12);
    --success: #22C55E;
    --success-dim: rgba(34, 197, 94, 0.12);
    --danger: #EF4444;
    --danger-dim: rgba(239, 68, 68, 0.12);
    --warning: #F59E0B;
    --warning-dim: rgba(245, 158, 11, 0.12);
    --bg-base: #0A0E1A;
    --bg-surface: #111827;
    --bg-elevated: #1F2937;
    --bg-hover: #283548;
    --bg-input: #0D1320;
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --border: rgba(148, 163, 184, 0.1);
    --border-focus: rgba(59, 130, 246, 0.5);
    --radius: 10px;
    --radius-sm: 6px;
    --font-sans: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== Header ===== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.95), rgba(10, 14, 26, 0.98));
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 50;
}

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

.header-left h1 {
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--purple));
    color: #fff;
    border: none;
    box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-primary:hover {
    box-shadow: 0 4px 16px var(--primary-glow);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

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

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

.btn-sm {
    padding: 6px 10px;
    font-size: 0.75rem;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 0.7rem;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.2rem;
}

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

.btn-save {
    width: 100%;
    justify-content: center;
    padding: 10px;
    margin-top: 8px;
}

/* ===== Stats Bar ===== */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding: 20px 24px;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: rgba(148, 163, 184, 0.2);
    transform: translateY(-1px);
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-success {
    color: var(--success);
}

.stat-running {
    color: var(--primary);
}

.stat-failed {
    color: var(--danger);
}

.stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 0;
    min-height: 0;
}

/* ===== Jobs Section ===== */
.jobs-section {
    padding: 0 24px 24px;
    overflow-y: auto;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0 12px;
}

.section-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
}

.filter-bar {
    display: flex;
    gap: 8px;
}

/* ===== Inputs ===== */
.input,
.select {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    padding: 9px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: var(--transition);
    outline: none;
}

.input:focus,
.select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.input::placeholder {
    color: var(--text-muted);
}

.input-sm,
.select-sm {
    padding: 6px 10px;
    font-size: 0.78rem;
}

.mono {
    font-family: var(--font-mono);
}

.select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%2394A3B8' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

.hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

/* ===== Jobs Table ===== */
.table-wrap {
    overflow-x: auto;
}

.jobs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.jobs-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
}

.jobs-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.jobs-table tr {
    transition: var(--transition);
}

.jobs-table tr:hover {
    background: rgba(59, 130, 246, 0.04);
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot.active {
    background: var(--success);
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.status-dot.paused {
    background: var(--warning);
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}

.status-dot.failed {
    background: var(--danger);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.rate-bar {
    width: 60px;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

.rate-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.rate-good {
    background: var(--success);
}

.rate-warn {
    background: var(--warning);
}

.rate-bad {
    background: var(--danger);
}

.action-btns {
    display: flex;
    gap: 4px;
}

.action-btns .btn-icon {
    width: 26px;
    height: 26px;
    font-size: 0.85rem;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.empty-state p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.empty-state span {
    font-size: 0.72rem;
}

.empty-hint {
    color: var(--text-muted);
    font-size: 0.78rem;
    text-align: center;
    padding: 20px;
}

/* ===== History Section ===== */
.history-section {
    padding: 16px;
    border-left: 1px solid var(--border);
    overflow-y: auto;
    background: var(--bg-surface);
}

.history-section .section-header {
    padding: 0 0 12px;
}

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

.timeline-item {
    padding: 10px 12px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    animation: fadeIn 0.2s ease-out;
}

.timeline-item:hover {
    border-color: rgba(148, 163, 184, 0.2);
}

.timeline-item .ti-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.timeline-item .ti-name {
    font-size: 0.78rem;
    font-weight: 600;
}

.timeline-item .ti-badge {
    font-size: 0.62rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
}

.ti-badge.success {
    background: var(--success-dim);
    color: var(--success);
}

.ti-badge.failed {
    background: var(--danger-dim);
    color: var(--danger);
}

.timeline-item .ti-meta {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    width: 440px;
    max-width: 90vw;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

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

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

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.82rem;
    color: var(--text-primary);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 1000;
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 16px;
    }

    .main-content {
        grid-template-columns: 1fr;
    }

    .history-section {
        border-left: none;
        border-top: 1px solid var(--border);
        max-height: 300px;
    }

    .jobs-section {
        padding: 0 16px 16px;
    }
}

@media (max-width: 600px) {
    .header {
        flex-direction: column;
        gap: 8px;
        padding: 10px 16px;
    }

    .stats-bar {
        grid-template-columns: 1fr 1fr;
    }

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

    .form-row {
        flex-direction: column;
    }
}