:root {
    --bg-color: #f8fafc;
    --sidebar-bg: #ffffff;
    --accent-color: #4f46e5;
    --secondary-color: #ec4899;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(0, 0, 0, 0.08);
    --sidebar-width: 260px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    position: relative;
}

/* Background animated elements */
.bg-blob {
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-color) 0%, transparent 60%);
    filter: blur(100px);
    opacity: 0.1;
    z-index: -1;
    animation: move 25s infinite alternate;
}
.bg-blob-2 {
    position: absolute;
    bottom: -100px;
    right: -100px;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--secondary-color) 0%, transparent 60%);
    filter: blur(100px);
    opacity: 0.08;
    z-index: -1;
    animation: move 20s infinite alternate-reverse;
}
@keyframes move {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(150px, 150px) scale(1.1); }
}

/* Sidebar styling */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--glass-border);
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: 2px 0 10px rgba(0,0,0,0.02);
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar .brand {
    font-size: 1.7rem;
    font-weight: 800;
    background: linear-gradient(to right, var(--accent-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
}
.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.3rem; /* Tighter gap */
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.75rem 1rem; /* Tighter padding */
    border-radius: 0.6rem;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    transition: all 0.2s ease;
}
.nav-item:hover { background: rgba(0, 0, 0, 0.03); color: var(--text-color); }
.nav-item.active { background: rgba(99, 102, 241, 0.1); color: var(--accent-color); border: 1px solid rgba(99, 102, 241, 0.2); }
.nav-item.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.sidebar-footer {
    margin-top: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.ad-sidebar-box {
    margin-bottom: 1.5rem;
    width: 100%;
    height: 150px;
    background: #f1f5f9;
    border: 1px dashed #cbd5e1;
    border-radius: 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Main Content styling */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden; /* Fix horizontal scrollbar */
    position: relative;
}
.top-bar {
    width: 100%;
    padding: 0.5rem 1.5rem; /* Reduced from 0.75rem */
    background: var(--page-theme-gradient, linear-gradient(135deg, var(--accent-color), var(--secondary-color)));
    display: flex;
    align-items: center;
    z-index: 20;
    position: sticky;
    top: 0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08); /* Elegant shadow */
}
.top-bar-title {
    margin-left: 1rem;
    font-weight: 800;
    font-size: 1.15rem;
    color: #ffffff; /* White for strong contrast */
    letter-spacing: -0.5px;
}
.menu-toggle {
    display: flex;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #ffffff; /* White for header contrast */
    padding: 0.4rem;
    border-radius: 0.4rem;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.menu-toggle:hover { background: rgba(255,255,255,0.2); }

.main-content-inner {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    flex: 1;
}
.content-wrapper {
    display: flex;
    gap: 2rem;
    width: 100%;
    max-width: 1100px;
    justify-content: center;
    align-items: flex-start;
}
.container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 1.25rem;
    padding: 2rem 3rem; /* Reduced from 2.5rem */
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.08);
    flex: 1;
    max-width: 900px;
    width: 100%;
    animation: fadeIn 0.8s ease-out;
}
.ad-side-banner {
    width: 160px;
    height: 500px;
    background: #f1f5f9;
    border: 1px dashed #cbd5e1;
    border-radius: 0.75rem;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 500;
    flex-shrink: 0;
    position: sticky;
    top: 1rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

/* Tabs UI */
.tabs-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    background: #f1f5f9;
    padding: 0.4rem;
    border-radius: 0.75rem;
    width: fit-content;
}
.tab-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all 0.3s;
}
.tab-btn:hover { color: var(--text-color); }
.tab-btn.active {
    background: #ffffff;
    color: var(--accent-color);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

/* Batch List UI */
.batch-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.batch-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #ffffff;
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.batch-thumb-wrapper {
    width: 140px;
    height: 140px;
    border-radius: 0.6rem;
    background: #f8fafc;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.batch-thumb { max-width: 100%; max-height: 100%; object-fit: contain; }
.batch-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    overflow: hidden;
}
.batch-name { font-size: 0.9rem; font-weight: 700; color: var(--text-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.batch-status { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }
.status-done { color: #10b981; }
.status-error { color: #ef4444; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Desktop specific behavior */
@media (min-width: 769px) {
    .sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-width)); }
}

/* Mobile Responsive Design */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
    z-index: 5;
    opacity: 0;
    transition: opacity 0.3s ease;
}

@media (max-width: 1050px) {
    .ad-side-banner { display: none !important; }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        z-index: 100;
    }
    .sidebar.open { left: 0; }
    .sidebar-overlay.open { display: block; opacity: 1; z-index: 50; }
    .main-content-inner { padding: 0.5rem; }
    .top-bar { padding: 0.5rem 1rem; }
    .container { 
        padding: 0.8rem; 
        border-radius: 0.75rem;
    }
    h1 { 
        font-size: 1.4rem; 
    }
    
    .btn-action { 
        padding: 0.5rem 0.8rem; 
        font-size: 0.85rem;
    }

    /* Video Editor Mobile UI Core */
    .time-group {
        height: 32px !important;
        padding: 2px 4px !important;
        flex-shrink: 0 !important;
    }
    .time-group input {
        width: 34px !important;
        font-size: 0.85rem !important;
        flex-shrink: 0 !important;
    }
    .timeline-track {
        height: 180px;
    }
    
    /* Segment item compacting */
    .segment-item {
        padding: 8px 4px !important;
    }
    .clip-times {
        gap: 2px !important;
    }
    .clip-dur-text {
        display: none !important;
    }
    
    #btn-export {
        font-size: 0.85rem;
        padding: 0.6rem 1rem;
    }

    .mobile-hide-label {
        display: none !important;
    }
}

