/* Improved animation controls panel */
.animation-controls {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    background-color: rgba(248, 243, 226, 0.95);
    border: 1px solid #725634;
    border-radius: 8px;
    padding: 16px;
    display: none; /* Hidden by default */
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.25);
    z-index: 10;
    backdrop-filter: blur(3px); /* Subtle blur for modern look */
}

/* Enhanced timeline container with better spacing */
.timeline-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    position: relative;
    padding-bottom: 25px; /* Space for shortcuts below */
}

/* Improved timeline labels with more professional styling */
.timeline-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    font-size: 13px;
    color: #4a2b0f;
    margin-bottom: 8px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Cleaner duration label */
.duration-label {
    font-size: 13px;
    white-space: nowrap;
    background: linear-gradient(to bottom, #f8f3e2, #e9e0cc);
    border-radius: 6px;
    padding: 6px 12px;
    border: 1px solid #c9b38c;
    display: flex;
    align-items: center;
}

.duration-label input {
    width: 48px;
    padding: 4px 8px;
    border: 1px solid #c9b38c;
    border-radius: 4px;
    font-size: 14px;
    text-align: center;
    margin: 0 6px;
    background-color: white;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
    font-weight: 600;
    color: #4a2b0f;
}

/* Enhanced timeline track */
.timeline {
    position: relative;
    height: 18px; /* Slimmer track */
    background: linear-gradient(to bottom, rgba(233, 224, 204, 0.5), rgba(201, 179, 140, 0.3));
    border: 1px solid #c9b38c;
    border-radius: 9px; /* Fully rounded for modern look */
    margin-bottom: 16px;
    cursor: pointer;
    z-index: 1;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.timeline::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.3), transparent);
    pointer-events: none;
    z-index: 2;
}

/* Enhanced time markers */
.timeline-markers {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    pointer-events: none;
}

.timeline-marker {
    position: absolute;
    top: 2px;
    bottom: 2px;
    width: 1px;
    background-color: rgba(74, 43, 15, 0.5);
    pointer-events: all;
}

.timeline-marker::after {
    content: attr(data-time) + "s";
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    white-space: nowrap;
    color: #4a2b0f;
    background-color: rgba(233, 224, 204, 0.9);
    padding: 2px 5px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
}

.timeline-marker:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-2px);
}

/* Improved playhead */
.playhead {
    position: absolute;
    top: -5px;
    bottom: -5px;
    width: 2px;
    background-color: #e67e22;
    left: 0;
    border-radius: 1px;
    pointer-events: none;
}

.playhead::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #e67e22;
    box-shadow: 0 0 0 2px #fff;
}

/* Better keyframe markers */
.keyframe-marker {
    position: absolute;
    width: 14px;
    height: 14px;
    background: radial-gradient(circle at center, #e67e22, #d35400);
    border: 2px solid #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(1);
    z-index: 10;
    cursor: pointer;
    box-shadow: 0 0 0 2px rgba(230, 126, 34, 0.3), 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.keyframe-marker:hover {
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 0 0 2px rgba(230, 126, 34, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3);
}

.keyframe-marker.selected {
    background: radial-gradient(circle at center, #f39c12, #e67e22);
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 0 0 2px #e67e22, 0 0 10px rgba(243, 156, 18, 0.6);
}

.keyframe-marker::before {
    content: "Right-click to delete";
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(41, 41, 41, 0.9);
    color: white;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 100;
}

.keyframe-marker:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-3px);
}

/* Improved control buttons layout */
.timeline-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
    padding: 5px 0;
    margin-bottom: 16px; /* Space for shortcuts */
}

/* Improved button grouping */
.button-group {
    display: flex;
    gap: 8px;
}

/* Time display */
.animation-time-display {
    position: absolute;
    top: -38px;
    right: 0;
    background: linear-gradient(to bottom, #f8f3e2, #e9e0cc);
    color: #4a2b0f;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    pointer-events: none;
    border: 1px solid rgba(201, 179, 140, 0.5);
    display: flex;
    align-items: center;
}

.animation-time-display::before {
    content: "⏱️";
    margin-right: 6px;
    font-size: 14px;
}

/* Enhanced button styling */
.animation-btn {
    height: 36px;
    border-radius: 6px;
    background-color: #546a3c;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.animation-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.1), transparent);
    pointer-events: none;
}

.animation-btn:hover {
    background-color: #3a4a29;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.animation-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Control buttons */
#play-animation, #stop-animation {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 22px;
    overflow: hidden;
    position: relative;
}

#play-animation .icon, #stop-animation .icon {
    margin: 0;
    font-size: 20px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#play-animation {
    background: linear-gradient(to bottom, #27ae60, #218c4e);
}

#play-animation:hover {
    background: linear-gradient(to bottom, #2ecc71, #27ae60);
}

#stop-animation {
    background: linear-gradient(to bottom, #c0392b, #a33326);
}

#stop-animation:hover {
    background: linear-gradient(to bottom, #e74c3c, #c0392b);
}

/* Keyframe action buttons */
#add-keyframe, #add-at-current-time {
    padding: 0 12px;
    font-size: 12px;
    font-weight: 600;
    height: 38px;
    min-width: 44px;
    letter-spacing: 0.3px;
}

