/* ===== RESET & BASE ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #eef1f5; color: #1e293b; min-height: 100vh;
}

/* ===== APP LAYOUT ===== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    box-shadow: 2px 0 8px rgba(0,0,0,0.04);
}

.sidebar-header {
    padding: 18px 16px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-header .logo-icon {
    width: 40px;
    height: 40px;
    background: rgb(139, 92, 246);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2em;
    font-weight: 700;
}
.sidebar-header h1 {
    font-size: 1.25em;
    font-weight: 800;
    color: #1e293b;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 13px 16px;
    background: transparent;
    color: #475569;
    border: none;
    border-radius: 10px;
    font-size: 0.95em;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
}
.nav-btn .nav-icon {
    font-size: 1.2em;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}
.nav-btn:hover {
    background: #f1f5f9;
    color: #1e293b;
}
.nav-btn.active {
    background: rgb(139, 92, 246);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid #e2e8f0;
}

.credit-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px;
    text-align: center;
}
.credit-title {
    font-size: 0.8em;
    font-weight: 700;
    color: #94a3b8;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    text-transform: uppercase;
}
.credit-info {
    font-size: 0.9em;
    color: #475569;
}
.credit-info strong {
    color: #16a34a;
    font-size: 1.1em;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 30px 40px;
    min-height: 100vh;
    background: #eef1f5;
}

/* ===== PAGES ===== */
.page { display: none; }
.page.active { display: block; }
.page > h2 {
    font-size: 1.5em;
    color: #1e293b;
    margin-bottom: 4px;
    font-weight: 800;
}
.page-desc {
    color: #64748b;
    margin-bottom: 24px;
    font-size: 0.93em;
}

/* ===== COMING SOON ===== */
.coming-soon {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    background: #ffffff;
    border-radius: 12px;
    border: 2px dashed #cbd5e1;
}
.coming-soon p {
    font-size: 1.1em;
    color: #94a3b8;
    font-weight: 500;
}

