/* ============================================================
   Crontab Editor — Premium Dark Theme (Purple/Pink)
   ============================================================ */

:root {
    --primary: #8B5CF6;
    --primary-hover: #A78BFA;
    --primary-glow: rgba(139, 92, 246, 0.25);
    --secondary: #EC4899;
    --accent: #F59E0B;
    --danger: #EF4444;
    --success: #10B981;

    --bg-base: #0C0A15;
    --bg-surface: #13111D;
    --bg-elevated: #1C1829;
    --bg-hover: #252133;
    --bg-active: #2E293E;

    --text-primary: #F0EDF8;
    --text-secondary: #A09CB5;
    --text-muted: #706C85;

    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --border-focus: var(--primary);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--primary-glow);

    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 250ms cubic-bezier(0.4, 0, 0.2, 1);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

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

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

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(139, 92, 246, .1), transparent), radial-gradient(ellipse 60% 40% at 80% 100%, rgba(236, 72, 153, .06), transparent);
    pointer-events: none;
}

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

.app-container {
    position: relative;
    z-index: 1;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px 60px;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 0 16px;
    gap: 16px;
    flex-wrap: wrap;
}

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

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

.subtitle {
    font-size: .82rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.tz-select-wrap select {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: .8rem;
    outline: none;
    cursor: pointer;
    max-width: 200px;
}

.tz-select-wrap select option {
    background: var(--bg-elevated);
}

.tz-select-wrap select:focus {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-glow);
}

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

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

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

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

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

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

.btn-sm {
    padding: 5px 10px;
    font-size: .78rem;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

/* Cron Display */
.cron-display-section {
    margin-bottom: 20px;
}

.cron-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.cron-fields {
    display: flex;
    gap: 4px;
    flex: 1;
    flex-wrap: wrap;
    justify-content: center;
}

.cron-field {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    min-width: 60px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.cron-field:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.cron-field.active {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

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

.cron-field-value {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    min-width: 24px;
    text-align: center;
}

.manual-input-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.manual-input {
    flex: 1;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: .88rem;
    outline: none;
    transition: border-color var(--transition-fast);
}

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

.human-readable {
    padding: 12px 16px;
    margin-top: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Presets */
.section-label {
    font-size: .88rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.presets-section {
    margin-bottom: 20px;
}

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

.preset-btn {
    padding: 6px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-family: var(--font-sans);
    font-size: .78rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

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

.preset-btn.active {
    background: rgba(139, 92, 246, .12);
    color: var(--primary);
    border-color: rgba(139, 92, 246, .3);
}

/* Selectors Grid */
.selectors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.selector-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.selector-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.selector-title {
    font-size: .88rem;
    font-weight: 600;
}

.selector-mode {
    display: flex;
    gap: 2px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.mode-btn {
    padding: 4px 10px;
    border: none;
    background: transparent;
    border-radius: 4px;
    font-family: var(--font-sans);
    font-size: .72rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

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

.selector-body {
    padding: 14px 16px;
    min-height: 60px;
}

.every-msg {
    font-size: .85rem;
    color: var(--text-muted);
    text-align: center;
    padding: 12px 0;
}

.step-controls,
.range-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.step-controls label,
.range-controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .85rem;
    color: var(--text-secondary);
}

.step-input,
.range-input {
    width: 60px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: .85rem;
    outline: none;
    text-align: center;
}

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

.specific-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
    gap: 4px;
}

.named-grid {
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
}

.specific-btn {
    padding: 6px 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    font-family: var(--font-mono);
    font-size: .78rem;
    color: var(--text-secondary);
    cursor: pointer;
    text-align: center;
    transition: all var(--transition-fast);
}

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

.specific-btn.selected {
    background: rgba(139, 92, 246, .15);
    color: var(--primary);
    border-color: rgba(139, 92, 246, .4);
    font-weight: 600;
}

/* Command Section */
.command-section {
    margin-bottom: 24px;
}

.command-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.command-input {
    flex: 1;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: .85rem;
    outline: none;
    transition: border-color var(--transition-fast);
}

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

.generated-output {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.generated-output[hidden] {
    display: none;
}

.generated-output code {
    flex: 1;
    font-family: var(--font-mono);
    font-size: .88rem;
    color: var(--accent);
    word-break: break-all;
}

/* Next Runs */
.next-runs-section {
    margin-bottom: 24px;
}

.next-runs-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.next-runs-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: .82rem;
    color: var(--text-secondary);
}

.next-runs-list li::before {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
}

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

.toast {
    padding: 10px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: .85rem;
    color: var(--text-primary);
    animation: toastSlide 300ms ease;
    max-width: 360px;
}

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

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

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

.toast-exit {
    animation: toastExit 200ms ease forwards;
}

@keyframes toastSlide {
    from {
        transform: translateX(100%);
        opacity: 0
    }

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

@keyframes toastExit {
    from {
        opacity: 1
    }

    to {
        opacity: 0;
        transform: translateX(100%)
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-active);
    border-radius: 3px;
}

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

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

    .subtitle {
        display: none;
    }

    .cron-field {
        padding: 6px 10px;
        min-width: 46px;
    }

    .cron-field-value {
        font-size: .9rem;
    }

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

    .selector-mode {
        flex-wrap: wrap;
    }
}