/* ============================================
   VoiceForge v2.0 — Dark theme
   ============================================ */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #111118;
    --bg-card: #16161f;
    --bg-hover: #1e1e2a;
    --bg-input: #1a1a25;
    --border: #2a2a3a;
    --border-focus: #7c3aed;
    --text-primary: #f0f0f5;
    --text-secondary: #8888a0;
    --text-muted: #55556a;
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-glow: rgba(124, 58, 237, 0.15);
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --radius: 10px;
    --radius-sm: 6px;
    --sidebar-width: 240px;
    --transition: 0.15s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

.hidden { display: none !important; }

/* ============ Login ============ */

.login-screen { display: flex; align-items: center; justify-content: center; height: 100vh; background: var(--bg-primary); }
.login-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 48px 40px; width: 400px; text-align: center; }
.login-logo { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 8px; }
.login-logo h1 { font-size: 24px; font-weight: 700; }
.login-subtitle { color: var(--text-secondary); margin-bottom: 32px; font-size: 14px; }

#login-form input { width: 100%; padding: 12px 16px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 14px; font-family: inherit; outline: none; margin-bottom: 16px; transition: border var(--transition); }
#login-form input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow); }
#login-form button { width: 100%; padding: 12px; background: var(--accent); color: white; border: none; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer; transition: background var(--transition); }
#login-form button:hover { background: var(--accent-hover); }
.login-error { color: var(--error); font-size: 13px; margin-top: 12px; min-height: 20px; }

/* ============ App Layout ============ */

.app { display: flex; height: 100vh; }

/* ============ Sidebar ============ */

.sidebar { width: var(--sidebar-width); background: var(--bg-secondary); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { display: flex; align-items: center; gap: 10px; padding: 20px 20px 28px; border-bottom: 1px solid var(--border); }
.sidebar-title { font-size: 17px; font-weight: 700; }
.sidebar-nav { padding: 12px 10px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: var(--text-secondary); text-decoration: none; font-size: 14px; font-weight: 500; border-radius: var(--radius-sm); transition: all var(--transition); margin-bottom: 2px; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); }
.sidebar-footer { padding: 12px 10px; border-top: 1px solid var(--border); }
.logout-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 14px; background: none; border: none; color: var(--text-secondary); font-size: 13px; font-family: inherit; cursor: pointer; border-radius: var(--radius-sm); transition: all var(--transition); }
.logout-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ============ Main Content ============ */

.main-content { flex: 1; overflow-y: auto; padding: 32px 40px; }
.page { display: none; }
.page.active { display: block; }
.page-header { margin-bottom: 28px; }
.page-header h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.page-header p { color: var(--text-secondary); font-size: 14px; }
.page-header-row { display: flex; justify-content: space-between; align-items: flex-start; }

/* ============ Buttons ============ */

.btn-primary { display: inline-flex; align-items: center; gap: 8px; padding: 11px 24px; background: var(--accent); color: white; border: none; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer; transition: all var(--transition); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary { display: inline-flex; align-items: center; gap: 6px; padding: 11px 20px; background: var(--bg-card); color: var(--text-secondary); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; font-family: inherit; cursor: pointer; text-decoration: none; transition: all var(--transition); }
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-small { padding: 8px 14px; font-size: 13px; }

.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; transition: all var(--transition); flex-shrink: 0; }
.btn-icon:hover { background: var(--accent); border-color: var(--accent); color: white; }

/* ============ Form Controls ============ */

select, .search-input, .filter-input, .filter-select {
    width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 14px; font-family: inherit; outline: none; transition: border var(--transition);
}
select { appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%238888a0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
select:focus, .search-input:focus, .filter-input:focus, .filter-select:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow); }

textarea { width: 100%; padding: 16px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-primary); font-size: 14px; font-family: inherit; line-height: 1.6; outline: none; resize: vertical; min-height: 200px; transition: border var(--transition); }
textarea:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow); }
textarea::placeholder { color: var(--text-muted); }

/* ============ TTS Page ============ */

.tts-container { max-width: 800px; }
.tts-controls { display: flex; gap: 16px; margin-bottom: 16px; }
.control-group { flex: 1; }
.control-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.textarea-wrapper { position: relative; margin-bottom: 16px; }
.char-count { position: absolute; bottom: 12px; right: 14px; font-size: 12px; color: var(--text-muted); }
.tts-actions { display: flex; gap: 10px; }

/* Sliders */
.slider-group { min-width: 0; }
.slider-value { color: var(--accent); font-weight: 700; }
input[type="range"] { -webkit-appearance: none; width: 100%; height: 6px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 3px; outline: none; margin-top: 4px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; background: var(--accent); border-radius: 50%; cursor: pointer; border: 2px solid var(--bg-primary); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; background: var(--accent); border-radius: 50%; cursor: pointer; border: 2px solid var(--bg-primary); }
.slider-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-muted); margin-top: 4px; }

