:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #14141c;
    --bg-card: #1a1a25;
    --bg-card-hover: #20202e;
    --border: #2a2a3a;
    --text-primary: #f5f5f7;
    --text-secondary: #a0a0b0;
    --text-muted: #6b6b80;
    --accent: #ff0033;
    --accent-glow: rgba(255, 0, 51, 0.4);
    --positive: #22c55e;
    --neutral: #facc15;
    --negative: #ef4444;
    --radius: 14px;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

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

html, body {
    min-height: 100vh;
}

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

body::before {
    content: '';
    position: fixed;
    top: -200px;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 800px;
    background: radial-gradient(
        circle,
        rgba(255, 0, 51, 0.18) 0%,
        rgba(255, 0, 51, 0.06) 30%,
        transparent 60%
    );
    pointer-events: none;
    z-index: 0;
}

.container {
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 60px 24px 80px;
}

/* ===== HEADER ===== */
.header {
    text-align: center;
    margin-bottom: 48px;
    animation: fadeDown 0.6s ease;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.logo-icon {
    width: 56px;
    height: 40px;
    background: var(--accent);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 30px var(--accent-glow);
}

.logo-icon::after {
    content: '';
    border-style: solid;
    border-width: 9px 0 9px 14px;
    border-color: transparent transparent transparent #fff;
    margin-left: 3px;
}

.logo-text {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo-text span {
    color: var(--accent);
}

h1 {
    font-size: clamp(32px, 5vw, 48px);
    font-weight: 800;
    letter-spacing: -1.5px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #fff 0%, #a0a0b0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 17px;
    max-width: 540px;
    margin: 0 auto;
}

/* ===== SEARCH FORM ===== */
.search-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    margin: 0 auto 32px;
    max-width: 640px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 8px;
    animation: fadeUp 0.6s ease 0.1s backwards;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-card:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow), var(--shadow);
}

.search-card input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    padding: 14px 18px;
}

.search-card input::placeholder {
    color: var(--text-muted);
}

.info-trigger {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
    width: 100%;
    max-width: 640px;
    margin: 0 auto 10px;
    padding: 6px 4px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
}

.info-trigger:hover {
    color: var(--accent);
    text-decoration: underline;
}

.info-trigger svg {
    color: var(--accent);
}

/* ===== TOGGLE / SWITCH ===== */
.toggle-card {
    max-width: 640px;
    margin: -14px auto 32px;
    animation: fadeUp 0.6s ease 0.22s backwards;
}

.toggle-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.toggle-field:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.toggle-label svg {
    color: var(--accent);
}

.switch {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}

.switch-track {
    display: inline-block;
    width: 46px;
    height: 26px;
    border-radius: 999px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    transition: background 0.2s, border-color 0.2s;
}

.switch-thumb {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform 0.2s, background 0.2s;
}

.switch input:checked + .switch-track {
    background: var(--accent);
    border-color: var(--accent);
}

.switch input:checked + .switch-track .switch-thumb {
    transform: translateX(20px);
    background: #fff;
}

.switch input:focus-visible + .switch-track {
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.toggle-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
    padding: 0 4px;
    line-height: 1.45;
}

.btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 12px 26px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    background: #e6002e;
    box-shadow: 0 6px 20px var(--accent-glow);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* ===== ERROR ===== */
.error {
    max-width: 640px;
    margin: 0 auto 32px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    padding: 14px 18px;
    border-radius: 10px;
    text-align: center;
    font-size: 15px;
    animation: fadeUp 0.4s ease;
}

/* ===== LOADING ===== */
.loading {
    display: none;
    text-align: center;
    padding: 60px 20px;
}

.loading.active {
    display: block;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}

.loading-text {
    color: var(--text-secondary);
    font-size: 15px;
}

/* ===== RESULTS ===== */
.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 48px 0 24px;
    animation: fadeUp 0.5s ease;
}

.results-header h2 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.results-count {
    color: var(--text-secondary);
    font-size: 14px;
    background: var(--bg-card);
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
}

.videos {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 20px;
}

.video-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    animation: fadeUp 0.5s ease backwards;
}

.video-card:nth-child(2) { animation-delay: 0.08s; }
.video-card:nth-child(3) { animation-delay: 0.16s; }
.video-card:nth-child(4) { animation-delay: 0.24s; }

.video-card:hover {
    transform: translateY(-4px);
    border-color: #3a3a4d;
    box-shadow: var(--shadow);
}

.thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
    overflow: hidden;
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s;
}

.video-card:hover .thumb img {
    transform: scale(1.04);
}

.thumb-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        transparent 50%,
        rgba(0, 0, 0, 0.6) 100%
    );
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 12px;
}

