:root {
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --card-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-darker);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Glassmorphism */
.glass-header {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px); border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem; display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; z-index: 100;
}
.glass-card {
    background: var(--card-bg); backdrop-filter: blur(16px);
    border: 1px solid var(--border-color); border-radius: 1rem;
    padding: 1.5rem; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

/* Login Screen */
.login-container {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    display: flex; justify-content: center; align-items: center;
    background: var(--bg-darker); z-index: 1000; transition: opacity 0.5s ease;
}
.login-card { width: 100%; max-width: 400px; padding: 2.5rem; animation: fadeUp 0.5s ease-out; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* Header & Inputs */
.logo { display: flex; align-items: center; gap: 0.75rem; }
.logo h1 { font-size: 1.25rem; font-weight: 700; }
.gradient-text { background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.header-search { display: flex; gap: 0.5rem; width: 100%; max-width: 750px; align-items: center; }
.search-bar input {
    flex: 1; padding: 0.75rem 1rem; border-radius: 0.5rem;
    border: 1px solid var(--border-color); background: rgba(0,0,0,0.3); color: var(--text-main);
    transition: all 0.3s ease;
}
.search-bar input:focus { outline: none; border-color: var(--accent-primary); }
.vs-badge { font-weight: bold; color: var(--warning); background: rgba(245, 158, 11, 0.1); padding: 0.4rem; border-radius: 0.3rem;}

/* Buttons */
.btn-primary { background: var(--accent-gradient); color: white; border: none; padding: 0.75rem 1.5rem; border-radius: 0.5rem; font-weight: 600; cursor: pointer; transition: transform 0.2s, opacity 0.2s; }
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-gold { background: linear-gradient(135deg, #f59e0b, #d97706); }
.btn-purple { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.btn-secondary { background: rgba(255,255,255,0.1); color: var(--text-main); border: 1px solid var(--border-color); padding: 0.5rem 1rem; border-radius: 0.5rem; font-size: 0.875rem; cursor: pointer; transition: background 0.2s; }
.btn-secondary:hover { background: rgba(255,255,255,0.15); }

/* Dashboard Content */
.dashboard-content { padding: 2rem; max-width: 1300px; margin: 0 auto; }
.dashboard-actions { display: flex; gap: 1rem; margin-bottom: 2rem; justify-content: flex-end; }

/* Battle Section */
.battle-card { margin-bottom: 2rem; border: 1px solid var(--warning); background: rgba(245, 158, 11, 0.05); }
.battle-grid { display: flex; justify-content: space-around; align-items: center; margin-bottom: 1.5rem; }
.channel-col { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.channel-col img { width: 100px; height: 100px; border-radius: 50%; border: 3px solid var(--border-color); }
.vs-col { font-size: 3rem; font-weight: 900; color: var(--warning); opacity: 0.5; }
.verdict-box { background: rgba(0,0,0,0.3); padding: 1.5rem; border-radius: 0.5rem; border-left: 4px solid var(--warning); line-height: 1.6; }

/* Stats */
.top-stats { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 1.5rem; margin-bottom: 2rem; }
.channel-profile { display: flex; align-items: center; gap: 1.5rem; }
.channel-profile img { width: 80px; height: 80px; border-radius: 50%; border: 2px solid var(--accent-primary); }
.stat-card { display: flex; align-items: center; gap: 1.2rem; }
.stat-icon { font-size: 2.2rem; background: rgba(255,255,255,0.05); padding: 1rem; border-radius: 1rem; }
.stat-details h3 { color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; margin-bottom: 0.5rem; }
.stat-value { font-size: 2.5rem; font-weight: 700; }
.highlight-green { color: var(--success); }
.highlight-blue { color: var(--accent-primary); }

/* Table */
.videos-section { margin-top: 2rem; }
.section-header h2 { font-size: 1.5rem; margin-bottom: 1rem; }
.table-container { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 1.25rem 1rem; border-bottom: 1px solid var(--border-color); vertical-align: top; }
th { color: var(--text-muted); font-weight: 600; font-size: 0.875rem; text-transform: uppercase; background: rgba(0,0,0,0.2); }
tbody tr:hover { background: rgba(255,255,255,0.02); }
.video-cell { display: flex; gap: 1rem; }
.video-cell img { width: 150px; border-radius: 0.5rem; aspect-ratio: 16/9; object-fit: cover; }
.video-info h4 { font-size: 0.95rem; margin-bottom: 0.5rem; max-width: 300px; line-height: 1.4; }
.video-info p { font-size: 0.8rem; color: var(--text-muted); }

/* Badges & Scores */
.score-badge { display: inline-flex; align-items: center; justify-content: center; width: 45px; height: 45px; border-radius: 50%; font-weight: bold; font-size: 0.95rem; }
.score-high { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid var(--success); }
.score-med { background: rgba(245, 158, 11, 0.1); color: var(--warning); border: 1px solid var(--warning); }
.score-low { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid var(--danger); }
.perf-cell { display: flex; flex-direction: column; gap: 0.8rem; }
.perf-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 0.9rem; font-weight: 500; }

/* Modals */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); display: flex; justify-content: center; align-items: center; z-index: 1000; opacity: 1; transition: opacity 0.3s; }
.modal.hidden { opacity: 0; pointer-events: none; }
.modal-content { width: 95%; max-width: 1000px; max-height: 90vh; overflow-y: auto; position: relative; }
.close-btn { position: absolute; top: 1rem; right: 1.5rem; font-size: 2rem; cursor: pointer; color: var(--text-muted); }
.close-btn:hover { color: white; }

.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.modal-section { margin-top: 1.5rem; }
.modal-section h3 { margin-bottom: 1rem; color: var(--accent-primary); font-size: 1rem; }
.feedback-text { background: rgba(0,0,0,0.3); padding: 1rem; border-radius: 0.5rem; border-left: 3px solid var(--accent-primary); line-height: 1.5; font-size: 0.9rem; }

.optimized-list { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }
.optimized-list li { background: rgba(0,0,0,0.2); padding: 1rem; border-radius: 0.5rem; border: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.optimized-list p { font-weight: 500; font-size: 0.95rem; }

.textarea-container { position: relative; }
textarea { width: 100%; background: rgba(0,0,0,0.2); border: 1px solid var(--border-color); color: var(--text-main); padding: 1rem; border-radius: 0.5rem; resize: vertical; line-height: 1.5; }
.textarea-container .copy-btn { position: absolute; top: 0.5rem; right: 0.5rem; }

.tags-container { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag { background: rgba(59, 130, 246, 0.1); color: var(--accent-primary); padding: 0.35rem 0.75rem; border-radius: 1rem; font-size: 0.8rem; border: 1px solid rgba(59, 130, 246, 0.3); }

/* Ideas Gen */
.ideas-container { display: flex; flex-direction: column; gap: 1rem; }
.idea-card { background: rgba(0,0,0,0.3); padding: 1.5rem; border-radius: 0.5rem; border: 1px solid var(--warning); }
.idea-card h4 { color: var(--text-main); margin-bottom: 0.5rem; font-size: 1.1rem; }
.idea-card p { color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; }

.hidden { display: none !important; }
.spinner { width: 40px; height: 40px; border: 4px solid rgba(255,255,255,0.1); border-left-color: var(--accent-primary); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 1rem auto; }
@keyframes spin { 100% { transform: rotate(360deg); } }
#loadingState { text-align: center; margin-top: 4rem; color: var(--text-muted); }

/* PDF Output rules */
.pdf-container { background: var(--bg-darker); }
