/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-dark: #1a2332;
    --bg-darker: #141c27;
    --bg-card: #1e2d3d;
    --bg-card-hover: #243447;
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --accent-light: rgba(245, 158, 11, 0.12);
    --text-white: #f1f5f9;
    --text-light: #cbd5e1;
    --text-muted: #7a8a9e;
    --border: #2a3a4d;
    --border-light: #334155;
    --success: #10b981;
    --error: #ef4444;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-white);
    line-height: 1.6;
    min-height: 100vh;
}

.screen { display: none; }
.screen.active { display: block; }

/* --- Login --- */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-darker);
    padding: 20px;
}
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-header .logo { margin-bottom: 16px; }
.login-header .logo svg rect { fill: var(--accent); }
.login-header h1 { font-size: 22px; font-weight: 700; color: var(--text-white); letter-spacing: -0.3px; }
.login-header .subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* --- Forms --- */
.input-group { margin-bottom: 20px; }
.input-group label {
    display: block; font-size: 11px; font-weight: 600; color: var(--text-muted);
    margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.8px;
}
.input-group input {
    width: 100%; padding: 12px 16px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 14px; font-family: inherit;
    background: var(--bg-darker); color: var(--text-white);
    transition: border-color 0.2s, box-shadow 0.2s; outline: none;
}
.input-group input::placeholder { color: var(--text-muted); }
.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px;
    border: none; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
    font-family: inherit; cursor: pointer; transition: all 0.2s;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.btn-primary { background: var(--accent); color: var(--bg-darker); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-full { width: 100%; justify-content: center; padding: 14px; }
.btn-outline {
    background: transparent; border: 1px solid var(--border-light); color: var(--text-light);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 8px 12px; text-transform: none; }
.btn-ghost:hover { color: var(--text-white); }
.btn-icon {
    background: transparent; border: 1px solid var(--border); color: var(--text-muted);
    padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; transition: all 0.2s;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.error-text { color: var(--error); font-size: 13px; text-align: center; margin-top: 16px; }

/* --- App Header --- */
.app-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 32px; background: var(--bg-darker); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-left svg rect { fill: var(--accent); }
.header-left h2 { font-size: 16px; font-weight: 600; color: var(--text-white); letter-spacing: -0.2px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.user-badge {
    font-size: 12px; color: var(--accent); background: var(--accent-light);
    padding: 4px 12px; border-radius: 4px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
}

/* --- Main --- */
.app-main { max-width: 900px; margin: 0 auto; padding: 32px 24px; }

/* --- Upload --- */
.upload-section { margin-bottom: 32px; }
.upload-area {
    border: 1px dashed var(--border-light); border-radius: var(--radius);
    padding: 48px 32px; text-align: center; cursor: pointer;
    transition: all 0.2s; background: var(--bg-card);
}
.upload-area:hover, .upload-area.dragover {
    border-color: var(--accent); background: var(--accent-light);
}
.upload-area h3 { font-size: 16px; margin-top: 16px; font-weight: 600; color: var(--text-white); }
.upload-area p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.upload-icon svg circle { stroke: var(--accent); }
.upload-icon svg path { stroke: var(--accent); }
.file-info {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 20px; margin-top: 16px; display: flex; align-items: center;
    justify-content: space-between;
}
.file-details { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--text-light); }
.file-details svg { stroke: var(--accent); }

/* --- Progress --- */
.progress-section { margin-bottom: 32px; }
.progress-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 48px 32px; text-align: center;
}
.progress-card h3 { margin-top: 20px; font-size: 16px; color: var(--text-white); }
.text-muted { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.spinner {
    width: 48px; height: 48px; border: 3px solid var(--border);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin 0.8s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.batch-progress-list { margin-top: 20px; text-align: left; max-width: 500px; margin-left: auto; margin-right: auto; }
.batch-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 16px;
    border-radius: var(--radius-sm); margin-bottom: 6px; font-size: 13px;
    background: var(--bg-darker); border: 1px solid var(--border);
}
.batch-item-icon { font-size: 16px; flex-shrink: 0; }
.batch-item-name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-light); }
.batch-item-status { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.batch-item-done { border-color: var(--success); background: rgba(16, 185, 129, 0.08); }
.batch-item-failed { border-color: var(--error); background: rgba(239, 68, 68, 0.08); }
.batch-item-progress .batch-item-icon { animation: spin 1s linear infinite; display: inline-block; }

/* --- Results --- */
.results-section { margin-bottom: 32px; }
.results-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.results-header-left { display: flex; align-items: center; gap: 16px; }
.results-header h2 {
    font-size: 20px; font-weight: 700; color: var(--text-white);
    letter-spacing: -0.3px;
}
.results-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.transcript-panel {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
}
.panel-body { padding: 24px; max-height: 600px; overflow-y: auto; }
.transcript-text {
    font-size: 14px; line-height: 1.8; color: var(--text-light); white-space: pre-wrap;
}

/* Transcript Selector */
.transcript-selector {
    padding: 8px 32px 8px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 13px; font-family: inherit; font-weight: 500; color: var(--text-white);
    background: var(--bg-darker); cursor: pointer; outline: none;
    appearance: none; -webkit-appearance: none;
    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='%237a8a9e' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
}
.transcript-selector:focus { border-color: var(--accent); }

/* --- History --- */
.history-section { margin-top: 24px; }
.history-section h3 {
    font-size: 11px; font-weight: 700; color: var(--accent);
    text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 16px;
}
.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-item {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px 16px;
    display: flex; align-items: center; justify-content: space-between;
    transition: all 0.15s;
}
.history-item:hover {
    border-color: var(--accent); background: var(--bg-card-hover);
    transform: translateY(-1px);
}
.history-item-left {
    display: flex; align-items: center; gap: 16px; cursor: pointer;
    flex: 1; min-width: 0;
}
.history-item-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.history-item-name {
    font-weight: 500; font-size: 13px; color: var(--text-light);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-item-date { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.status-badge {
    font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 4px;
    text-transform: uppercase; letter-spacing: 0.8px;
}
.status-completed { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.status-in-progress { background: rgba(245, 158, 11, 0.15); color: var(--accent); }
.status-failed { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.show-all-container { text-align: center; margin-top: 12px; }

/* --- Toast --- */
.toast {
    position: fixed; bottom: 24px; right: 24px;
    background: var(--bg-card); color: var(--text-white);
    border: 1px solid var(--accent); border-left: 3px solid var(--accent);
    padding: 12px 24px; border-radius: var(--radius-sm); font-size: 13px;
    box-shadow: var(--shadow-lg); transform: translateY(100px); opacity: 0;
    transition: all 0.3s; z-index: 1000;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-darker); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Responsive --- */
@media (max-width: 768px) {
    .app-header { padding: 12px 16px; }
    .app-main { padding: 20px 16px; }
    .file-info { flex-direction: column; gap: 12px; }
    .results-header { flex-direction: column; align-items: flex-start; }
    .login-card { padding: 32px 24px; }
    .history-item-left { flex-direction: column; align-items: flex-start; gap: 4px; }
}

/* --- Login screen (added) --- */
#login-screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-darker);
    padding: 20px;
}
.login-card { text-align: center; }
.login-logo { margin-bottom: 20px; display: flex; justify-content: center; }
.login-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.3px; }
.login-card .text-muted { font-size: 14px; margin-bottom: 28px; }
.login-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-form input {
    width: 100%; padding: 12px 16px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 14px; font-family: inherit;
    background: var(--bg-darker); color: var(--text-white);
    transition: border-color 0.2s, box-shadow 0.2s; outline: none;
}
.login-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.login-form .btn { margin-top: 6px; justify-content: center; }
.login-error {
    color: var(--error); font-size: 13px; text-align: center; margin-top: 4px;
}

/* --- App header layout with logout --- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* --- Files section (S3 browser) --- */
.header-right { display: flex; align-items: center; gap: 8px; }
.files-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.files-note { font-size: 13px; margin-bottom: 16px; }
.files-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.files-tab { padding: 6px 14px; font-size: 13px; }
.files-tab.active { background: var(--accent); color: var(--bg-dark); border-color: var(--accent); }
