/* 
 * Search Recording Text App Stylesheet
 * Complete rewrite with improved organization and consistency
 */

/* ========== VARIABLES ========== */
:root {
    /* Color palette */
    --primary: #1976d2;
    --primary-dark: #1565c0;
    --primary-light: #e3f2fd;
    --primary-hover: rgba(25, 118, 210, 0.08);
    --accent: #f59e0b;
    --success: #22c55e;
    --success-dark: #16a34a;
    --error: #ef4444;
    --error-dark: #dc2626;
    --warning: #f59e0b;
    --warning-dark: #d97706;
    --info: #3b82f6;
    --info-dark: #2563eb;
    /* Text colors */
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #6b7280;
    /* Background colors */
    --bg-main: #ffffff;
    --bg-light: #9fa9b3;
    --bg-lighter: #f3f4f6;
    --bg-sidebar: lavender;
    /* Border colors */
    --border-light: #e5e7eb;
    --border-lighter: #f0f0f0;
    --border-subtle: rgba(0, 0, 0, 0.05);
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 24px;
    /* Font sizes */
    --text-xs: 0.7rem;
    --text-sm: 0.8rem;
    --text-base: 1rem;
    --text-md: 1.1rem;
    --text-lg: 1.25rem;
    --text-xl: 2.5rem;
    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;
    /* Shadows */
    --shadow-sm: 0 2px 5px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.15);
    /* Z-index layers */
    --z-sidebar: 10;
    --z-content: 5;
    --z-video: 30;
    --z-controls: 35;
    --z-search: 25;
    --z-overlay: 40;
    --z-modal: 1000;
    --z-toast: 9999;
    /* Layout dimensions */
    --sidebar-width: 50%; /* Changed from 300px to 50% */
    --search-height: 60vh;
    --main-area-height: 40vh;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* ========== LAYOUT ========== */
.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* Sidebar */
#sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-light);
    height: 100%;
    z-index: var(--z-sidebar);
    transition: transform 0.3s ease;
}

.sidebar-header {
    background-image: url('./images/Tower.jpg');
    background-size: cover; /* Resize the background image to cover the entire container */
    background-color: #cccccc;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-light);
}

    .sidebar-header h2 {
        font-size: var(--text-lg);
        font-weight: 600;
        color: var(--text-primary);
    }

.sidebar-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--border-light);
    margin-top: auto;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.file-list-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Conditional visibility - hide Clear All button and search when no files */
body.no-files .file-controls #clearButton,
body.no-files .search-controls {
    display: none;
}

/* Show controls when files are present or search results are visible */
body:not(.no-files) .file-controls #clearButton,
body:not(.no-files) .search-controls,
body.search-results-visible .search-controls {
    display: flex;
}

/* Main Content Layout */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    height: 100vh;
}

/* Video Container */
.video-container {
    position: relative;
    width: 100%;
    background-color: #000;
    height: 50vh;
    z-index: var(--z-content);
}

    .video-container.empty {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background-color: #222;
        color: white;
        text-align: center;
        padding: var(--space-xl);
    }

        .video-container.empty::before {
            content: "Welcome to Subtitle Search";
            font-size: var(--text-xl);
            font-weight: 600;
            margin-bottom: var(--space-md);
        }

        .video-container.empty::after {
            content: "Use the buttons in the sidebar to add your media and subtitle files. Once indexed, you can search through all your subtitles at once.";
            font-size: var(--text-md);
            max-width: 80%;
            opacity: 0.8;
        }

/* Video Player */
#videoPlayer {
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: var(--z-content);
}

    #videoPlayer.hidden {
        display: none;
    }

/* Subtitle Panel */
.subtitle-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--border-light);
    overflow: hidden;
    z-index: var(--z-content);
}

.subtitle-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-lg);
    border-bottom: 1px solid var(--border-light);
    background-color: var(--bg-light);
}

.subtitle-content {
    flex: 1;
    overflow-y: auto;
    position: relative;
}

/* ========== SEARCH RESULTS LAYOUT ========== */
/* UPDATED: Search results replace file list instead of overlay */
body.search-results-visible .file-list-container #fileList {
    display: none; /* Hide regular file list when showing search results */
}

