/**
 * Audio Trimmer - Tool Specific Styles
 * Base styles come from /src/styles/layouts/tool-layout.css
 */

/* ==================== WAVEFORM SECTION ==================== */
.waveform-section {
    margin-bottom: var(--space-4);
}

.waveform-container {
    position: relative;
    height: 120px;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.waveform-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#selectionCanvas {
    z-index: 10;
    pointer-events: auto;
}

#waveformCanvas {
    z-index: 5;
}

/* Playhead */
.waveform-playhead {
    position: absolute;
    top: 0;
    left: 0;
    width: 2px;
    height: 100%;
    background: #ef4444;
    z-index: 15;
    pointer-events: auto;
    transform: translateX(-1px);
    cursor: ew-resize;
    /* GPU acceleration for smooth animation */
    will-change: left;
    contain: layout style;
}

/* Increase playhead hit area for easier grabbing */
.waveform-playhead::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 18px;
    height: 100%;
    cursor: ew-resize;
}

/* Playhead visual feedback when dragging */
.waveform-playhead.dragging {
    background: #f97316;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

/* Playhead grab indicators (top and bottom) */
.waveform-playhead::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 10px;
    background: #ef4444;
    border-radius: 50%;
    top: -5px;
}

.waveform-playhead.dragging::after {
    background: #f97316;
    box-shadow: 0 0 6px rgba(249, 115, 22, 0.6);
}

/* Waveform Row - Play button + Waveform side by side */
.waveform-row {
    display: flex;
    gap: var(--space-3);
    align-items: stretch;
}

/* Play Button (separate from waveform) */
.play-button {
    flex-shrink: 0;
    width: 80px;
    height: 120px;
    border-radius: var(--radius-md);
    background: var(--color-bg-tertiary);
    border: 2px solid var(--color-border);
    color: var(--color-text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.play-button:hover {
    background: var(--color-bg-elevated);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.play-button:active {
    transform: scale(0.95);
}

.play-button svg {
    margin-left: 3px; /* Optical centering for play icon */
}

.play-button .hidden {
    display: none;
}

/* Waveform container takes remaining space */
.waveform-row .waveform-container {
    flex: 1;
}

/* Time Bar below waveform */
.waveform-time-bar {
    display: flex;
    justify-content: space-between;
    padding: var(--space-2) var(--space-1);
}

/* Color Legend */
.waveform-legend {
    display: flex;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-2) 0;
    font-size: var(--text-xs);
}

.waveform-legend__item {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.waveform-legend__color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.waveform-legend__color--start {
    background: #22c55e; /* Green - matches RangeSelector start handle */
}

.waveform-legend__color--end {
    background: #3b82f6; /* Blue - matches RangeSelector end handle */
}

.waveform-legend__color--playhead {
    background: #ef4444; /* Red - matches playhead */
}

.waveform-legend__label {
    color: var(--color-text-secondary);
}

/* ==================== RANGE INFO SECTION ==================== */
.range-info {
    display: flex;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
}

.range-input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.range-input-group label {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    font-weight: var(--font-medium);
}

.time-input {
    width: 100px;
    padding: var(--space-2);
    font-size: var(--text-sm);
    font-family: var(--font-mono);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-primary);
    text-align: center;
    cursor: ew-resize;
    user-select: none;
    -webkit-user-select: none;
}

.time-input:focus {
    outline: none;
    border-color: var(--color-accent);
    cursor: text;
}

.time-input.dragging {
    background: var(--color-accent-bg);
    border-color: var(--color-accent);
}

.duration-display {
    font-size: var(--text-sm);
    font-family: var(--font-mono);
    color: var(--color-text-primary);
    padding: var(--space-2);
    background: var(--color-bg-elevated);
    border-radius: var(--radius-sm);
    min-width: 100px;
    text-align: center;
}

/* ==================== FADE OPTIONS ==================== */
.fade-options {
    display: flex;
    gap: var(--space-6);
    margin-bottom: var(--space-4);
}

.fade-group {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.fade-group label {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    min-width: 60px;
}

.fade-group .input {
    width: 70px;
    padding: var(--space-2);
    font-size: var(--text-sm);
    text-align: center;
}

.fade-unit {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

/* ==================== ACTION BUTTONS ==================== */
.action-buttons {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.action-buttons .btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.action-buttons .btn svg {
    flex-shrink: 0;
}

/* Preview Button Active State */
.btn--secondary.active {
    background: var(--color-success);
    border-color: var(--color-success);
    color: white;
}

/* ==================== FILE INFO ==================== */
.file-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3);
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
}

.file-name {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 70%;
}

.file-duration {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    font-family: var(--font-mono);
}

.time-display {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    font-family: var(--font-mono);
    min-width: 45px;
}

/* ==================== RESET CONTAINER ==================== */
.reset-container {
    display: flex;
    justify-content: center;
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
}

/* ==================== FORM ELEMENTS ==================== */
.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text-primary);
    margin-bottom: var(--space-2);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 640px) {
    .range-info {
        flex-direction: column;
        gap: var(--space-3);
    }

    .range-input-group {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .time-input,
    .duration-display {
        width: auto;
        flex: 1;
        max-width: 120px;
    }

    .fade-options {
        flex-direction: column;
        gap: var(--space-3);
    }

    .fade-group {
        justify-content: space-between;
    }

    .action-buttons {
        flex-direction: column;
    }

    .player-controls {
        flex-wrap: wrap;
    }

    .waveform-row {
        gap: var(--space-2);
    }

    .play-button {
        width: 60px;
    }
}
