/* Base structure */
.waveform-player {
    font-family: inherit;
    color: inherit;
    line-height: 1.4;
}

.waveform-player * {
    box-sizing: border-box;
}

/* Body container */
.waveform-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Track row */
.waveform-track {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

/* Play button */
.waveform-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    border: 2px solid currentColor;
    background: transparent;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    opacity: 0.9;
    flex-shrink: 0;
}

.waveform-btn:hover:not(:disabled) {
    opacity: 1;
    transform: scale(1.05);
}

.waveform-btn:disabled {
    cursor: not-allowed;
    opacity: 0.3;
}

/* Icons */
.waveform-btn > * {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.waveform-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    display: block;
}

.waveform-icon-play svg {
    margin-left: 1px;
}

/* Waveform container */
.waveform-container {
    flex: 1;
    position: relative;
    min-height: 60px;
    cursor: pointer;
    min-width: 0;
    width: 100%;
}

.waveform-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    transition: opacity 0.3s ease;
    position: relative;
    z-index: 1;
}

/* Info section */
.waveform-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    min-height: 20px;
}

.waveform-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.waveform-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.waveform-subtitle {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.waveform-time {
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* BPM display */
.waveform-bpm {
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Loading state */
.waveform-loading {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.1);
    z-index: 10;
}

/* Error state */
.waveform-error {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.waveform-error-text {
    font-size: 12px;
    opacity: 0.7;
    text-align: center;
    padding: 0 20px;
}

/* Markers container */
.waveform-markers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 5;
}

/* Individual marker */
.waveform-marker {
    position: absolute;
    top: 0;
    width: 2px;
    height: 100%;
    background: rgba(255, 255, 255, 0.5);
    border: none;
    padding: 0;
    cursor: pointer;
    pointer-events: all;
    transition: all 0.2s;
}

.waveform-marker:hover {
    width: 4px;
    z-index: 20;
}

/* Marker tooltip */
.waveform-marker-tooltip {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 1000;
}

.waveform-marker:hover .waveform-marker-tooltip {
    opacity: 1;
}

/* Focus styles for accessibility */
.waveform-btn:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.waveform-marker:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 1px;
    width: 4px;
}

/* Playback speed control */
.waveform-speed {
    position: relative;
    flex-shrink: 0;
}

.speed-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 4px 8px;
    color: inherit;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 40px;
}

.speed-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
}

.speed-value {
    font-weight: 600;
}

.speed-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 4px;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 4px;
    z-index: 100;
    min-width: 60px;
}

.speed-option {
    display: block;
    width: 100%;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    border-radius: 4px;
}

.speed-option:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.speed-option.active {
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
    font-weight: 600;
}

.waveform-player.waveform-focused {
    outline: 2px solid rgba(168, 85, 247, 0.5);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Remove focus outline when clicking, but keep for keyboard navigation */
.waveform-player:focus {
    outline: none;
}

/* Only show focus indicator when keyboard navigating (not clicking) */
.waveform-player:focus-visible {
    outline: 1px solid rgba(168, 85, 247, 0.3);
    outline-offset: 1px;
}

/* Remove the class-based focus indicator since we're using :focus-visible */
.waveform-player.waveform-focused {
    outline: none;
}

/* Button alignment variants */
.waveform-track.waveform-align-top {
    align-items: flex-start;
}

.waveform-track.waveform-align-top .waveform-btn {
    margin-top: 5px;
}

.waveform-track.waveform-align-center {
    align-items: center; /* Default */
}

.waveform-track.waveform-align-bottom {
    align-items: flex-end;
}

.waveform-track.waveform-align-bottom .waveform-btn {
    margin-bottom: 5px;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .waveform-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }

    .waveform-container {
        min-height: 50px;
    }

    .waveform-info {
        font-size: 12px;
    }

    .waveform-subtitle,
    .waveform-time,
    .waveform-bpm {
        font-size: 10px;
    }
}