/* Generation Status */
.generation-status { margin-top: 20px; }
.status-card { display: flex; align-items: center; gap: 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.status-icon { flex-shrink: 0; }
.spinner { width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-text p { font-size: 14px; font-weight: 500; }
.status-detail { color: var(--text-secondary) !important; font-size: 13px !important; font-weight: 400 !important; margin-top: 4px; }

/* Audio Player */
.audio-player { margin-top: 20px; }
.player-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.player-info { display: flex; justify-content: space-between; margin-bottom: 12px; }
.player-voice { font-size: 14px; font-weight: 600; }
.player-duration { font-size: 13px; color: var(--text-secondary); }
audio { width: 100%; height: 40px; margin-bottom: 12px; border-radius: var(--radius-sm); outline: none; }
audio::-webkit-media-controls-panel { background: var(--bg-input); }
.player-actions { display: flex; gap: 8px; }

/* ============ Voices Page ============ */

.voices-toolbar { display: flex; gap: 12px; margin-bottom: 24px; }
.search-input { max-width: 300px; }

.voices-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }

.voice-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; transition: all var(--transition); }
.voice-card:hover { border-color: var(--accent); background: var(--bg-hover); }
.voice-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.voice-card-info { min-width: 0; flex: 1; }
.voice-card-meta-inline { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.voice-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-glow); border: 1px solid var(--accent); display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; color: var(--accent); flex-shrink: 0; }
.voice-card-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voice-card-settings { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.voice-tag { font-size: 11px; padding: 3px 8px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 20px; color: var(--text-secondary); }
.voice-card-actions { display: flex; gap: 8px; align-items: center; }

/* ============ Tables (Channels + History) ============ */

.table-container { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 12px 16px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); border-bottom: 1px solid var(--border); background: var(--bg-secondary); }
.data-table td { padding: 14px 16px; font-size: 13px; border-bottom: 1px solid var(--border); color: var(--text-secondary); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }
.actions-cell { white-space: nowrap; display: flex; gap: 6px; }

.history-text { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }

.status-badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.status-badge.success { background: rgba(34, 197, 94, 0.1); color: var(--success); }
.status-badge.failed, .status-badge.error { background: rgba(239, 68, 68, 0.1); color: var(--error); }
.status-badge.processing { background: rgba(245, 158, 11, 0.1); color: var(--warning); }

.source-badge { display: inline-flex; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.source-badge.ui { background: rgba(124, 58, 237, 0.1); color: var(--accent); }
.source-badge.trello { background: rgba(34, 197, 94, 0.1); color: var(--success); }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); font-size: 14px; }

/* Filter toolbar */
.filter-toolbar { display: flex; gap: 12px; margin-bottom: 20px; }
.filter-select, .filter-input { width: auto; min-width: 140px; }
.filter-input { max-width: 200px; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 20px; }
.page-info { font-size: 13px; color: var(--text-secondary); }

/* ============ Modal ============ */

.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; width: 520px; max-width: 90vw; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-secondary); font-size: 24px; cursor: pointer; padding: 4px; line-height: 1; }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 24px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

/* Modal Form */
.modal-form { }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-group input[type="text"], .form-group select { width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 14px; font-family: inherit; outline: none; }
.form-group input[type="text"]:focus, .form-group select:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Upload Zone */
.upload-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 32px; text-align: center; cursor: pointer; transition: all var(--transition); position: relative; }
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--accent); background: var(--accent-glow); }
.upload-zone svg { color: var(--text-muted); margin-bottom: 8px; }
.upload-zone p { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.upload-link { color: var(--accent); cursor: pointer; }
.upload-hint { font-size: 12px !important; color: var(--text-muted) !important; margin-top: 8px !important; }
.upload-input { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.upload-filename { font-size: 13px; color: var(--accent); margin-top: 8px; }

/* ============ Toast ============ */

.toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; transform: translateX(100%); opacity: 0; transition: all 0.3s ease; }
.toast.show { transform: translateX(0); opacity: 1; }
.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--error); color: white; }

/* ============ Responsive ============ */

@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-title, .nav-item span { display: none; }
    .nav-item { justify-content: center; padding: 12px; }
    .main-content { padding: 20px; }
    .tts-controls { flex-direction: column; }
    .voices-grid { grid-template-columns: 1fr; }
    .filter-toolbar { flex-direction: column; }
    .form-row { flex-direction: column; }
    .page-header-row { flex-direction: column; gap: 12px; }
}