#add-keyframe {
    background-color: #e67e22;
    padding: 0 14px;
    border-radius: 6px;
    position: relative;
}

#add-keyframe:hover {
    background-color: #d35400;
}

#add-keyframe .icon {
    font-weight: bold;
    margin-right: 6px;
    font-size: 16px;
}

#add-at-current-time {
    background-color: #9b722f;
    padding: 0 14px;
    border-radius: 6px;
    position: relative;
}

#add-at-current-time:hover {
    background-color: #7d5b24;
}

#add-at-current-time .icon {
    margin-right: 6px;
    font-size: 14px;
}

.animation-btn .icon {
    font-size: 16px;
    margin-right: 5px;
}

/* Improved keyboard shortcuts */
.animation-shortcuts {
    position: relative;
    width: 100%;
    font-size: 11px;
    color: #666;
    background: linear-gradient(to bottom, rgba(248, 243, 226, 0.9), rgba(233, 224, 204, 0.9));
    padding: 8px 12px;
    border-radius: 8px;
    line-height: 1.6;
    margin-top: 8px;
    text-align: center;
    border: 1px solid rgba(201, 179, 140, 0.5);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.animation-shortcuts strong {
    color: #4a2b0f;
}

.animation-shortcuts kbd {
    display: inline-block;
    padding: 2px 5px;
    font-size: 10px;
    font-family: monospace;
    background-color: #fff;
    border: 1px solid #c9b38c;
    border-radius: 3px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
    margin: 0 2px;
}

/* Enhanced animation notifications */
.animation-message {
    position: absolute;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.95), rgba(240, 240, 240, 0.95));
    color: #333;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    max-width: 350px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    animation: floatIn 0.5s ease-out;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-weight: 500;
}

.animation-message.animation-message-success {
    border-left: 5px solid #2ecc71;
}

.animation-message.animation-message-warning {
    border-left: 5px solid #e67e22;
}

.animation-message.animation-message-error {
    border-left: 5px solid #e74c3c;
}

.animation-message.animation-message-info {
    border-left: 5px solid #3498db;
}

@keyframes floatIn {
    0% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Refined onboarding tooltip */
.animation-onboarding {
    position: absolute;
    background: linear-gradient(145deg, #ffffff, #f8f3e2);
    color: #333;
    padding: 16px 20px;
    border-radius: 10px;
    font-size: 14px;
    max-width: 350px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    animation: fadeInScale 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-left: 6px solid #7a3d99;
}

.animation-onboarding strong {
    display: block;
    font-size: 18px;
    margin-bottom: 8px;
    color: #4a2b0f;
    font-family: 'Cinzel', serif;
}

.animation-onboarding p {
    margin: 8px 0;
    line-height: 1.4;
}

.animation-onboarding ol {
    margin: 12px 0;
    padding-left: 24px;
}

.animation-onboarding ol li {
    margin-bottom: 8px;
    line-height: 1.4;
    position: relative;
    padding-left: 4px;
}

.animation-onboarding button {
    background: linear-gradient(to bottom, #7a3d99, #662d82);
    color: white;
    border: none;
    padding: 8px 16px;
    margin-top: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    display: block;
    width: 100%;
}

.animation-onboarding button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    background: linear-gradient(to bottom, #8a4da9, #7a3d99);
}

@keyframes fadeInScale {
    0% { opacity: 0; transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1); }
}

/* Enhanced responsive layout */
@media (max-width: 800px) {
    .timeline-controls {
        flex-wrap: wrap;
        gap: 12px 15px;
    }
    
    .button-group {
        flex: 1 0 auto;
        justify-content: flex-start;
    }
    
    .animation-time-display {
        top: -35px;
        right: 0;
    }
}

@media (max-width: 600px) {
    .timeline-labels {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .duration-label {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .animation-time-display {
        top: -60px;
        right: 0;
    }
    
    .timeline-controls {
        margin-top: 15px;
    }
    
    .animation-btn {
        flex: 1;
    }
}

/* For very small screens (mobile) */
@media (max-width: 400px) {
    .timeline-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .button-group {
        width: 100%;
    }
    
    #add-keyframe, #add-at-current-time {
        flex: 1;
    }
}