/* Search results appear in the file list container */
body.search-results-visible #searchResults {
    display: block;
    height: 100%;
    overflow-y: auto;
    background-color: var(--bg-main);
}

#searchResults.hidden {
    display: none;
}

/* Remove the old overlay styles - search results now appear inline */
body.search-results-visible {
    /* Remove fixed positioning styles */
}

/* ========== BUTTONS & CONTROLS ========== */
/* Button styles */
.button {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-base);
    font-weight: 500;
    transition: background-color 0.2s;
}

    .button:hover {
        background-color: var(--primary-dark);
    }

.button-danger {
    background-color: var(--error);
    color: white;
    border: none;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-base);
    transition: background-color 0.2s;
}

    .button-danger:hover {
        background-color: var(--error-dark);
    }

    .button:disabled, .button-danger:disabled {
        opacity: 0.7;
        cursor: not-allowed;
    }

/* Icon button */
.icon-button {
    background: transparent;
    border: none;
    font-size: var(--text-lg);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: color 0.2s, background-color 0.2s;
}

    .icon-button:hover {
        color: var(--primary);
        background-color: var(--primary-hover);
    }

/* Button loading state */
.button.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

    .button.loading::after {
        content: '';
        position: absolute;
        left: 50%;
        top: 50%;
        width: 16px;
        height: 16px;
        margin-left: -8px;
        margin-top: -8px;
        border: 2px solid rgba(255, 255, 255, 0.2);
        border-radius: 50%;
        border-top-color: white;
        animation: button-loading-spinner 0.6s linear infinite;
    }

/* File Controls */
.file-controls {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-light);
}

    .file-controls .button,
    .file-controls .button-danger {
        flex: 1;
    }

/* Play button */
.play-button {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-sm);
    transition: background-color 0.2s;
    z-index: var(--z-controls);
    position: relative;
}

    .play-button:hover {
        background-color: var(--primary-dark);
    }

/* Big play button for autoplay blocked scenarios */
.video-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: var(--z-overlay);
}

.big-play-button {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: rgba(25, 118, 210, 0.8);
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: white;
    font-size: 36px;
    padding: 0;
    line-height: 1;
    transition: transform 0.2s, background-color 0.2s;
}

    .big-play-button:hover {
        transform: scale(1.1);
        background-color: rgba(25, 118, 210, 1);
    }

    .big-play-button span {
        margin-left: 5px; /* Slight offset for the play symbol */
    }

/* Forced play button for extreme cases - moved from inline styles */
.forced-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: var(--z-overlay);
    padding: 20px 40px;
    font-size: 18px;
    background-color: rgba(25, 118, 210, 0.9);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

    .forced-play-button:hover {
        background-color: var(--primary);
        transform: translate(-50%, -50%) scale(1.05);
    }

/* ========== SUBTITLE COMPONENTS ========== */
/* Subtitle Controls */
.subtitle-controls {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    font-size: small;
}

    .subtitle-controls span {
        font-weight: 600;
        font-size: small;
    }

.subtitle-settings {
    display: flex;
    align-items: center;
}


/* Subtitle Overlay */
.subtitle-overlay {
    position: absolute;
    bottom: 10%;
    left: 10%;
    right: 10%;
    text-align: center;
    color: white;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
    font-size: 20px;
    z-index: 2;
    pointer-events: none;
}

/* Subtitle Transcript */
.subtitle-entry {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-lighter);
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
}

    .subtitle-entry:hover {
        background-color: var(--bg-light);
    }

    .subtitle-entry.active {
        background-color: var(--primary-light);
        border-left: 3px solid var(--primary);
    }

.subtitle-timestamp {
    color: var(--primary);
    font-weight: 600;
    min-width: 70px;
    margin-right: var(--space-md);
}

.subtitle-text, .search-result-text {
    flex: 1;
    font-size: var(--text-sm);
}

.subtitle-entry.active .subtitle-text {
    font-weight: 500;
}

.subtitle-current {
    position: sticky;
    top: 0;
    padding: var(--space-md);
    background-color: var(--primary-light);
    border-bottom: 1px solid var(--primary);
    font-weight: 500;
    z-index: 2;
}

.auto-scroll-indicator {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    background-color: rgba(25, 118, 210, 0.9);
    color: white;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    display: none;
    align-items: center;
    gap: var(--space-sm);
    z-index: 10;
    animation: fadeIn 0.3s, fadeOut 0.3s 0.7s forwards;
}

    .auto-scroll-indicator.visible {
        display: flex;
    }

