:root {
    --bg-dark: #0a0a0a;
    --bg-panel: #161616;
    --text-main: #ffffff;
    --text-muted: #888888;
    --accent-primary: #ffffff;
    --accent-blue: #3ea6ff;
    --accent-green: #2ba640;
    --accent-gold: #ffd700;
    --accent-purple: #c084fc;
    --border: #2a2a2a;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    margin: 0;
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* SIDEBAR */
aside {
    width: 300px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 10;
    overflow-y: auto;
    flex-shrink: 0;
}

/* LOGO AREA */
.brand {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: space-between;

    p {
        padding: 0;
        margin: 0;
    }

    .login-button {
        --size: 2.4rem;
        --bdrs: .5rem;
        
        border: 1px solid var(--border);
        height: var(--size);
        width: var(--size);
        justify-content: center;
        align-items: center;
        display: flex;
        -webkit-border-radius: var(--bdrs);
        -moz-border-radius: var(--bdrs);
        border-radius: var(--bdrs);
        transition: .2s ease-in-out;
        cursor: pointer;
        user-select: none;

        &:hover {
            border: 1px solid #444;
        }
    }

    img {
        height: 1.8rem;
    }
}

.brand span {
    color: var(--text-muted);
    font-weight: 400;
}

.input-group {
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="password"], input[type="text"] {
    background: #000;
    border: 1px solid var(--border);
    color: #fff;
    padding: 12px;
    border-radius: 8px;
    font-family: monospace;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.2s;
    font-size: 1rem;
    font-weight: 300;
}

input[type="submit"] {
    background: var(--accent-blue);
    border: 1px solid var(--border);
    color: #fff;
    padding: 10px 12px;
    border-radius: 8px;
    box-sizing: border-box;
    transition: border-color 0.2s;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 1.2rem;
}

textarea {
    width: 100%;
    background: #000;
    border: 1px solid var(--border);
    color: #fff;
    padding: 12px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.85rem;
    resize: vertical;
    min-height: 150px;
    white-space: pre;
    overflow-x: auto;
    line-height: 1.5;
    box-sizing: border-box;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
}

button.primary-btn {
    width: 100%;
    padding: 14px;
    background-color: var(--text-main);
    color: #000;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
}

button.primary-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* STATUS LOG */
#statusLog {
    font-family: monospace;
    font-size: 0.75rem;
    color: #666;
    white-space: pre-wrap;
    height: 100px;
    overflow-y: auto;
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* MAIN CONTENT */
main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

header {
    padding: 20px 40px;
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 5;
    flex-shrink: 0;
}

.header-title {
    font-size: 1.2rem;
    font-weight: 700;
}

.header-stats {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* AI BUTTON */
.ai-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(118, 75, 162, 0.3);
    transition: transform 0.2s;
}

.ai-btn:hover {
    transform: scale(1.02);
}

select.time-filter {
    background: var(--bg-panel);
    color: white;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    margin-left: 15px;
    outline: none;
}

/* SCROLL AREA */
.scroll-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 40px;
    display: flex;
    flex-direction: column;
}

/* AI RESULT PANEL */
#aiResultPanel {
    background: #1a1a1a;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent-purple);
    padding: 24px;
    margin-bottom: 40px;
    border-radius: 12px;
    display: none;
    animation: slideDown 0.3s ease-out;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    box-sizing: border-box;
}

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

#aiText {
    line-height: 1.7;
    color: #e0e0e0;
    font-size: 1rem;
    white-space: pre-wrap;
}

#aiText strong {
    color: var(--accent-purple);
}

/* GRID - FIXED ALIGNMENT */
.grid {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    padding-bottom: 80px;
    /* Changed from center to flex-start for left-to-right alignment */
    justify-content: flex-start;
}

/* CARD STYLES */
.card {
    background: #000;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: 320px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-4px);
    border-color: #444;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.thumb-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 177.77%;
    background: #111;
    cursor: pointer;
}

.thumb-wrapper img, .thumb-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: none;
}

.overlay-badges {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
}

.badge-outlier {
    background: var(--accent-green);
    color: #000;
    padding: 6px 10px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.85rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.badge-lov {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.85);
    color: var(--accent-gold);
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.85rem;
    border: 1px solid #444;
    pointer-events: none;
}

.play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.play-btn::after {
    content: "▶";
    color: white;
    font-size: 1.8rem;
    margin-left: 5px;
}

.card-data {
    padding: 16px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
}

.channel-title {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 6px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.video-title {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 16px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.8em;
    color: #fff;
}

.metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.metric-box {
    background: #222;
    padding: 8px 12px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.m-head {
    color: #666;
    font-size: 0.7rem;
    text-transform: uppercase;
    margin-bottom: 4px;
    font-weight: 600;
}

.m-val {
    font-size: 0.9rem;
    font-weight: 700;
    font-family: monospace;
}

.c-blue {
    color: var(--accent-blue);
}

.c-white {
    color: white;
}

.c-purp {
    color: var(--accent-purple);
}

.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    width: 100%;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #333;
    border-top: 3px solid var(--text-main);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.mobile-nav-hamburger {
    --hamburger-height: 1.0rem;
    --hamburger-width: 1.5rem;
    --hamburger-thickness: 2px;

    position: absolute;
    /* top: calc(calc(var(--header-height) / 2 - 1.4rem) - calc(var(--hamburger-height) / 2)); */
    right: 5vw;
    width: var(--hamburger-width);
    height: var(--hamburger-height);
    z-index: 2000;
    display: none;

    @media screen and (max-width: 900px) {
        display: block;
    }
}

.hamburger-relative {
    position: relative;
    height: 100%;
    width: 100%;
}

.hamburger-line {
    width: var(--hamburger-width);
    height: var(--hamburger-thickness);
    background-color: #fafafa;
    position: absolute;
    top: calc(calc(var(--hamburger-height) / 2) - calc(var(--hamburger-thickness) / 2));
    border-radius: calc(var(--hamburger-thickness) / 2);
    transition: all .5s ease;
}

.mobile-nav-hamburger .line-top {
    transform: translateY(calc(calc(var(--hamburger-thickness) / 2) - calc(var(--hamburger-height) / 2)));
}

.mobile-nav-hamburger .line-bottom {
    transform: translateY(calc(calc(var(--hamburger-height) / 2) - calc(var(--hamburger-thickness) / 2)));
}

.mobile-nav-hamburger.toggled .line-top {
    transform: rotate(45deg);
}

.mobile-nav-hamburger.toggled .line-bottom {
    transform: rotate(-45deg);
}

.mobile-nav-hamburger.toggled .line-center {
    opacity: 0;
}

.aside-mobile-shown {
    display: flex;
    position: fixed;
    top: attr(data-header px);
    left: 0;
    width: 100vw;
    height: calc(100dvh - attr(data-header px));
    box-sizing: border-box;
    background: #060606;
}

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