/* ============================================================
   TEXTIFY ANIMATION - Timeline Compacto
   ============================================================ */

/* ==================== PANEL COMPACTO ==================== */
#animationPanel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #11111b;
    border-top: 1px solid #313244;
}

#animationPanel.hidden {
    display: none;
}

/* Barra de controles principal */
.animation-bar {
    position: relative;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: linear-gradient(180deg, #1e1e2e 0%, #181825 100%);
    flex-wrap: wrap;
}


/* ============================================================
   FIX iOS/iPad hit-area & overlap in animation bar
   - Evita que #currentTimeDisplay solape botones en flex-wrap
   - Hace que los botones reciban el tap en toda su caja
   ============================================================ */
.animation-bar { align-content: flex-start; }

.anim-btn {
    position: relative;
    z-index: 5;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.anim-btn > * { pointer-events: none; }

#currentTimeDisplay {
    position: relative;
    z-index: 1;
    pointer-events: none;
    user-select: none;
}

.duration-control {
    position: relative;
    z-index: 4;
}

#animPrevFrameBtn { position: relative; z-index: 6; }
#animNextFrameBtn { position: relative; z-index: 70; line-height: 36px; }

/* Botones de control */
.anim-btn {
width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: #313244;
    color: #cdd6f4;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;
    position: relative;
    /* Mantener por encima de otros elementos del flex (duración/tiempo) para evitar hitboxes parciales. */
    z-index: 6;
    line-height: 1;
}

.anim-btn:hover {
    background: #45475a;
}

.anim-btn:active {
    transform: scale(0.95);
}

.anim-btn.active {
    background: #89b4fa;
    color: #1e1e2e;
}

.anim-btn.primary {
    background: linear-gradient(135deg, #f38ba8 0%, #fab387 100%);
    color: #1e1e2e;
}

.anim-btn.primary:hover {
    filter: brightness(1.1);
}

.anim-btn.kf-add {
    background: linear-gradient(135deg, #a6e3a1 0%, #94e2d5 100%);
    color: #1e1e2e;
    font-weight: 700;
    font-size: 12px;
}

.anim-btn.kf-nav {
    /* En escritorio algunos glifos (◀/▶/◆) pueden renderizar más altos que 30px y quedar “fuera”
       del hitbox; usar el mismo tamaño del botón base asegura que todo el icono sea clicable. */
    width: 36px;
    height: 36px;
    font-size: 12px;
    border-radius: 8px;
    z-index: 60;
}

/* Time Display */
#currentTimeDisplay {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: #a6e3a1;
    background: #11111b;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
}

/* Duration Input */
.duration-control {
    display: flex;
    align-items: center;
    gap: 4px;
}

.duration-control label {
    font-size: 11px;
    color: #a6adc8;
}

.duration-control input {
    width: 50px;
    padding: 6px;
    border: 1px solid #313244;
    border-radius: 6px;
    background: #11111b;
    color: #cdd6f4;
    font-size: 12px;
    text-align: center;
}

.duration-control input:focus {
    outline: none;
    border-color: #89b4fa;
}

.duration-control span {
    font-size: 11px;
    color: #a6adc8;
}

.easing-control {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 170px;
}

.easing-control label {
    font-size: 11px;
    color: #a6adc8;
    white-space: nowrap;
}

.easing-control select {
    min-width: 120px;
    padding: 6px;
    border: 1px solid #313244;
    border-radius: 6px;
    background: #11111b;
    color: #cdd6f4;
    font-size: 12px;
}

.easing-control select:focus {
    outline: none;
    border-color: #89b4fa;
}

.easing-editor {
    border-top: 1px solid #313244;
    padding: 8px 12px;
    background: linear-gradient(180deg, #171725 0%, #131321 100%);
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: center;
}

.easing-editor.hidden {
    display: none;
}

.easing-editor-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.easing-editor label {
    font-size: 11px;
    color: #a6adc8;
}

.easing-editor input {
    width: 66px;
    padding: 6px;
    border: 1px solid #313244;
    border-radius: 6px;
    background: #11111b;
    color: #cdd6f4;
    font-size: 12px;
}

.easing-editor #animEaseName {
    width: 140px;
}

/* ==================== TIMELINE COLAPSABLE ==================== */
.timeline-container {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.timeline-container.expanded {
    max-height: 200px;
}

#animationTimeline {
    display: flex;
    flex-direction: column;
    background: #11111b;
}

/* Ruler */
.timeline-ruler {
    height: 20px;
    background: #181825;
    border-bottom: 1px solid #313244;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.ruler-mark {
    position: absolute;
    bottom: 0;
    width: 1px;
    background: #45475a;
}

.ruler-mark.major {
    height: 12px;
    background: #585b70;
}

.ruler-mark.minor {
    height: 6px;
}

.ruler-label {
    position: absolute;
    top: 2px;
    left: 3px;
    font-size: 9px;
    color: #a6adc8;
    white-space: nowrap;
}

/* Tracks */
.timeline-tracks-wrapper {
    max-height: 150px;
    overflow: auto;
    position: relative;
}

.timeline-tracks {
    min-height: 50px;
}

.timeline-track {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid #313244;
    min-height: 32px;
}

.track-label {
    width: 80px;
    min-width: 80px;
    padding: 6px 8px;
    background: #1e1e2e;
    border-right: 1px solid #313244;
    font-size: 11px;
    color: #cdd6f4;
    display: flex;
    align-items: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    position: sticky;
    left: 0;
    z-index: 2;
}

.track-keyframes {
    flex: 1;
    position: relative;
    background: 
        repeating-linear-gradient(90deg, transparent, transparent 99px, #313244 99px, #313244 100px),
        linear-gradient(180deg, #181825 0%, #11111b 100%);
    cursor: crosshair;
    min-height: 32px;
}

/* Keyframe Markers */
.keyframe-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 34px;
    height: 34px;
    /* Safari: asegura hit-testing en toda el área */
    background: rgba(0, 0, 0, 0.001);
    border: 0;
    cursor: pointer;
    transition: all 0.15s ease;
    z-index: 1;
    --kf-bg: #89b4fa;
    pointer-events: auto;
    touch-action: manipulation;
}

.keyframe-marker::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 12px;
    height: 12px;
    transform: translate(-50%, -50%) rotate(45deg);
    background: var(--kf-bg);
    border: 2px solid #cdd6f4;
    border-radius: 2px;
    transition: all 0.15s ease;
    pointer-events: none;
}

.keyframe-marker:hover {
    filter: drop-shadow(0 0 8px rgba(137, 180, 250, 0.5));
}

.keyframe-marker:hover::before {
    transform: translate(-50%, -50%) rotate(45deg) scale(1.25);
}

.keyframe-marker.selected::before {
    transform: translate(-50%, -50%) rotate(45deg) scale(1.28);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55), 0 0 14px rgba(166, 227, 161, 0.9);
}

.keyframe-marker.kf-transform { --kf-bg: #f38ba8; }
.keyframe-marker.kf-color { --kf-bg: #f9e2af; }
.keyframe-marker.kf-effect { --kf-bg: #a6e3a1; }

/* Playhead */
#timelinePlayhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #f38ba8;
    z-index: 10;
    pointer-events: none;
}

#timelinePlayhead::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -4px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #f38ba8;
}

/* ==================== MENÚ DE EXPORTACIÓN ==================== */
.export-dropdown {
    position: fixed;
    background: #1e1e2e;
    border: 1px solid #313244;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    padding: 8px;
    z-index: 2000;
    min-width: 180px;
}

.export-dropdown.hidden {
    display: none;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #cdd6f4;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.dropdown-item:hover {
    background: #313244;
}

.dropdown-divider {
    border: none;
    border-top: 1px solid #313244;
    margin: 8px 0;
}

/* ==================== MENÚ KEYFRAME ==================== */
.keyframe-menu {
    position: fixed;
    background: #1e1e2e;
    border: 1px solid #313244;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    padding: 8px;
    z-index: 2000;
    max-height: 350px;
    overflow-y: auto;
    min-width: 180px;
}

.menu-group {
    margin-bottom: 4px;
}

.menu-group-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #585b70;
    padding: 6px 8px 2px;
    letter-spacing: 0.5px;
}

.menu-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #cdd6f4;
    font-size: 12px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.menu-item:hover {
    background: #313244;
}

/* ==================== HEADER BUTTON ACTIVE STATE ==================== */
.icon-btn.active {
    background: rgba(243, 139, 168, 0.2);
    color: #f38ba8;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 600px) {
    .animation-bar {
        padding: 6px 8px;
        gap: 6px;
    }
    
    .anim-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    #currentTimeDisplay {
        font-size: 10px;
        padding: 4px 8px;
    }
    
    .duration-control input {
        width: 40px;
    }

    .easing-control {
        min-width: 148px;
    }

    .easing-control select {
        min-width: 96px;
        font-size: 11px;
        padding: 5px;
    }

    .easing-editor {
        padding: 8px;
        gap: 6px;
    }

    .easing-editor input {
        width: 58px;
        padding: 5px;
        font-size: 11px;
    }

    .easing-editor #animEaseName {
        width: 118px;
    }
    
    .track-label {
        width: 60px;
        min-width: 60px;
        font-size: 10px;
    }
}

/* ==================== SCROLLBAR ==================== */
.timeline-tracks-wrapper::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.timeline-tracks-wrapper::-webkit-scrollbar-track {
    background: #11111b;
}

.timeline-tracks-wrapper::-webkit-scrollbar-thumb {
    background: #45475a;
    border-radius: 3px;
}

.keyframe-menu::-webkit-scrollbar {
    width: 6px;
}

.keyframe-menu::-webkit-scrollbar-track {
    background: #11111b;
}

.keyframe-menu::-webkit-scrollbar-thumb {
    background: #45475a;
    border-radius: 3px;
}