/* ========== FILE LIST COMPONENTS ========== */
/* File List */
.folder-header {
    padding: var(--space-sm) var(--space-md);
    font-weight: 600;
    background-color: var(--bg-light); /* Changed from var(--bg-lighter) to primary blue */
    color: white; /* Changed from var(--text-secondary) to white for contrast */
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: var(--radius-sm); /* Added border radius for better appearance */
    margin-bottom: var(--space-xs); /* Added margin for spacing */
}

/* Add styles for duration display */
.duration {
    background-color: var(--primary-light);
    color: var(--primary);
    padding: 2px var(--space-xs);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 600;
    margin-right: var(--space-sm);
}

.file-item {
    position: relative;
    padding: 3px;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background-color 0.2s;
}

    .file-item:hover {
        background-color: rgba(0, 0, 0, 0.03);
    }

    .file-item.active {
        background-color: var(--primary-hover);
    }

    .file-item.has-linked-files {
        border-left: 3px solid var(--primary);
    }

.file-header {
    font-weight: 600;
    font-size: var(--text-sm);
    margin-bottom: var(--space-xs);
    display: block;
    text-wrap: nowrap;
    justify-content: space-between;
}

.file-icon {
    margin-right: var(--space-sm);
}

.file-meta {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    display: flex;
    flex-wrap: nowrap;
    text-wrap: nowrap;
    gap: var(--space-sm);
}

.linked-files {
    margin-top: var(--space-sm);
    font-size: var(--text-xs);
    background-color: rgba(25, 118, 210, 0.06);
    padding: 0px var(--space-sm);
    color: var(--text-secondary);
}

.linked-file {
    font-size: var(--text-xs);
    padding: var(--space-xs) 0;
    display: block;
    text-wrap: nowrap;
    justify-content: space-between;
}

.subtitle-count {
    margin-left: var(--space-xs);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.link-badge {
    display: inline-flex;
    align-items: center;
    font-size: var(--text-xs);
    background-color: var(--primary);
    color: white;
    padding: 2px var(--space-sm);
    border-radius: var(--radius-full);
    margin-left: var(--space-sm);
}

.summary-item {
    padding: var(--space-sm) var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
}

.badge {
    background-color: var(--primary);
    color: white;
    padding: 2px var(--space-sm);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: bold;
}

/* ========== SEARCH RESULTS COMPONENTS ========== */
/* Search Results Header */
.search-header {
    padding: var(--space-md) var(--space-lg);
    font-weight: 600;
    border-bottom: 1px solid var(--border-light);
    background-color: var(--primary-light);
    color: var(--text-primary);
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Close button for search results */
.search-close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background: white;
    border: 1px solid var(--border-light);
    font-size: 18px;
    cursor: pointer;
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    z-index: 6;
}

    .search-close-button:hover {
        background-color: var(--bg-light);
        color: var(--primary);
    }

/* File Groups in Search Results */
.search-file-group {
    margin-bottom: var(--space-sm);
    background-color: var(--bg-main);
    border-bottom: 1px solid var(--border-light);
}

.search-file-header {
    padding: var(--space-sm) var(--space-lg);
    font-weight: 600;
    background-color: var(--bg-lighter);
    display: flex;
    text-wrap: nowrap;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--border-lighter);
}

/* Individual Search Result Items */
.search-result {
    padding: var(--space-sm) var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background-color 0.2s;
    background-color: var(--bg-main);
    position: relative;
    z-index: 5;
}

    .search-result:hover {
        background-color: var(--primary-hover);
    }

.search-result-count {
    font-size: var(--text-sm);
    color: var(--text-muted);
    background-color: var(--primary-light);
    padding: 2px var(--space-sm);
    border-radius: var(--radius-full);
}

.search-result-header {
    margin-bottom: var(--space-xs);
    font-size:small;
}

.search-result-time {
    color: var(--primary);
    font-weight: 600;
}


.search-result-text mark {
    background-color: #fef08a;
    padding: 0 2px;
    border-radius: 2px;
}

/* ========== TTS COMPONENTS ========== */
/* TTS Controls */
.tts-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 16px;
}