.play-link {
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s, transform 0.2s, background 0.2s;
}

.video-card:hover .play-link {
    opacity: 1;
    transform: translateY(0);
}

.play-link:hover {
    background: #e6002e;
}

.card-body {
    padding: 18px 20px 20px;
}

.video-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.35;
    margin-bottom: 14px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 44px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 18px;
}

.stat {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 10px 8px;
    text-align: center;
}

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

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* ===== SENTIMENTS ===== */
.sentiment-section {
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.sentiment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.sentiment-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.sentiment-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
}

.badge-positive {
    background: rgba(34, 197, 94, 0.15);
    color: var(--positive);
}

.badge-negative {
    background: rgba(239, 68, 68, 0.15);
    color: var(--negative);
}

.badge-neutral {
    background: rgba(250, 204, 21, 0.15);
    color: var(--neutral);
}

.sentiment-bar {
    display: flex;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--bg-secondary);
    margin-bottom: 12px;
}

.bar-positive { background: var(--positive); }
.bar-neutral  { background: var(--neutral); }
.bar-negative { background: var(--negative); }

.sentiment-legend {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 6px 10px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.legend-item:hover:not(:disabled) {
    background: var(--bg-secondary);
    border-color: var(--border);
    color: var(--text-primary);
}

.legend-item:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.legend-item.active {
    background: var(--bg-secondary);
    border-color: var(--border);
    color: var(--text-primary);
}

.legend-item.active.legend-positive { border-color: var(--positive); }
.legend-item.active.legend-neutral  { border-color: var(--neutral); }
.legend-item.active.legend-negative { border-color: var(--negative); }

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-positive { background: var(--positive); }
.dot-neutral  { background: var(--neutral); }
.dot-negative { background: var(--negative); }

/* ===== CHARTS SECTION ===== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
    animation: fadeUp 0.5s ease;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 22px 18px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chart-card:hover {
    border-color: #3a3a4d;
    box-shadow: var(--shadow);
}

.chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.chart-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.2px;
    margin-bottom: 4px;
}

.chart-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.chart-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}

.chart-image {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: zoom-in;
    transition: background 0.2s;
}

.chart-image:hover {
    background: #1c1c28;
}

.chart-image img {
    width: 100%;
    height: auto;
    display: block;
    pointer-events: none;
}

.chart-zoom-hint {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.chart-image:hover .chart-zoom-hint {
    opacity: 1;
}

/* ===== LIGHTBOX MODAL ===== */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 10, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-content {
    position: relative;
    max-width: min(1400px, 95vw);
    max-height: 90vh;
    transform: scale(0.96);
    transition: transform 0.25s ease;
}

.lightbox.active .lightbox-content {
    transform: scale(1);
}

.lightbox-content img {
    display: block;
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    background: var(--bg-card);
    padding: 24px;
}

.lightbox-close {
    position: absolute;
    top: -14px;
    right: -14px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.15s, border-color 0.15s;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.lightbox-close:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(1.08);
}

body.lightbox-open {
    overflow: hidden;
}

@media (max-width: 600px) {
    .lightbox { padding: 20px; }
    .lightbox-content img { padding: 14px; border-radius: 10px; }
    .lightbox-close { top: -10px; right: -10px; width: 36px; height: 36px; }
}

/* ===== COMMENTS PANEL ===== */
.comments-panel {
    margin-top: 14px;
    border-top: 1px solid var(--border);
    padding-top: 14px;
    display: none;
    animation: fadeUp 0.25s ease;
}

.comments-panel.active {
    display: block;
}

.comments-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 6px;
}

.comments-list::-webkit-scrollbar { width: 6px; }
.comments-list::-webkit-scrollbar-track { background: transparent; }
.comments-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
.comments-list::-webkit-scrollbar-thumb:hover {
    background: #3a3a4d;
}

.comment {
    background: var(--bg-secondary);
    border-left: 3px solid transparent;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
}

.comment.positive { border-left-color: var(--positive); }
.comment.neutral  { border-left-color: var(--neutral); }
.comment.negative { border-left-color: var(--negative); }

.comment-author {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.comment-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.comments-empty {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    padding: 12px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    animation: fadeUp 0.5s ease 0.2s backwards;
}

.empty-icon {
    font-size: 48px;
    opacity: 0.4;
    margin-bottom: 16px;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    .container { padding: 32px 16px 60px; }
    .search-card { flex-direction: column; padding: 12px; }
    .search-card input { padding: 12px 14px; }
    .btn { justify-content: center; }
    .videos { grid-template-columns: 1fr; }
    .results-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .toggle-field { flex-direction: row; align-items: center; }
}
