/* =========================================
   CSS Animation Timeline Editor — Styles
   Vibrant gradient palette, dark mode
   ========================================= */

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

:root {
    --primary: #8B5CF6;
    --primary-light: #A78BFA;
    --primary-dark: #7C3AED;
    --primary-glow: rgba(139, 92, 246, 0.15);
    --accent: #F472B6;
    --accent-light: #F9A8D4;
    --accent-glow: rgba(244, 114, 182, 0.15);

    --bg-base: #0C0A1D;
    --bg-surface: #16132D;
    --bg-elevated: #1E1A3A;
    --bg-hover: #292447;
    --bg-input: #0A0818;

    --text-primary: #F1F5F9;
    --text-secondary: #A5B4FC;
    --text-muted: #6B7294;

    --border: #2A2650;
    --success: #10B981;
    --error: #EF4444;
    --warning: #F59E0B;

    --radius: 10px;
    --radius-sm: 6px;
    --font: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --transition: 200ms ease;
}

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

.app {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px 60px;
}

/* Header */
.header {
    padding: 20px 0 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

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

.logo {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    box-shadow: 0 0 20px var(--primary-glow);
}

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

.tagline {
    font-size: 0.75rem;
    color: var(--text-muted);
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 14px;
}

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

.btn-sm {
    font-size: 0.78rem;
    padding: 6px 12px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 8px 16px;
    box-shadow: 0 0 15px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 25px rgba(139, 92, 246, 0.3);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent), #EC4899);
    color: #fff;
    padding: 8px 16px;
}

.btn-accent:hover {
    transform: translateY(-1px);
}

.btn-danger {
    color: var(--error);
    background: transparent;
}

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

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

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

.select {
    cursor: pointer;
}

.input-unit {
    display: flex;
    align-items: center;
    gap: 4px;
}

.input-unit input {
    width: 80px;
}

.input-unit span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Controls Bar */
.controls-bar {
    display: flex;
    gap: 14px;
    padding: 16px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

/* Editor Layout */
.editor-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 16px;
    margin-bottom: 20px;
}

/* Timeline */
.timeline-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.timeline-header,
.preview-header,
.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.timeline-header h2,
.preview-header h2,
.code-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
}

.preview-controls {
    display: flex;
    gap: 6px;
}

/* Timeline Track */
.timeline-track {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
}

.track-ruler {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.track-bar {
    position: relative;
    height: 32px;
    background: linear-gradient(90deg, var(--bg-elevated), var(--bg-hover));
    border-radius: 4px;
    overflow: visible;
}

.keyframe-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    border: 2px solid var(--primary-light);
    cursor: grab;
    z-index: 2;
    transition: transform 100ms ease, box-shadow 100ms ease;
}

.keyframe-marker:hover,
.keyframe-marker.active {
    transform: translate(-50%, -50%) scale(1.3);
    box-shadow: 0 0 10px var(--primary-glow);
}

.keyframe-marker.active {
    background: var(--accent);
    border-color: var(--accent-light);
}

/* Keyframes List */
.keyframes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.kf-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    cursor: pointer;
    transition: border-color var(--transition);
}

.kf-card:hover,
.kf-card.active {
    border-color: var(--primary);
}

.kf-card.active {
    border-left: 3px solid var(--primary);
}

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

.kf-percent {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-light);
}

.kf-props {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kf-prop-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.kf-prop-row .input {
    font-size: 0.78rem;
    padding: 4px 8px;
}

.kf-prop-row .prop-name {
    flex: 1;
    font-family: var(--font-mono);
}

.kf-prop-row .prop-value {
    flex: 2;
    font-family: var(--font-mono);
}

.kf-actions {
    display: flex;
    gap: 4px;
}

/* Preview */
.preview-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.preview-stage {
    background: var(--bg-input);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.preview-element {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    transition: none;
}

/* Code Output */
.code-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.code-output {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--accent);
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    max-height: 250px;
    overflow-y: auto;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 20px;
    font-size: 0.85rem;
    color: var(--text-primary);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    z-index: 200;
    opacity: 0;
    transition: transform 250ms ease, opacity 250ms ease;
    pointer-events: none;
}

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

.hidden {
    display: none !important;
}

@media (max-width: 768px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }

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

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

::-webkit-scrollbar {
    width: 6px;
}

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

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