.tts-button {
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background-color 0.2s;
}

    .tts-button:hover:not(:disabled) {
        background-color: var(--primary-dark);
    }

    .tts-button:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

.tts-active-subtitle {
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 80%;
    margin: 0 auto;
}

.tts-icon {
    font-size: 1.5rem;
}

.tts-text {
    font-size: 1.2rem;
    line-height: 1.4;
}

/* TTS Settings */
.settings-group {
    margin-bottom: 16px;
}

    .settings-group label {
        display: block;
        margin-bottom: 6px;
        font-weight: 500;
    }

.tts-setting {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ========== PROCESSING PROGRESS (SIDEBAR FOOTER) ========== */
/* NEW: Processing progress in sidebar footer */
.processing-progress {
    margin-top: var(--space-sm);
    padding: var(--space-sm);
    background-color: var(--bg-lighter);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    text-wrap: nowrap;
}

    .processing-progress.hidden {
        display: none;
    }

.progress-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xs);
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

/* Progress Bar - moved to sidebar footer */
.progress-bar-container {
    width: 100%;
    height: 6px;
    background-color: var(--border-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin: var(--space-xs) 0;
}

.progress-bar {
    height: 100%;
    background-color: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
}

    .progress-bar.processing {
        animation: pulse 1.5s infinite;
    }

/* ========== NOTIFICATIONS ========== */
/* Autoplay message */
.autoplay-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(25, 118, 210, 0.9);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0.2, 0.2);
    z-index: var(--z-toast);
    max-width: 400px;
    text-align: center;
    animation: fadeIn 0.3s;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.autoplay-message button {
    margin-top: 8px;
    padding: 6px 12px;
    background-color: white;
    color: var(--primary);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

    .autoplay-message button:hover {
        background-color: #f0f0f0;
    }

/* Toast notifications */
#toast-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    z-index: var(--z-toast);
    max-width: 350px;
}

.toast {
    background-color: #333;
    color: white;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-sm);
    margin-top: var(--space-md);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: flex-start;
    overflow: hidden;
    animation: fadeInUp 0.3s forwards;
}

.toast-success {
    background-color: var(--success);
    /*  border-left: 4px solid var(--success-dark);*/
}

.toast-error {
    background-color: var(--error);
    /* border-left: 4px solid var(--error-dark);*/
}

.toast-warning {
    background-color: var(--warning);
    /* border-left: 4px solid var(--warning-dark); */
}

.toast-info {
    background-color: var(--info);
   /* border-left: 4px solid var(--info-dark); */
}

.toast-icon {
    margin-right: var(--space-md);
    font-size: 20px;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.toast-message {
    opacity: 0.9;
}

.toast-close {
    background: transparent;
    border: none;
    color: white;
    opacity: 0.7;
    cursor: pointer;
    font-size: 16px;
    padding: 0 0 0 var(--space-md);
    transition: opacity 0.2s;
}

    .toast-close:hover {
        opacity: 1;
    }

/* Error states and indicators */
.error-icon {
    font-size: 48px;
    margin-bottom: var(--space-md);
}

.error-details {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin: var(--space-md) 0;
    max-width: 80%;
}

.loading-state {
    padding: var(--space-xl);
    text-align: center;
    color: var(--text-muted);
}

.empty-state {
    padding: var(--space-xl);
    text-align: center;
    color: var(--text-muted);
}

.error-state {
    padding: var(--space-xl);
    text-align: center;
    color: var(--error);
}

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

/* ========== ANIMATIONS ========== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
    }

    to {
        transform: scale(1);
    }
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

@keyframes button-loading-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* ========== RESPONSIVE STYLES ========== */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px; /* Reset sidebar width for mobile */
    }

    #sidebar {
        position: fixed;
        transform: translateX(-100%);
        width: 85%;
        max-width: 300px;
        box-shadow: var(--shadow-lg);
        z-index: var(--z-modal);
    }

        #sidebar.open {
            transform: translateX(0);
        }

    .sidebar-header h2 {
        font-size: var(--text-base);
    }

    .file-controls {
        flex-direction: column;
    }

    /* Mobile search mode - no longer needs special layout since results replace file list */
    body.search-results-visible .video-container,
    body.search-results-visible .subtitle-panel {
        position: static;
        width: 100%;
        height: auto;
    }

    body.search-results-visible .video-container {
        height: 40vh;
    }

    body.search-results-visible .subtitle-panel {
        height: 30vh;
    }

    body.search-results-visible .main-content {
        display: flex;
        flex-direction: column;
    }
}

