:root {
    --primary-red: #CC0000;
    --primary-dark: #990000;
    --primary-light: #FF0000;
    --bg-primary: #0A0A0A;
    --bg-secondary: #141414;
    --bg-tertiary: #1F1F1F;
    --text-primary: #FFFFFF;
    --text-secondary: #B3B3B3;
    --text-tertiary: #666666;
    --border-color: #2A2A2A;
    --success-green: #00D084;
    --warning-yellow: #FFB800;
    --error-red: #FF3737;
    --gradient-primary: linear-gradient(135deg, #CC0000 0%, #FF0000 100%);
    --gradient-dark: linear-gradient(135deg, #0A0A0A 0%, #1F1F1F 100%);
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 40px rgba(204, 0, 0, 0.3);
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: radial-gradient(ellipse at top, #1a0000 0%, var(--bg-primary) 50%);
}

/* Header Styles */
.header {
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    animation: slideDown 0.5s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.cnn-logo {
    height: 35px;
    width: auto;
}

.divider {
    width: 1px;
    height: 40px;
    background: var(--border-color);
    display: none;
}

.app-title h1 {
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

/* Button Styles */
.btn-primary, .btn-secondary, .btn-tertiary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    border: none;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

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

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #2A2A2A;
    border-color: #3A3A3A;
}

.btn-tertiary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
}

.btn-tertiary:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 2rem;
    width: 100%;
}

/* Upload Section */
.upload-section {
    animation: fadeInUp 0.6s ease-out;
}

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

.upload-container {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.upload-area {
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    padding: 4rem 2rem;
    text-align: center;
    transition: all var(--transition-base);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.upload-area:hover {
    border-color: var(--primary-red);
    background: #1A1A1A;
    transform: scale(1.01);
}

.upload-area.drag-over {
    border-color: var(--primary-light);
    background: rgba(204, 0, 0, 0.1);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 4rem;
    color: var(--primary-red);
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.upload-area h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.upload-area p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.file-info {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    margin-bottom: 2rem;
}

.upload-btn {
    margin-top: 1rem;
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.feature-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    transform: scaleX(0);
    transition: transform var(--transition-base);
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-red);
}

.feature-card:hover::before {
    transform: scaleX(1);
}

.feature-icon {
    width: 60px;
    height: 60px;
    background: rgba(204, 0, 0, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    color: var(--primary-red);
}

.feature-icon .material-icons-round {
    font-size: 28px;
}

.feature-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.feature-card p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Processing Section */
.processing-section {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.processing-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: start;
}

.video-preview {
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.video-preview video {
    width: 100%;
    height: auto;
    display: block;
}

.processing-panel {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 2.5rem;
    box-shadow: var(--shadow-md);
}

.processing-header {
    margin-bottom: 2rem;
}

.processing-header h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.video-name {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.process-steps {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-bottom: 2rem;
}

.step {
    display: flex;
    gap: 1.5rem;
    opacity: 0.5;
    transition: opacity var(--transition-base);
}

.step.active {
    opacity: 1;
}

.step.completed .step-icon {
    background: var(--success-green);
    color: white;
}

.step-icon {
    width: 48px;
    height: 48px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-base);
}

.step-content {
    flex: 1;
}

.step-content h4 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.step-content p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.progress-bar {
    margin-top: 0.75rem;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    width: 0%;
    transition: width var(--transition-slow);
}

.ai-thinking {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.thinking-dot {
    width: 8px;
    height: 8px;
    background: var(--primary-red);
    border-radius: 50%;
    animation: thinking 1.4s ease-in-out infinite;
}

.thinking-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes thinking {
    0%, 60%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    30% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Results Section */
.results-container {
    animation: fadeInUp 0.6s ease-out;
}

.results-header {
    text-align: center;
    margin-bottom: 3rem;
}

.results-header h2 {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
}

.results-header p {
    color: var(--text-secondary);
    font-size: 1.125rem;
}

.results-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 3rem;
    margin-bottom: 3rem;
}

.thumbnail-preview {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.thumbnail-preview img {
    width: 100%;
    height: auto;
    display: block;
}

.thumbnail-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7), rgba(0,0,0,0.3));
    padding: 0.75rem;
    color: white;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.timestamp-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.results-panel {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.ai-explanation {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.75rem;
}

.ai-explanation h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--primary-red);
}

.ai-explanation p {
    color: var(--text-secondary);
    line-height: 1.7;
}

.thumbnail-options h3 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
}

.option-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.option-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--text-secondary);
}

.option-btn:hover {
    border-color: var(--primary-red);
    color: var(--text-primary);
}

.option-btn.active {
    background: rgba(204, 0, 0, 0.1);
    border-color: var(--primary-red);
    color: var(--primary-red);
}

.download-options {
    display: flex;
    gap: 1rem;
}

.download-btn {
    flex: 1;
}

.share-section {
    display: flex;
    gap: 1rem;
}

.share-section button {
    flex: 1;
}

.new-upload-section {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

/* Footer */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-left {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer-right {
    display: flex;
    gap: 1.5rem;
}

.tech-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 20px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.tech-icon {
    width: 20px;
    height: 20px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 3px solid var(--bg-tertiary);
    border-top: 3px solid var(--primary-red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .processing-container,
    .results-grid {
        grid-template-columns: 1fr;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
    }
    
    .logo-section {
        flex-direction: column;
    }
    
    .divider {
        width: 100px;
        height: 1px;
    }
    
    .option-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .download-options,
    .share-section {
        flex-direction: column;
    }
}

/* Animations for elements appearing */
.fade-in {
    animation: fadeIn 0.5s ease-out;
}

.slide-up {
    animation: slideUp 0.5s ease-out;
}

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

/* Thumbnail Grid Styles */
.thumbnails-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.thumbnail-option {
    position: relative;
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-secondary);
    transition: all var(--transition-base);
    border: 3px solid transparent;
}

.thumbnail-option:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.thumbnail-option.active {
    border-color: var(--primary-red);
}

.thumbnail-option.ai-recommended {
    border-color: #ffd700;
}

.thumbnail-option img {
    width: 100%;
    height: auto;
    display: block;
}

.ai-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--gradient-primary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    z-index: 2;
}

.rank-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    font-weight: bold;
    box-shadow: var(--shadow-md);
    z-index: 2;
}


.thumbnail-info .thumbnail-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.thumbnail-info .timestamp {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.selected-thumbnail-container {
    margin-top: 2rem;
    text-align: center;
}

.selected-thumbnail-container h3 {
    margin-bottom: 1rem;
}

.selected-thumbnail {
    max-width: 100%;
    max-height: 400px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
}

.ranking-notes {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-style: italic;
}

/* Action Buttons in Results */
.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

.action-buttons .btn-primary,
.action-buttons .btn-secondary {
    min-width: 200px;
}

.action-buttons .material-icons-round {
    font-size: 20px;
}

/* AI Analysis Section */
.ai-analysis-section {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.ai-analysis-section h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.ai-analysis-section .ai-explanation {
    color: var(--text-primary);
    line-height: 1.7;
    margin-bottom: 1rem;
    transition: opacity 0.3s ease;
}

.ai-analysis-section .ranking-notes {
    color: var(--text-secondary);
    line-height: 1.6;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
    margin-top: 1rem;
}

/* Ensure thumbnails grid shows properly */
.thumbnails-grid {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin: 2rem 0;
    width: 100%;
}

/* Ensure thumbnail options are visible */
.thumbnail-option {
    min-height: 150px;
    display: block !important;
}

/* Make thumbnails responsive */
@media (max-width: 1400px) {
    .thumbnails-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1000px) {
    .thumbnails-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .thumbnails-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* AI Mode Toggle Styles */
.ai-mode-toggle {
    margin-top: 2rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #3a3a3a;
    transition: .4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: #CC0000;
}

input:checked + .toggle-slider:before {
    transform: translateX(28px);
}

.toggle-label h4 {
    margin: 0;
    font-size: 1rem;
    color: #ffffff;
}

.toggle-label p {
    margin: 0;
    font-size: 0.875rem;
    color: #999;
}

.mode-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.mode-info span {
    color: #CC0000;
    font-size: 1.25rem;
}

.mode-info p {
    margin: 0;
    font-size: 0.875rem;
    color: #e3e3e3;
    flex: 1;
}

