/* OpenTranscriber v6 - Styles */

:root {
    --primary: #1a202c;
    --accent: #4299e1;
    --accent-hover: #3182ce;
    --bg: #f7fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #2d3748;
    --text-muted: #718096;
    --danger: #e53e3e;
    
    --header-height: 60px;
    
    /* Couleurs locuteurs */
    --spk1: #ef5350;
    --spk2: #66bb6a;
    --spk3: #42a5f5;
    --spk4: #ffee58;
    --spk5: #ab47bc;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 0;
    background: var(--bg);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--text);
}

/* ========== HEADER ========== */
header {
    height: var(--header-height);
    background: var(--surface);
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    flex-shrink: 0;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--primary);
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent), #805ad5);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
}

.title {
    font-weight: 600;
    font-size: 1.1rem;
}

.subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
}

.toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
}

.separator {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
}

/* ========== BUTTONS ========== */
.btn {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    background: var(--surface);
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
    color: var(--text);
}

.btn:hover:not(:disabled) {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

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

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-sm {
    padding: 6px 10px;
    font-size: 0.8rem;
}

.btn-help {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ctrl-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    background: var(--surface);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.ctrl-btn:hover {
    background: #edf2f7;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s;
}

.toggle:hover {
    background: rgba(0,0,0,0.03);
}

/* ========== SPEAKER FILTER ========== */
.speaker-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.filter-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.radio-pill {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.radio-pill input[type="radio"] {
    display: none;
}

.radio-pill span {
    padding: 6px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.15s;
}

.radio-pill:hover span {
    background: #edf2f7;
}

.radio-pill input:checked + span {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Couleurs pour les pills locuteurs */
.radio-pill.spk1 input:checked + span { background: var(--spk1); border-color: var(--spk1); }
.radio-pill.spk2 input:checked + span { background: var(--spk2); border-color: var(--spk2); }
.radio-pill.spk3 input:checked + span { background: var(--spk3); border-color: var(--spk3); }
.radio-pill.spk4 input:checked + span { background: var(--spk4); border-color: var(--spk4); color: #333; }
.radio-pill.spk5 input:checked + span { background: var(--spk5); border-color: var(--spk5); }

#speakerRadioButtons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ========== LOOP TOGGLE ========== */
.toggle-loop {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}

.toggle-loop:hover {
    background: #edf2f7;
}

.toggle-loop input {
    display: none;
}

.toggle-loop input:checked + span {
    color: var(--accent);
    font-weight: 600;
}

.toggle-loop span {
    color: var(--text-muted);
}

/* ========== MAIN ========== */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    gap: 16px;
}

/* ========== MASTER TRACK ========== */
.master-track {
    background: var(--surface);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

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

.track-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--primary);
}

.track-info {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    color: var(--text-muted);
}

#waveformContainer {
    position: relative;
    min-height: 150px;
    background: #fafafa;
    border-radius: 4px;
    margin-bottom: 12px;
}

#waveform {
    position: relative;
    z-index: 1;
}

#spectrogram {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2;
    pointer-events: none;
    opacity: 0.4;
}

#timeline {
    position: relative;
    z-index: 3;
}

.playback-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.control-group select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    font-size: 0.85rem;
    cursor: pointer;
}

.control-group input[type="range"] {
    cursor: pointer;
    accent-color: var(--accent);
    width: 80px;
}

.control-group span {
    font-size: 0.8rem;
    color: var(--text-muted);
    min-width: 45px;
}

/* ========== SPEAKER TRACKS ========== */
#speakersContainer {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.speaker-track {
    background: var(--surface);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border-left: 5px solid;
}

.speaker-track .track-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.speaker-name {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 0.9rem;
    font-weight: 500;
    background: var(--surface);
}

.speaker-name:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-remove {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s;
}

.btn-remove:hover {
    background: #fee;
    border-color: var(--danger);
}

.waveform-container {
    min-height: 60px;
    background: #fafafa;
    border-radius: 4px;
}

.btn-add-speaker {
    width: 100%;
    padding: 12px;
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.15s;
}

.btn-add-speaker:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(66, 153, 225, 0.05);
}

/* ========== EDITION PANEL ========== */
.edition-panel {
    background: var(--surface);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 2px solid var(--accent);
}

.edition-panel.hidden {
    display: none;
}

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

.edition-header strong {
    color: var(--primary);
}

.btn-close {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-muted);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    color: var(--danger);
}

.edition-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-row {
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 8px;
    background: var(--bg);
    border-radius: 4px;
}

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

.form-row label {
    font-size: 0.85rem;
    font-weight: 500;
    min-width: 100px;
}

.form-row select,
.form-row input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
}

.form-row input[type="text"]:focus,
.form-row select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

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

.action-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* ========== MODALS ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--primary);
}

.modal-header .close-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-muted);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-header .close-btn:hover {
    color: var(--danger);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.form-group select,
.form-group input[type="range"] {
    width: 100%;
}

.form-group input[type="range"] {
    margin-top: 4px;
}

.export-stats {
    background: var(--bg);
    padding: 16px;
    border-radius: 4px;
    margin-top: 16px;
}

.export-stats ul {
    margin: 8px 0 0 20px;
    padding: 0;
}

.export-stats li {
    margin-bottom: 4px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ========== HELP OVERLAY ========== */
.help-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.help-content {
    background: var(--surface);
    border-radius: 8px;
    padding: 32px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.help-content h2 {
    margin: 0 0 24px 0;
    color: var(--primary);
}

.btn-close-help {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-muted);
}

.btn-close-help:hover {
    color: var(--danger);
}

.help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
}

.help-section h3 {
    margin: 0 0 12px 0;
    font-size: 1rem;
    color: var(--primary);
}

.help-section kbd {
    display: inline-block;
    padding: 3px 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    font-size: 0.85rem;
    font-family: monospace;
    margin-right: 4px;
}

/* ========== TOAST ========== */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--primary);
    color: white;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-size: 0.9rem;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
    z-index: 3000;
    pointer-events: none;
}

.toast-show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: #48bb78;
}

.toast-info {
    background: var(--accent);
}

.toast-danger {
    background: var(--danger);
}

/* ========== HIGHLIGHT ========== */
.segment-highlighted {
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.7) !important;
    z-index: 100 !important;
}

/* ========== REGION STYLES ========== */
.wavesurfer-region {
    cursor: pointer !important;
}

.wavesurfer-region:hover {
    filter: brightness(1.1);
}

/* ========== DRAG SELECTION ========== */
.wavesurfer-region.wavesurfer-drag-selection {
    background: rgba(66, 153, 225, 0.3) !important;
    border: 2px dashed var(--accent) !important;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .toolbar {
        flex-wrap: wrap;
    }
    
    .playback-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .help-grid {
        grid-template-columns: 1fr;
    }
    
    .speaker-filter {
        flex-direction: column;
        align-items: flex-start;
    }
}