/* Ensure video controls are accessible */
video::-webkit-media-controls {
    z-index: var(--z-controls);
}

.no-video {
    color: var(--text-muted);
    font-style: italic;
    font-size: var(--text-sm);
    padding: 3px 10px;
    background-color: var(--bg-lighter);
    border-radius: var(--radius-sm);
}

.search-result.standalone-srt {
    border-left: 3px solid var(--warning);
}

.search-file-header .no-video-badge {
    background-color: var(--warning);
    color: white;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    margin-left: 8px;
}
/* Add these styles to your existing CSS */

.select-video-button {
    background-color: var(--warning);
    color: white;
    border: none;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-sm);
    transition: background-color 0.2s;
    z-index: var(--z-controls);
    position: relative;
}

    .select-video-button:hover {
        background-color: var(--warning-dark);
    }

.video-linked-badge {
    background-color: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.no-video-badge {
    background-color: var(--warning);
    color: white;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    margin-left: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

    .no-video-badge:hover {
        background-color: var(--warning-dark);
    }

.search-header-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Add these new styles for larger search controls */
.search-controls {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-light);
    position: relative;
}

.search-input-group {
    display: flex;
    gap: var(--space-sm);
    width: 100%;
    align-items: center;
    position: relative;
}

/* Enhanced search input - made slimmer to align with Clear All button */
#searchInput {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-base);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background-color: var(--bg-main);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 36px;
}

    #searchInput:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 2px var(--primary-hover);
    }

    #searchInput::placeholder {
        color: var(--text-muted);
        font-size: var(--text-sm);
    }

/* Enhanced search button - made slimmer to align with Clear All button */
.search-button {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-base);
    transition: background-color 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 36px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

    .search-button:hover {
        background-color: var(--primary-dark);
        transform: translateY(-1px);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    }

    .search-button:active {
        transform: translateY(0);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    }

.search-icon {
    font-size: var(--text-base);
    line-height: 1;
}

/* Search Help Button */
.search-help-button {
    background-color: var(--text-muted);
    color: white;
    border: none;
    padding: var(--space-sm);
    border-radius: 50%;
    cursor: pointer;
    font-size: var(--text-sm);
    transition: background-color 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    min-height: 28px;
    font-weight: bold;
}

    .search-help-button:hover {
        background-color: var(--primary);
        transform: scale(1.1);
    }

/* Search Help Panel */
.search-help-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-overlay);
    margin-top: var(--space-xs);
}

    .search-help-panel.hidden {
        display: none;
    }

.search-help-content {
    padding: var(--space-lg);
}

    .search-help-content h4 {
        margin: 0 0 var(--space-md) 0;
        color: var(--primary);
        font-size: var(--text-lg);
        font-weight: 600;
        display: flex;
        align-items: center;
        gap: var(--space-sm);
    }

.search-examples {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.search-example {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    background-color: var(--bg-lighter);
    transition: background-color 0.2s;
}

    .search-example:hover {
        background-color: var(--primary-hover);
    }

    .search-example code {
        background-color: var(--primary-light);
        color: var(--primary-dark);
        padding: 2px var(--space-xs);
        border-radius: var(--radius-sm);
        font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
        font-size: var(--text-sm);
        font-weight: 600;
        min-width: 120px;
        text-align: left;
        border: 1px solid var(--primary);
    }

    .search-example span {
        color: var(--text-secondary);
        font-size: var(--text-sm);
        line-height: 1.4;
        flex: 1;
    }

.search-help-note {
    background-color: var(--info-light, #e3f2fd);
    border-left: 4px solid var(--info);
    padding: var(--space-md);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

    .search-help-note strong {
        color: var(--info-dark);
        font-weight: 600;
    }

/* Sort Controls */
.sort-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-xs);
}

    .sort-controls select {
        flex: 1;
        padding: var(--space-xs) var(--space-sm);
        border: 1px solid var(--border-light);
        border-radius: var(--radius-sm);
        background-color: var(--bg-main);
        color: var(--text-primary);
        font-size: var(--text-sm);
        transition: border-color 0.2s;
    }

        .sort-controls select:focus {
            outline: none;
            border-color: var(--primary);
        }

    /* NEW: File Filter Input Styles */
    .sort-controls input[type="text"] {
        flex: 1;
        padding: var(--space-xs) var(--space-sm);
        border: 1px solid var(--border-light);
        border-radius: var(--radius-sm);
        background-color: var(--bg-main);
        color: var(--text-primary);
        font-size: var(--text-sm);
        transition: border-color 0.2s, box-shadow 0.2s;
        margin-left: var(--space-xs);
    }

        .sort-controls input[type="text"]:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 2px var(--primary-hover);
        }

        .sort-controls input[type="text"]::placeholder {
            color: var(--text-muted);
            font-style: italic;
        }

        /* Add visual indicator when filter is active */
        .sort-controls input[type="text"]:not(:placeholder-shown) {
            border-color: var(--success);
            background-color: rgba(34, 197, 94, 0.05);
        }

