/* === Coffre-Vocal — Theme & Variables === */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #0e1628;
    --accent: #e94560;
    --accent-hover: #ff6b81;
    --text-primary: #e0e0e0;
    --text-secondary: #8892a4;
    --text-muted: #555e6e;
    --border: #2a2d3e;
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #3498db;
    --radius: 8px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --transition: 0.2s ease;
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === Header === */
header {
    background: var(--bg-secondary);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
header h1 { font-size: 1.5rem; color: var(--accent); }
.subtitle { color: var(--text-secondary); font-size: 0.85rem; margin-left: 0.5rem; }
.header-left { display: flex; align-items: baseline; gap: 0.5rem; }

/* === Status Badge === */
.status-badge {
    font-size: 0.8rem;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-weight: 600;
}
.status-online { background: rgba(46, 204, 113, 0.15); color: var(--success); }
.status-offline { background: rgba(231, 76, 60, 0.15); color: var(--danger); }

/* === Tabs === */
.tabs {
    background: var(--bg-secondary);
    display: flex;
    padding: 0 2rem;
    gap: 0;
    border-bottom: 2px solid var(--border);
}
.tab {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.8rem 1.5rem;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* === Main === */
main {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* === Tab Content === */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* === Card === */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.card h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* === Buttons === */
.btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

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

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

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.3rem;
}
.btn-icon:hover { color: var(--text-primary); }

/* === Mic Controls === */
.mic-controls { margin-bottom: 1rem; }

.mic-channel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
}
.mic-channel-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    grid-column: 1 / -1;
}
.mic-channel-header select {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
    flex: 1;
}
.mic-channel-body { grid-column: 1 / -1; }

/* VU Meter */
.vu-meter {
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
    margin: 0.5rem 0;
}
.vu-meter-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, var(--success), var(--warning), var(--danger));
    transition: width 0.1s ease;
    border-radius: 4px;
}

/* Record Button */
.btn-record {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    border: 3px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.btn-record:hover { transform: scale(1.05); }
.btn-record.recording {
    animation: pulse 1.5s infinite;
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.5);
}
.btn-record .dot {
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
}
.btn-record.recording .dot {
    border-radius: 3px;
    width: 14px;
    height: 14px;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 5px rgba(233, 69, 96, 0.3); }
    50% { box-shadow: 0 0 25px rgba(233, 69, 96, 0.6); }
}

/* === Drop Zone === */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.05);
}
.drop-zone p { margin: 0.5rem 0; }
.drop-zone .small { font-size: 0.8rem; color: var(--text-muted); }

/* Upload Item */
.upload-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.upload-item-info { flex: 1; }
.upload-item-name { font-weight: 600; }
.upload-item-size { font-size: 0.8rem; color: var(--text-secondary); }

/* Progress Bar */
.progress-bar {
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.5rem;
}
.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 0.3s ease;
}

/* === Table === */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}
th, td {
    padding: 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
th {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
tr:hover td { background: rgba(233, 69, 96, 0.03); }

/* Status Badges */
.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-queued { background: rgba(149, 165, 166, 0.2); color: #95a5a6; }
.badge-running { background: rgba(52, 152, 219, 0.2); color: var(--info); }
.badge-done { background: rgba(46, 204, 113, 0.2); color: var(--success); }
.badge-failed { background: rgba(231, 76, 60, 0.2); color: var(--danger); }

/* === Pagination === */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}
#page-info { color: var(--text-secondary); font-size: 0.85rem; }

/* === Transcript === */
.transcript {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 1rem;
}
.segment {
    padding: 0.5rem 0.8rem;
    border-left: 3px solid var(--accent);
    margin-bottom: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.segment-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}
.segment-speaker {
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
    padding: 0.1rem 0.5rem;
    border-radius: 12px;
}
.segment-text { margin-top: 0.3rem; line-height: 1.5; cursor: text; }
.segment.partial { opacity: 0.6; border-left-color: var(--warning); }
.segment.verified { border-left-color: var(--success); }
.segment.playing { box-shadow: inset 0 0 0 1px var(--accent); }
.segment-header { display: flex; align-items: center; gap: 0.6rem; }
.segment-verify {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    white-space: nowrap;
}
.segment-edit-textarea {
    width: 100%;
    min-height: 3rem;
    margin-top: 0.3rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font: inherit;
    line-height: 1.5;
    padding: 0.4rem;
    resize: vertical;
}
.verify-progress {
    margin: 0.5rem 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
#modal-audio { width: 100%; margin: 0.5rem 0; }

/* Live transcript container */
.live-transcript {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-input);
    border-radius: var(--radius);
    min-height: 60px;
}

/* === Modal === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal[hidden] { display: none; }
.modal-backdrop {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
}
.modal-content {
    position: relative;
    z-index: 1;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-content.modal-wide { max-width: 900px; }
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.modal-footer {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
}
.export-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* === Toast === */
#toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast {
    padding: 0.8rem 1.2rem;
    border-radius: var(--radius);
    color: white;
    font-size: 0.85rem;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease;
    max-width: 350px;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* === Footer === */
footer {
    text-align: center;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    border-top: 1px solid var(--border);
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === Responsive === */
@media (max-width: 768px) {
    header { flex-direction: column; gap: 0.5rem; }
    main { padding: 1rem; }
    .tabs { padding: 0 1rem; overflow-x: auto; }
    .tab { padding: 0.6rem 1rem; font-size: 0.85rem; white-space: nowrap; }
    .mic-channel { grid-template-columns: 1fr; }
    .modal-content { width: 95%; }
}
