/* ===== CSS VARIABLES (Easy Theme Customization) ===== */
:root {
    /* Dark Theme Colors */
    --bg-page: #1a1a1a;
    --bg-container: #2d2d2d;
    --bg-section: #353535;
    --bg-section-hover: #3d3d3d;
    --bg-card: #3a3a3a;
    --bg-input: #454545;
    
    /* Accent Colors */
    --color-primary: #4a9eff;
    --color-primary-dark: #357abd;
    --color-success: #3dd68c;
    --color-warning: #ffa726;
    --color-error: #ef5350;
    
    /* Text Colors */
    --text-primary: #e8e8e8;
    --text-secondary: #b8b8b8;
    --text-muted: #888888;
    
    /* Borders */
    --border-color: #4a4a4a;
    --border-radius: 6px;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ===== RESET & BASE ===== */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    padding: 20px;
    line-height: 1.6;
}

/* ===== CONTAINER ===== */
.container { 
    max-width: 1400px;
    margin: 0 auto;
    background: var(--bg-container);
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: var(--shadow-lg);
}

/* ===== TYPOGRAPHY ===== */
header {
    margin-bottom: 30px;
    border-bottom: 3px solid var(--color-primary);
    padding-bottom: 10px;
}

h1 { 
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 28px;
}

h2 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 22px;
}

h3 {
    color: var(--text-secondary);
    font-size: 16px;
}

/* ===== SECTIONS (COLLAPSIBLE) ===== */
.section {
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--bg-section);
}

.section-header {
    background: var(--bg-section);
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background-color 0.2s;
}

.section-header:hover {
    background: var(--bg-section-hover);
}

.section-toggle {
    font-size: 20px;
    transition: transform 0.3s;
    color: var(--text-secondary);
}

.section-content {
    padding: 20px;
    display: none;
    background: var(--bg-container);
}

.section.active .section-content {
    display: block;
}

.section.active .section-toggle {
    transform: rotate(180deg);
}

/* ===== FORMS ===== */
.form-row {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 15px;
    align-items: center;
    margin-bottom: 15px;
}

label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
}

input, select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    width: 100%;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: border-color 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.2);
}

input[type="file"] {
    padding: 8px;
}

.checkbox-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
}

.model-params {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.model-params > div {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.model-params label {
    font-size: 12px;
}

.model-params input {
    padding: 8px;
}

.api-key-input {
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

/* ===== BUTTONS ===== */
button, .submit-btn {
    padding: 12px 30px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s;
    margin-top: 20px;
    width: 100%;
}

button:hover, .submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

button:disabled, .submit-btn:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

/* ===== PROGRESS ===== */
.progress-section {
    margin-top: 30px;
}

.progress-bar-container {
    width: 100%;
    height: 30px;
    background: var(--bg-card);
    border-radius: 15px;
    overflow: hidden;
    margin: 15px 0;
    border: 1px solid var(--border-color);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-success));
    transition: width 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
}

#progressText {
    text-align: center;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== RESULTS ===== */
.results-section {
    margin-top: 30px;
}

.result-group {
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--bg-section);
}

.result-header {
    background: var(--bg-section);
    padding: 12px 15px;
    border-left: 4px solid var(--color-primary);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
    color: var(--text-primary);
}

.result-header:hover {
    background: var(--bg-section-hover);
}

.result-content {
    padding: 20px;
    display: none;
    background: var(--bg-container);
}

.result-group.active .result-content {
    display: block;
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    padding: 15px;
    border-radius: var(--border-radius);
    border-left: 3px solid var(--color-primary);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--text-primary);
}

/* ===== CLUSTERS ===== */
.cluster-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.cluster-card {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--bg-section);
}

.cluster-header {
    background: #2a4a5e;
    color: white;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.cluster-body {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    padding: 15px;
    background: var(--bg-container);
}

.cluster-image-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cluster-image {
    width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    border: 2px solid var(--color-primary);
}

.other-frames {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
}

.other-frame-item {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s;
}

.other-frame-item:hover {
    border-color: var(--color-primary);
}

.other-frame-item img {
    width: 100%;
    height: auto;
    display: block;
}

.other-frame-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    font-size: 11px;
}

.cluster-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cluster-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 10px;
}

.metric-item {
    background: var(--bg-card);
    padding: 10px;
    border-radius: 4px;
    font-size: 13px;
}

.metric-label {
    color: var(--text-muted);
    font-size: 11px;
    margin-bottom: 4px;
}

.metric-value {
    font-weight: bold;
    color: var(--text-primary);
    font-size: 16px;
}

.cluster-description {
    background: rgba(61, 214, 140, 0.15);
    padding: 12px;
    border-radius: var(--border-radius);
    border-left: 3px solid var(--color-success);
    line-height: 1.6;
    font-size: 14px;
    color: var(--text-primary);
}

/* ===== TRANSCRIPTION ===== */
.transcription-box {
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg-card);
    padding: 15px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.8;
}

.transcription-box p {
    margin-bottom: 10px;
}

.timestamp {
    color: var(--color-primary);
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

/* ===== NARRATIVE ===== */
.narrative-box {
    background: rgba(255, 167, 38, 0.15);
    padding: 25px;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--color-warning);
    line-height: 1.9;
    font-size: 15px;
    color: var(--text-primary);
}

/* ===== ERROR ===== */
.error {
    background: rgba(239, 83, 80, 0.15);
    border-left: 4px solid var(--color-error);
    color: #ff8a80;
    padding: 15px;
    border-radius: 4px;
    margin: 15px 0;
}

/* ===== UTILITIES ===== */
.hidden { 
    display: none !important; 
}

/* ===== SCROLLBAR STYLING ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-card);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5a5a5a;
}