/* Responsive adjustments for slimmer search */
@media (max-width: 768px) {
    .search-controls {
        padding: var(--space-sm);
    }

    #searchInput {
        padding: var(--space-xs) var(--space-sm);
        font-size: var(--text-sm);
        min-height: 32px;
    }

    .search-button {
        padding: var(--space-xs) var(--space-sm);
        min-width: 36px;
        min-height: 32px;
        font-size: var(--text-sm);
    }

    .search-icon {
        font-size: var(--text-sm);
    }

    .search-help-button {
        min-width: 24px;
        min-height: 24px;
        font-size: var(--text-xs);
    }

    .search-help-content {
        padding: var(--space-md);
    }

    .search-example {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-xs);
    }

        .search-example code {
            min-width: auto;
            width: 100%;
        }

    .sort-controls {
        flex-direction: column;
        align-items: stretch;
    }

        .sort-controls select,
        .sort-controls input[type="text"] {
            margin-left: 0;
            margin-top: var(--space-xs);
        }
}

.processing-tip {
    margin-top: 6px;
    font-size: 24px;
    line-height: 1.35;
    color: var(--text-secondary, #b8b8b8);
    opacity: 1;
    transition: opacity 220ms ease;
}

    .processing-tip .tip-icon {
        margin-right: 6px;
      
    }

    .processing-tip .tip-title {
        font-weight: 800;
        color: var(--text-primary, #eaeaea);
    }

.upload-overlay-text .tip-status {
    margin-bottom: 8px;
    font-size: 14px;
}

.upload-overlay-text .tip-help {
    font-size: 12px;
    line-height: 1.35;
    opacity: 0.95;
}

.upload-overlay-text .tip-icon {
    margin-right: 6px;
}

/* ========== CONSOLE LOG DISPLAY ========== */
/* --- App log: collapsed by default, expanded only when the arrow is hovered --- */

.sidebar-footer {
    position: relative;
}

/* --- App log with integrated hover arrow --- */

.app-log-wrap {
    position: relative;
    /* leave room at the top for the arrow tab so it doesn't overlap text */
    padding-top: 14px;
}

.app-log {
    max-height: 24px;
    overflow: hidden;
    background: var(--bg-secondary, #232323);
    border: 1px solid var(--border-color, #444);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-secondary, #bbb);
    transition: max-height 220ms ease;
}

/* The arrow — sits on the log's top-right corner and shares its border,
   so it visually reads as a tab belonging to the log itself */
.app-log-toggle {
    position: absolute;
    top: 0;
    right: 6px;
    height: 15px;
    padding: 0 8px;
    line-height: 13px;
    font-size: 11px;
    color: var(--text-secondary, #bbb);
    background: var(--bg-secondary, #232323);
    border: 1px solid var(--border-color, #444);
    border-bottom: none; /* merge into the log's top border */
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 120ms ease, color 120ms ease, background 120ms ease;
}

      .app-log-toggle:focus-visible {
        opacity: 1;
        color: var(--text-primary, #fff);
        background: var(--bg-tertiary, #2f2f2f);
        outline: none;
    }

    /* Rotate the caret when expanded */
    .app-log-toggle > span {
        display: inline-block;
        transition: transform 220ms ease;
    }

   .app-log-toggle:focus-visible > span,
    .app-log-toggle.pinned > span {
        transform: rotate(180deg);
    }

/* Expand ONLY when the arrow (or its focus) is active — not the log body.
   Using :has() lets ordering in the DOM be arbitrary. */
.app-log-wrap:has(.app-log-toggle:focus-visible) .app-log,
.app-log-wrap:has(.app-log-toggle.pinned) .app-log {
    max-height: 40vh;
    overflow-y: auto;
}
    .app-log:empty {
        display: none;
    }

.log-entry {
    padding: 1px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 10px;
    line-height: 1.2;
    word-break: break-word;
}

    .log-entry:last-child {
        border-bottom: none;
    }

    .log-entry.log-info {
        color: #9cdcfe;
    }

    .log-entry.log-warn {
        color: #ffd700;
    }

    .log-entry.log-error {
        color: #f48771;
    }

    .log-entry.log-debug {
        color: #608b4e;
    }

.log-timestamp {
    color: #808080;
    margin-right: var(--space-xs);
    font-size: 9px;
}

.log-message {
    color: inherit;
}

.app-log::-webkit-scrollbar {
    width: 4px;
}

.app-log::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.app-log::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

    .app-log::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.5);
    }

/* Enhanced subtitle highlighting styles */
.subtitle-line {
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    padding-left: 8px;
}

    .subtitle-line.active {
        background-color: rgba(25, 118, 210, 0.1);
        border-left-color: #1976d2;
        box-shadow: 0 2px 8px rgba(25, 118, 210, 0.2);
    }

    .subtitle-line.current-playing {
        background-color: rgba(25, 118, 210, 0.15);
        border-left-color: #1976d2;
        border-left-width: 4px;
    }

    .subtitle-line.has-search-match {
        background-color: rgba(255, 193, 7, 0.1);
        border-left-color: #ffc107;
    }

        .subtitle-line.has-search-match.active {
            background-color: rgba(25, 118, 210, 0.2);
            border-left-color: #1976d2;
        }

/* Search term highlighting */
.search-highlight {
    background-color: #ffeb3b;
    color: #333;
    font-weight: 600;
    padding: 1px 3px;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

    .search-highlight.current {
        background-color: #ff5722;
        color: white;
        animation: pulse-highlight 2s ease-in-out;
    }

    .search-highlight.large {
        font-size: 1.1em;
        padding: 2px 6px;
        border-radius: 4px;
    }

/* Search result enhancements */
.search-result.enhanced-highlight {
    transition: all 0.2s ease;
}

    .search-result.enhanced-highlight:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }

.search-result-text mark {
    background-color: #ffeb3b;
    color: #333;
    font-weight: 600;
    padding: 1px 2px;
    border-radius: 2px;
}

/* Current subtitle display enhancements */
#currentSubtitle {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 16px 20px;
    border-radius: 8px;
    font-size: 18px;
    line-height: 1.4;
    text-align: center;
    margin: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
}

    #currentSubtitle .search-highlight.large {
        background-color: #ffeb3b;
        color: #333;
        font-weight: 700;
        animation: pulse-highlight 1.5s ease-in-out infinite;
    }

/* Animations */
@keyframes pulse-highlight {
    0%, 100% {
        background-color: #ffeb3b;
        transform: scale(1);
    }

    50% {
        background-color: #ff5722;
        transform: scale(1.05);
        color: white;
    }
}

/* Auto-scroll indicator improvements */
.auto-scroll-indicator {
    background: rgba(25, 118, 210, 0.1);
    border-left: 3px solid #1976d2;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 4px;
    font-size: 0.9em;
    color: #1976d2;
}

/* Clickable subtitle lines */
.subtitle-line {
    cursor: pointer;
}

    .subtitle-line:hover {
        background-color: rgba(0, 0, 0, 0.05);
    }

        .subtitle-line:hover .sub-time {
            color: #1976d2;
            font-weight: 600;
        }

/* Add these styles at the end of your CSS file if they're not already present */

/* Subtitle transcript styles */
.subtitle-transcript {
    padding: var(--space-sm);
}

.subtitle-line {
    display: flex;
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    margin-left: var(--space-xs);
}

    .subtitle-line:hover {
        background-color: rgba(0, 0, 0, 0.05);
    }

        .subtitle-line:hover .sub-time {
            color: var(--primary);
            font-weight: 600;
        }

    .subtitle-line.active {
        background-color: rgba(25, 118, 210, 0.1);
        border-left-color: var(--primary);
        box-shadow: 0 2px 8px rgba(25, 118, 210, 0.2);
    }

    .subtitle-line.current-playing {
        background-color: rgba(25, 118, 210, 0.15);
        border-left-color: var(--primary);
        border-left-width: 4px;
    }

    .subtitle-line.has-search-match {
        background-color: rgba(255, 193, 7, 0.1);
        border-left-color: #ffc107;
    }

        .subtitle-line.has-search-match.active {
            background-color: rgba(25, 118, 210, 0.2);
            border-left-color: var(--primary);
        }

.sub-time {
    color: var(--primary);
    font-weight: 600;
    min-width: 80px;
    margin-right: var(--space-md);
    font-size: var(--text-sm);
}

.sub-text {
    flex: 1;
    font-size: var(--text-sm);
    line-height: 1.4;
}

/* Search term highlighting - matches search results styling */
.search-highlight {
    background-color: #ffeb3b;
    color: #333;
    font-weight: 600;
    padding: 1px 3px;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

    .search-highlight.current {
        background-color: #ff5722;
        color: white;
        animation: pulse-highlight 2s ease-in-out;
    }

    .search-highlight.large {
        font-size: 1.1em;
        padding: 2px 6px;
        border-radius: 4px;
    }

/* Animation for highlighted search terms */
@keyframes pulse-highlight {
    0%, 100% {
        background-color: #ffeb3b;
        transform: scale(1);
    }

    50% {
        background-color: #ff5722;
        transform: scale(1.05);
        color: white;
    }
}

/* ========== UPLOAD OVERLAY ========== */
.upload-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-xl) var(--space-lg);
    height: 100%;
    animation: fadeIn 0.3s ease;
}

.upload-overlay-icon {
    font-size: 48px;
    margin-bottom: var(--space-lg);
    animation: pulse 2s ease-in-out infinite;
}

.upload-overlay-title {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--primary);
    margin-bottom: var(--space-md);
}

.upload-overlay-text {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.7;
    max-width: 340px;
}

    .upload-overlay-text strong {
        color: var(--primary-dark);
    }


/* ========== SHARE BUTTON ========== */
.share-button {
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-light);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-sm);
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
    z-index: var(--z-controls);
    position: relative;
    margin-left: var(--space-xs);
}

    .share-button:hover {
        background-color: var(--primary-light);
        color: var(--primary);
        border-color: var(--primary);
    }

    .share-button:active {
        background-color: var(--primary);
        color: white;
    }

    #btnSeek.seek-button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Main-content overlay for ReadMe / fallback landing page */
/* Main-content overlay for ReadMe / fallback iframe */
.main-content {
    position: relative;
}

.main-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    background: #fff; /* white default so a blank iframe isn't a black hole */
    overflow: hidden;
}

    .main-overlay.hidden {
        display: none;
    }

    /* Fallback iframe — absolutely pinned, always fills its parent */
    .main-overlay #mainOverlayFrame {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        border: 0;
        margin: 0;
        padding: 0;
        background: #fff;
        color-scheme: light;
    }

        .main-overlay #mainOverlayFrame.hidden {
            display: none;
        }

    /* Inline HTML pane (ReadMe.htm) */
    .main-overlay .main-overlay-html {
        position: absolute;
        inset: 0;
        overflow: auto;
        padding: 1.25rem 1.5rem;
       color: var(--text-primary, #eee);
        line-height: 1.5;
    }

        .main-overlay .main-overlay-html.hidden {
            display: none;
        }

        .main-overlay .main-overlay-html img {
            max-width: 100%;
            height: auto;
        }

        .main-overlay .main-overlay-html a {
            color: var(--accent-color, #4ea1ff);
        }

/* --- Ensure #mainOverlay sits above the video container --- */
main.main-content > .video-container {
    position: relative;
    z-index: 0 !important;
}

main.main-content > #mainOverlay:not(.hidden) {
    z-index: 1000 !important;
}

/* Prevent the (hidden) <video> element from claiming a stacking slot */
#videoPlayer.hidden {
    display: none !important;
}
