/* ============================================
   Crontab Guru — Premium Dark Theme
   ============================================ */

:root {
    --primary: #6C63FF;
    --primary-hover: #5A52E0;
    --primary-glow: rgba(108, 99, 255, 0.25);
    --secondary: #A78BFA;
    --accent: #C4B5FD;
    --bg: #0F0A1A;
    --bg-card: rgba(22, 17, 38, 0.85);
    --bg-elevated: rgba(35, 28, 55, 0.9);
    --bg-hover: rgba(108, 99, 255, 0.06);
    --border: rgba(108, 99, 255, 0.12);
    --border-hover: rgba(108, 99, 255, 0.25);
    --text: #E8E6F0;
    --text-muted: #9B96A8;
    --text-dim: #5A5570;
    --success: #34D399;
    --warning: #FBBF24;
    --danger: #F87171;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --glass: blur(20px);
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
    --sans: 'Inter', system-ui, -apple-system, sans-serif;
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(108, 99, 255, 0.1), transparent),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(167, 139, 250, 0.06), transparent);
}

/* --- Header --- */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: var(--glass);
    -webkit-backdrop-filter: var(--glass);
    background: rgba(15, 10, 26, 0.85);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    color: var(--primary);
    display: flex;
}

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

.logo-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: block;
}

.timezone-select {
    max-width: 220px;
    font-size: 0.78rem;
}

/* --- Section Titles --- */
.section-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.75rem;
}

.hint {
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
    opacity: 0.7;
}

/* --- Main --- */
.main {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* --- Expression Section --- */
.expression-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    backdrop-filter: var(--glass);
}

.expression-fields {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.field-col {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    text-align: center;
}

.field-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.field-input {
    width: 100%;
    padding: 0.6rem 0.4rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--primary);
    font-family: var(--mono);
    font-size: 1.3rem;
    font-weight: 600;
    text-align: center;
    transition: all var(--transition);
    outline: none;
}

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

.field-input.invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2);
}

.expression-string {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.cron-display {
    font-family: var(--mono);
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.1em;
}

.description {
    text-align: center;
    font-size: 0.92rem;
    color: var(--text);
    font-weight: 500;
    padding: 0.5rem 1rem;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--sans);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    box-shadow: 0 0 20px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 30px var(--primary-glow), 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

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

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: var(--radius-xs);
    transition: all var(--transition);
    display: flex;
}

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

/* --- Inputs --- */
.input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-family: var(--sans);
    font-size: 0.82rem;
    transition: all var(--transition);
    outline: none;
}

.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.select {
    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='%239B96A8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    padding-right: 2rem;
}

/* --- Preset Grid --- */
.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.5rem;
}

.preset-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.preset-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-elevated);
    transform: translateY(-1px);
}

.preset-card:active {
    transform: translateY(0);
}

.preset-name {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
}

.preset-expr {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--primary);
    background: var(--bg-hover);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    flex-shrink: 0;
}

/* --- Builder Grid --- */
.builder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

.builder-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
}

.builder-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: block;
    margin-bottom: 0.4rem;
}

/* --- Next Executions --- */
.next-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.4rem;
}

.next-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-family: var(--mono);
    font-size: 0.8rem;
    animation: fadeIn 300ms ease-out;
}

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

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

.next-index {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 1.5rem;
}

.next-date {
    color: var(--text);
    flex: 1;
}

.next-relative {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* --- Heatmap --- */
.heatmap-section {
    position: relative;
}

.heatmap-nav {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    gap: 0.25rem;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    margin-bottom: 0.75rem;
}

.heatmap-day-label {
    font-size: 0.62rem;
    color: var(--text-dim);
    text-align: center;
    padding: 0.2rem 0;
}

.heatmap-cell {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 3px;
    min-width: 12px;
    min-height: 12px;
    display: inline-block;
}

.heatmap-cell.day {
    cursor: default;
    transition: transform var(--transition);
}

.heatmap-cell.day:hover {
    transform: scale(1.2);
}

.level-0 {
    background: rgba(108, 99, 255, 0.05);
}

.level-1 {
    background: rgba(108, 99, 255, 0.2);
}

.level-2 {
    background: rgba(108, 99, 255, 0.4);
}

.level-3 {
    background: rgba(108, 99, 255, 0.65);
}

.level-4 {
    background: var(--primary);
}

.heatmap-cell.empty {
    background: transparent;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    justify-content: flex-end;
    font-size: 0.68rem;
    color: var(--text-muted);
}

.heatmap-legend .heatmap-cell {
    width: 14px;
    height: 14px;
    min-width: 14px;
}

/* --- Export Section --- */
.export-section {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 1rem;
    font-size: 0.82rem;
    color: var(--text);
    box-shadow: var(--shadow);
    animation: toastIn 300ms ease-out;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.info {
    border-left: 3px solid var(--primary);
}

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

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

/* --- Responsive --- */
@media (max-width: 640px) {
    .main {
        padding: 1rem;
        gap: 1.5rem;
    }

    .expression-fields {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.3rem;
    }

    .field-input {
        font-size: 1rem;
        padding: 0.5rem 0.2rem;
    }

    .cron-display {
        font-size: 1.2rem;
    }

    .preset-grid {
        grid-template-columns: 1fr;
    }

    .builder-grid {
        grid-template-columns: 1fr 1fr;
    }

    .next-list {
        grid-template-columns: 1fr;
    }

    .header-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .timezone-select {
        max-width: 100%;
    }
}