/* ===== SECTIONS ===== */
.queue-section { background: #ffffff; border-radius: 12px; padding: 24px; margin-top: 24px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.queue-section h2 { font-size: 1.1em; margin-bottom: 20px; color: #1e293b; font-weight: 700; }
h3 { font-size: 1em; margin-bottom: 14px; color: #3b82f6; border-bottom: 1px solid #e2e8f0; padding-bottom: 8px; font-weight: 700; }
h4 { font-size: 0.93em; margin: 16px 0 8px; color: #475569; font-weight: 600; }

/* ===== FORM ===== */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; color: #475569; font-size: 0.88em; }

/* ===== INPUTS ===== */
.input-field {
    width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid #d1d5db;
    background: #ffffff; color: #1e293b; font-size: 0.93em; transition: border-color 0.2s;
}
.input-field:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }
.input-small {
    width: 70px; padding: 6px 8px; border-radius: 6px; border: 1px solid #d1d5db;
    background: #ffffff; color: #1e293b; font-size: 0.88em; text-align: center;
}
.input-char {
    width: 50px; padding: 6px 8px; border-radius: 6px; border: 1px solid #d1d5db;
    background: #ffffff; color: #1e293b; font-size: 0.88em; text-align: center;
}

/* ===== TOOL LIST ===== */
.tool-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; max-width: 600px; }
.tool-card {
    background: #ffffff; border: 2px solid #e2e8f0; border-radius: 10px;
    padding: 16px; text-align: center; cursor: pointer; transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.tool-card:hover { border-color: #3b82f6; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(59,130,246,0.12); }
.tool-card.selected { border-color: #3b82f6; background: #eff6ff; }
.tool-card h3 { font-size: 1.3em; font-weight: 800; margin-bottom: 4px; border: none; padding: 0; color: #1e293b; }
.tool-card p { font-size: 0.83em; color: #64748b; }

/* ===== SELECT ===== */
select {
    width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid #d1d5db;
    background: #ffffff; color: #1e293b; font-size: 0.93em;
}
select:focus { outline: none; border-color: #3b82f6; }

/* ===== VOICE SELECT ROW ===== */
.voice-select-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.voice-select-row select { flex: 1; }
.btn-delete-voice {
    padding: 10px 20px;
    background: #ef4444;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
.btn-delete-voice:hover { background: #dc2626; }

/* ===== CLONE ACTIONS ===== */
.clone-actions {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.terms-check {
    font-size: 0.85em !important;
}
.terms-link {
    color: #3b82f6;
    text-decoration: underline;
}
.terms-link:hover { color: #2563eb; }
.btn-create-clone {
    padding: 10px 28px;
    background: #3b82f6;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
.btn-create-clone:hover { background: #2563eb; }
.btn-create-clone:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== TWO PANEL ROW ===== */
.two-panel-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
.two-panel-row.single-panel {
    grid-template-columns: 1fr;
}
.panel-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    align-self: start;
}
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    padding: 2px 0;
}
.panel-header h3 {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}
.panel-arrow {
    font-size: 0.85em;
    color: #94a3b8;
    transition: transform 0.2s;
}
.panel-header:hover .panel-arrow { color: #3b82f6; }
.panel-body {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

/* ===== CLONE FOOTER ===== */
.clone-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #e2e8f0;
    flex-wrap: wrap;
}

/* ===== SETTINGS 2-COL ===== */
.settings-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* ===== SAMPLE INLINE ===== */
.sample-drop-inline {
    border: 2px dashed #cbd5e1; border-radius: 8px; padding: 12px 14px; text-align: center;
    cursor: pointer; transition: all 0.2s; background: #f8fafc; font-size: 0.86em; color: #64748b;
}
.sample-drop-inline:hover { border-color: #8b5cf6; background: #faf5ff; }
.file-info-inline {
    display: flex; align-items: center; gap: 8px; background: #f1f5f9;
    padding: 8px 12px; border-radius: 8px; border: 1px solid #e2e8f0; font-size: 0.83em; margin-top: 6px;
}
.file-info-inline span { flex: 1; color: #1e293b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== VOICES TABLE ===== */
.my-voices { margin-top: 16px; }
.voices-table { width: 100%; border-collapse: collapse; font-size: 0.85em; }
.voices-table th { background: #f1f5f9; padding: 8px 12px; text-align: left; color: #64748b; font-weight: 600; }
.voices-table td { padding: 8px 12px; border-bottom: 1px solid #e2e8f0; }

/* ===== VOICE SETTINGS ===== */
.range-group { display: flex; align-items: center; gap: 12px; }
.range-group input[type="range"] {
    flex: 1; height: 6px; -webkit-appearance: none; appearance: none;
    background: #d1d5db; border-radius: 3px; outline: none;
}
.range-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #3b82f6; cursor: pointer;
}
.checkbox-group { display: flex; gap: 20px; flex-wrap: wrap; }
.checkbox-label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 0.88em; color: #475569; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: #3b82f6; }

/* ===== ADVANCE SETTINGS ===== */
.advance-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.advance-row label:not(.checkbox-label) { min-width: 180px; font-size: 0.88em; color: #475569; font-weight: 600; }
.inline-inputs { display: flex; align-items: center; gap: 8px; }
.inline-inputs span { font-size: 0.83em; color: #64748b; }
.hint { color: #ef4444 !important; font-style: italic; }
.advance-title { font-size: 0.9em; font-weight: 700; color: #3b82f6; margin-bottom: 14px; }
.divider { border: none; border-top: 1px solid #e2e8f0; margin: 16px 0; }
.char-pause-settings { padding-left: 24px; margin-bottom: 12px; }
.char-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.char-row label { font-size: 0.88em; color: #64748b; min-width: 50px; }

/* ===== FILE INFO ===== */
.file-info {
    display: flex; align-items: center; gap: 12px; background: #f1f5f9;
    padding: 10px 16px; border-radius: 8px; margin-top: 8px; border: 1px solid #e2e8f0;
}
.file-info span { flex: 1; font-size: 0.88em; color: #1e293b; }
.btn-remove { background: #ef4444; color: white; border: none; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; font-weight: bold; font-size: 0.8em; }

/* ===== BATCH JOB BOX ===== */
.batch-job-box { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.batch-job-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.batch-job-row label { min-width: 70px; font-size: 0.88em; color: #475569; flex-shrink: 0; font-weight: 600; }
.folder-input { flex: 1; cursor: pointer; }
.btn-browse {
    padding: 10px 16px; background: #475569; color: #ffffff; border: none;
    border-radius: 8px; cursor: pointer; font-size: 1em; font-weight: 700;
}
.btn-browse:hover { background: #334155; }
.batch-job-center { display: flex; align-items: center; justify-content: center; gap: 24px; margin-bottom: 16px; }
.btn-batch {
    padding: 10px 28px; background: transparent; color: #22c55e; border: 2px solid #22c55e;
    border-radius: 8px; font-size: 0.95em; font-weight: 700; cursor: pointer;
}
.btn-batch:hover { background: #22c55e; color: white; }
.btn-batch:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== IMPORT BUTTONS ===== */
.import-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.btn-import {
    padding: 9px 16px; background: transparent; color: #475569; border: 1px solid #cbd5e1;
    border-radius: 6px; font-size: 0.86em; cursor: pointer; transition: all 0.15s; font-weight: 600;
}
.btn-import:hover { background: #f1f5f9; }
.btn-import-file { color: #3b82f6; border-color: #3b82f6; }
.btn-import-file:hover { background: #3b82f6; color: white; }
.btn-srt-action { color: #f59e0b; border-color: #f59e0b; }
.btn-srt-action:hover { background: #f59e0b; color: white; }
.btn-join-action { color: #8b5cf6; border-color: #8b5cf6; }
.btn-join-action:hover { background: #8b5cf6; color: white; }

/* ===== START / STOP ===== */
.start-stop-row { display: flex; gap: 12px; margin-bottom: 14px; }
.btn-start {
    flex: 1; padding: 14px; border: none; border-radius: 8px; background: #22c55e;
    color: #ffffff; font-size: 1.05em; font-weight: 700; cursor: pointer;
}
.btn-start:hover { background: #16a34a; }
.btn-start:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-stop {
    flex: 1; padding: 14px; border: none; border-radius: 8px; background: #7f1d1d;
    color: #ffffff; font-size: 1.05em; font-weight: 700; cursor: pointer;
}
.btn-stop:hover { background: #991b1b; }
.btn-stop:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== FILE TABLE ===== */
.file-table-container { border: 1px solid #e2e8f0; border-radius: 10px; overflow: hidden; max-height: 350px; overflow-y: auto; }
.file-table { width: 100%; border-collapse: collapse; font-size: 0.85em; }
.file-table thead { position: sticky; top: 0; z-index: 1; }
.file-table th { background: #f1f5f9; padding: 10px 12px; text-align: left; color: #475569; font-weight: 600; }
.file-table td { padding: 8px 12px; border-bottom: 1px solid #e2e8f0; color: #1e293b; }
.file-table tr:hover { background: #f8fafc; }
.file-table tr.row-running { background: #eff6ff; }
.col-id { width: 50px; text-align: center; }
.col-status { width: 120px; text-align: center; }
.status-badge { display: inline-block; padding: 2px 10px; border-radius: 4px; font-size: 0.8em; font-weight: 600; }
.status-waiting { background: #f1f5f9; color: #64748b; }
.status-running { background: #eff6ff; color: #3b82f6; animation: pulse 1s infinite; }
.status-done { background: #f0fdf4; color: #16a34a; }
.status-error { background: #fef2f2; color: #dc2626; }

/* ===== STATUS BAR ===== */
.status-bar { background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px 16px; margin-bottom: 16px; font-size: 0.85em; color: #64748b; }
.status-bar strong { color: #1e293b; }

/* ===== QUEUE ===== */
.queue-list { display: flex; flex-direction: column; gap: 12px; }
.queue-item { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 16px; display: flex; align-items: center; gap: 16px; }
.queue-item .status { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.queue-item .status.pending { background: #f59e0b; }
.queue-item .status.processing { background: #3b82f6; animation: pulse 1s infinite; }
.queue-item .status.done { background: #22c55e; }
.queue-item .status.error { background: #ef4444; }
.queue-item .info { flex: 1; }
.queue-item .info h4 { font-size: 0.88em; margin-bottom: 4px; color: #1e293b; font-weight: 600; }
.queue-item .info p { font-size: 0.8em; color: #64748b; }
.empty { text-align: center; color: #94a3b8; padding: 20px; font-size: 0.93em; }
.btn-download {
    display: inline-block; padding: 6px 16px; background: #22c55e; color: #ffffff;
    border: none; border-radius: 6px; text-decoration: none; font-size: 0.85em; cursor: pointer; margin: 2px; font-weight: 600;
}
.btn-download:hover { background: #16a34a; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.file-table-container::-webkit-scrollbar { width: 6px; }
.file-table-container::-webkit-scrollbar-track { background: #f8fafc; }
.file-table-container::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ===== TOGGLE ADVANCE BUTTON ===== */
.btn-toggle-advance {
    width: 100%;
    padding: 10px 16px;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}
.btn-toggle-advance:hover {
    background: #e2e8f0;
    color: #1e293b;
}
.btn-toggle-advance .advance-arrow {
    font-size: 0.8em;
    transition: transform 0.3s;
}
.btn-toggle-advance.open .advance-arrow {
    transform: rotate(180deg);
}
.advance-content {
    margin-top: 16px;
    padding-top: 12px;
    animation: slideDown 0.3s ease;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== OK BUTTON ===== */
.settings-ok-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}
.btn-settings-ok {
    padding: 10px 40px;
    background: #3b82f6;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-settings-ok:hover {
    background: #2563eb;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* ===== CMD SETTINGS (ElevenLabs style) ===== */
.cmd-fieldset {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 14px 16px;
    background: #f8fafc;
}
.cmd-fieldset legend {
    font-weight: 700;
    color: #1e293b;
    font-size: 0.93em;
    padding: 0 6px;
}
.cmd-voice-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.cmd-voice-row label {
    min-width: 55px;
    font-size: 0.88em;
    font-weight: 600;
    color: #475569;
}
.cmd-name-input {
    flex: 1;
    max-width: 200px;
}
.btn-cmd-search {
    padding: 8px 18px;
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.88em;
    font-weight: 600;
    cursor: pointer;
}
.btn-cmd-search:hover { background: #f1f5f9; }
.cmd-voice-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}
.btn-add-library {
    padding: 8px 18px;
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.88em;
    font-weight: 600;
    cursor: pointer;
}
.btn-add-library:hover { background: #f1f5f9; }
.btn-library-vip {
    padding: 8px 18px;
    background: #ffffff;
    color: #8b5cf6;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.88em;
    font-weight: 700;
    cursor: pointer;
}
.btn-library-vip:hover { background: #faf5ff; }
.cmd-settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 24px;
    margin-top: 8px;
}
.cmd-setting-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.cmd-setting-item > label:not(.checkbox-label) {
    min-width: 70px;
    font-size: 0.88em;
    font-weight: 600;
    color: #475569;
}
.btn-cmd-reset {
    padding: 6px 20px;
    background: #ffffff;
    color: #475569;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.88em;
    font-weight: 600;
    cursor: pointer;
}
.btn-cmd-reset:hover { background: #f1f5f9; }

/* ===== TOOL STATUS ===== */
.tool-status-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin-bottom: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.85em;
    font-weight: 600;
    color: #475569;
}
.tool-status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.tool-status-indicator.connected {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}
.tool-status-indicator.disconnected {
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.3);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { width: 200px; min-width: 200px; }
    .main-content { margin-left: 200px; padding: 20px; }
    .tool-list { grid-template-columns: 1fr; }
    .two-panel-row { grid-template-columns: 1fr; }
    .settings-row-2col { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .sidebar { width: 100%; position: relative; min-width: unset; }
    .app-layout { flex-direction: column; }
    .main-content { margin-left: 0; padding: 16px; }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
    .nav-btn { flex: 1; min-width: 120px; justify-content: center; }
}
