/* ============================================
   Cron Job Visualizer — Styles
   Theme: Dark mode with Golden Amber palette
   ============================================ */

/* --- Design Tokens --- */
:root {
    --primary: #F39C12;
    --primary-rgb: 243, 156, 18;
    --secondary: #F1C40F;
    --secondary-rgb: 241, 196, 15;
    --accent: #3498DB;
    --accent-rgb: 52, 152, 219;
    --background: #1A150A;
    --surface: #241D0E;
    --surface-hover: #2E2614;
    --surface-active: #382F1A;
    --border: rgba(243, 156, 18, 0.15);
    --border-hover: rgba(243, 156, 18, 0.3);
    --text-primary: #F5F0E8;
    --text-secondary: #B8A88A;
    --text-muted: #7A6C56;
    --error: #E74C3C;
    --success: #2ECC71;
    --warning: #E67E22;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --transition: 250ms ease;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

    /* Job colors for multi-job timeline */
    --job-color-0: #F39C12;
    --job-color-1: #3498DB;
    --job-color-2: #2ECC71;
    --job-color-3: #E74C3C;
    --job-color-4: #9B59B6;
    --job-color-5: #1ABC9C;
    --job-color-6: #E67E22;
    --job-color-7: #F1C40F;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Ambient background glow */
body::before {
    content: '';
    position: fixed;
    top: -200px;
    right: -200px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(var(--primary-rgb), 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: -200px;
    left: -200px;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(var(--accent-rgb), 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* --- Screen Reader Only --- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- App Container --- */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Glass Panel --- */
.glass-panel {
    background: rgba(36, 29, 14, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-md);
}

/* --- Header --- */
.app-header {
    padding: 40px 0 32px;
    text-align: center;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon svg {
    filter: drop-shadow(0 0 8px rgba(var(--primary-rgb), 0.4));
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {

    0%,
    100% {
        filter: drop-shadow(0 0 8px rgba(var(--primary-rgb), 0.4));
    }

    50% {
        filter: drop-shadow(0 0 14px rgba(var(--primary-rgb), 0.6));
    }
}

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

.header-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 40px;
}

/* --- Section Headers --- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

/* --- Buttons --- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--background);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

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

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-secondary:hover {
    background: rgba(var(--primary-rgb), 0.1);
    border-color: var(--border-hover);
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: var(--radius-xs);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-ghost:hover {
    color: var(--error);
    background: rgba(231, 76, 60, 0.1);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-icon:hover {
    color: var(--error);
    background: rgba(231, 76, 60, 0.1);
}

/* --- Input Fields --- */
.input-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

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

.cron-input-group {
    flex: 1;
}

.name-input-group {
    flex: 0.6;
}

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

.input-field {
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: all var(--transition);
    outline: none;
}

.input-field.mono {
    font-family: var(--font-mono);
    font-size: 1rem;
    letter-spacing: 0.12em;
}

.input-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

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

.select-field {
    padding: 6px 28px 6px 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23B8A88A' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: all var(--transition);
}

.select-field:focus {
    border-color: var(--primary);
}

/* --- Cron Field Hints --- */
.cron-fields-hint {
    display: flex;
    gap: 0;
    padding: 0 14px;
}

.cron-fields-hint span {
    flex: 1;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    max-width: 60px;
}

/* --- Error Message --- */
.error-message {
    font-size: 0.78rem;
    color: var(--error);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* --- Cron Description --- */
.cron-description {
    margin-top: 12px;
    padding: 10px 16px;
    background: rgba(var(--primary-rgb), 0.06);
    border-left: 3px solid var(--primary);
    border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-height: 0;
    transition: all var(--transition);
}

.cron-description:empty {
    display: none;
}

.cron-description strong {
    color: var(--primary);
}

/* --- Presets Panel --- */
.presets-panel {
    margin-bottom: 16px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    animation: slideDown 200ms ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

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

.presets-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.preset-chip {
    padding: 6px 14px;
    background: rgba(var(--primary-rgb), 0.08);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.preset-chip:hover {
    background: rgba(var(--primary-rgb), 0.18);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

/* --- Jobs List --- */
.jobs-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.job-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(36, 29, 14, 0.5);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    animation: fadeInUp 250ms ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

.job-card:hover {
    border-color: var(--border-hover);
}

.job-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px currentColor;
}

.job-info {
    flex: 1;
    min-width: 0;
}

.job-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.job-expression {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
}

.job-summary {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* --- Timeline --- */
.timeline-controls {
    display: flex;
    gap: 8px;
}

.range-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    overflow: hidden;
}

.range-btn {
    padding: 6px 14px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.range-btn:hover {
    color: var(--text-secondary);
    background: rgba(var(--primary-rgb), 0.05);
}

.range-btn.active {
    background: rgba(var(--primary-rgb), 0.2);
    color: var(--primary);
}

.timeline-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
}

.timeline-container {
    position: relative;
    min-height: 180px;
    width: 100%;
}

/* Timeline internals */
.timeline-header {
    display: flex;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 8px;
    position: relative;
}

.timeline-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    position: absolute;
    transform: translateX(-50%);
    white-space: nowrap;
}

.timeline-grid {
    position: relative;
    min-height: 120px;
}

.timeline-row {
    position: relative;
    height: 36px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
}

.timeline-row-label {
    position: absolute;
    left: 0;
    font-size: 0.7rem;
    color: var(--text-secondary);
    width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    z-index: 2;
}

.timeline-bar {
    position: absolute;
    left: 110px;
    right: 0;
    height: 100%;
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-xs);
    overflow: hidden;
}

.timeline-tick {
    position: absolute;
    width: 3px;
    height: 20px;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 2px;
    opacity: 0.85;
    transition: opacity 150ms ease;
}

.timeline-tick:hover {
    opacity: 1;
    height: 28px;
}

.timeline-tick.collision {
    box-shadow: 0 0 6px var(--error);
}

.timeline-gridline {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border);
    opacity: 0.4;
}

.timeline-time-labels {
    display: flex;
    justify-content: space-between;
    padding-left: 110px;
    margin-bottom: 12px;
}

.timeline-time-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* --- Collision Alerts --- */
.collision-alerts {
    padding: 12px 16px;
    background: rgba(231, 76, 60, 0.08);
    border: 1px solid rgba(231, 76, 60, 0.2);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.collision-alert-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--error);
    padding: 4px 0;
}

.collision-alert-item svg {
    flex-shrink: 0;
}

/* --- Executions List --- */
.executions-list {
    max-height: 400px;
    overflow-y: auto;
}

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

.execution-table thead th {
    text-align: left;
    padding: 8px 12px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}

.execution-table tbody td {
    padding: 8px 12px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(var(--primary-rgb), 0.05);
}

.execution-table tbody tr:hover td {
    background: rgba(var(--primary-rgb), 0.04);
}

.execution-table .exec-time {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-primary);
}

.execution-table .exec-job {
    display: flex;
    align-items: center;
    gap: 6px;
}

.execution-table .exec-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.execution-table .exec-relative {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Export --- */
.export-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    box-shadow: var(--shadow-lg);
    animation: toastIn 300ms ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.success {
    border-color: rgba(46, 204, 113, 0.3);
}

.toast.error {
    border-color: rgba(231, 76, 60, 0.3);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

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

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* --- Footer --- */
.app-footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-muted);
    font-size: 0.78rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .app-container {
        padding: 0 16px;
    }

    .app-header h1 {
        font-size: 1.4rem;
    }

    .input-row {
        flex-direction: column;
        align-items: stretch;
    }

    .name-input-group {
        flex: 1;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .timeline-time-labels {
        padding-left: 80px;
    }

    .timeline-row-label {
        width: 70px;
        font-size: 0.6rem;
    }

    .timeline-bar {
        left: 80px;
    }

    .glass-panel {
        padding: 16px;
    }

    .presets-grid {
        gap: 6px;
    }

    .preset-chip {
        font-size: 0.72rem;
        padding: 5px 10px;
    }

    .export-buttons {
        flex-direction: column;
    }

    .toast-container {
        bottom: 16px;
        right: 16px;
        left: 16px;
    }
}

@media (max-width: 480px) {
    .app-header {
        padding: 24px 0 20px;
    }

    .logo-group {
        flex-direction: column;
        gap: 8px;
    }

    .execution-table .exec-relative {
        display: none;
    }
}