/* Video Editor Specific Mobile UI */
.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
    gap: 1rem;
}

@media (max-width: 600px) {
    .editor-header {
        flex-direction: column;
        align-items: stretch;
    }
    .editor-header .subtitle {
        display: block;
        margin-top: 4px;
    }
    #btn-export {
        width: 100%;
        margin-left: 0 !important;
        margin-top: 10px;
    }
}

/* Loading Spinner */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: 1rem;
    display: none;
}
.loading-overlay.active { display: flex; }
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.btn-action.vibrant {
    background: linear-gradient(135deg, var(--accent-color), #4338ca);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
    font-weight: 800;
}

/* Soft Buttons for secondary actions */
.btn-soft-green {
    background: #ecfdf5 !important;
    border: 1px solid #a7f3d0 !important;
    color: #065f46 !important;
}

.btn-soft-red {
    background: #fef2f2 !important;
    border: 1px solid #fecaca !important;
    color: #991b1b !important;
}

.btn-soft-gray {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    color: #64748b !important;
}

/* Segmented Control (Toggle) */
.mode-toggle {
    display: flex;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 8px;
    gap: 2px;
}

.mode-option {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    white-space: nowrap;
}

.mode-option.active {
    background: white;
    color: var(--accent-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.mode-option:hover:not(.active) {
    background: #e2e8f0;
}
.btn-action.vibrant:hover {
    background: linear-gradient(135deg, #fb923c, #f97316);
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(234, 88, 12, 0.4);
}
.btn-action.vibrant:disabled {
    background: #e2e8f0 !important;
    color: #94a3b8 !important;
    box-shadow: none !important;
    cursor: not-allowed;
    transform: none !important;
}

/* Premium Switch Button */
.premium-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    padding: 6px 14px;
    border-radius: 99px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #e2e8f0;
    user-select: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.premium-switch:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.premium-switch input {
    display: none;
}

.premium-switch input:checked + .switch-track {
    background: #10b981;
}

.premium-switch input:checked + .switch-track .switch-thumb {
    transform: translateX(18px);
}

.premium-switch .switch-track {
    width: 38px;
    height: 20px;
    background: #cbd5e1;
    border-radius: 20px;
    position: relative;
    transition: all 0.3s ease;
}

.premium-switch .switch-thumb {
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 3px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.premium-switch .switch-label {
    font-size: 0.8rem;
    font-weight: 800;
    color: #475569;
}


/* Mode Toggle Help Button */
.btn-toggle-help {
    padding: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #64748b;
    font-size: 0.7rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn-toggle-help:hover {
    background: #e2e8f0;
    color: var(--accent-color);
    transform: scale(1.1);
}

/* Focus highlight for all inputs */
.time-group input.modified, input.modified {
    background-color: #fef3c7 !important; /* light yellow background */
    border-color: #f59e0b !important;
    color: #92400e !important;
}

/* Specific focus style for modified inputs to avoid purple/yellow conflict */
.time-group input.modified:focus, input.modified:focus {
    background-color: #fef3c7 !important;
    border-color: #f59e0b !important;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.35) !important; /* Amber glow */
    outline: none !important;
}

/* Global focus (purple box) - keep it subtle */
input:focus {
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2) !important;
    border-color: var(--accent-color) !important;
    outline: none !important;
}

.modified-btn, .modified-btn i {
    color: #f59e0b !important; /* amber/yellow */
}

/* SweetAlert2 style adjustments */
.swal2-popup {
    font-family: 'Outfit', sans-serif !important;
    border-radius: 1.25rem !important;
}
.swal2-title {
    font-weight: 800 !important;
}
.swal2-html-container {
    font-size: 0.95rem !important;
    line-height: 1.6 !important;
}

/* Segmented Control Adjustment */
.mode-toggle {
    margin-right: 4px;
}

/* Option Pills */
.option-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    border-radius: 99px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}

.option-pill .premium-switch {
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
}

.option-pill .switch-label {
    color: #64748b;
    transition: color 0.2s ease;
}

/* Separate Option Active */
.option-pill:has(#check-separate:checked) {
    background: #ecfdf5;
    border-color: #10b981;
}
.option-pill:has(#check-separate:checked) .switch-label {
    color: #065f46;
}
.option-pill:has(#check-separate:checked) .switch-track {
    background: #10b981;
}

/* Timeline Separate Mode Visual Feedback */
.timeline-track.separate-mode .segment-item {
    border-color: #10b981 !important;
    background-color: #ecfdf5 !important;
    border-width: 2px !important;
}

/* Speed Option Active */
.option-pill:has(#check-speed:checked) {
    background: #fff7ed;
    border-color: #f97316;
}
.option-pill:has(#check-speed:checked) .switch-label {
    color: #9a3412;
}
.option-pill:has(#check-speed:checked) .switch-track.speed-track {
    background: #f97316;
}
.option-pill:has(#check-speed:checked) #input-speed {
    border-color: #fdba74 !important;
    color: #9a3412 !important;
}
.option-pill:has(#check-speed:checked) .speed-unit-label {
    color: #9a3412 !important;
}

/* Speed Mode Specific Styles */
.speed-active-text {
    color: #c2410c !important; /* Orange-red for speed alert */
}

#input-speed:focus {
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2) !important;
}

