/* Custom Design System & CSS Variables */
:root {
    --bg-primary: #0b0c10;
    --bg-secondary: #12131a;
    --panel-bg: rgba(26, 29, 41, 0.65);
    --panel-border: rgba(255, 255, 255, 0.07);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent-red: #ff3e3e;
    --accent-red-hover: #e52e2e;
    --accent-blue: #6366f1;
    --accent-blue-glow: rgba(99, 102, 241, 0.4);
    --accent-green: #10b981;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --border-radius: 16px;
    --max-width: 1200px;
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    padding: 2rem 1rem;
}

/* Background Glowing Orb Effects */
.background-glow {
    position: fixed;
    top: -10%;
    left: 50%;
    transform: translateX(-50%);
    width: 80vw;
    height: 50vh;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(255, 62, 62, 0.05) 50%, rgba(0,0,0,0) 100%);
    filter: blur(80px);
    z-index: -1;
    pointer-events: none;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Header Styles */
.app-header {
    text-align: center;
    margin-top: 1rem;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    font-size: 2.5rem;
    color: var(--accent-red);
    filter: drop-shadow(0 0 12px rgba(255, 62, 62, 0.6));
}

.logo h1 {
    font-family: var(--font-heading);
    font-size: 2.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #ffffff 40%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo h1 span {
    color: var(--accent-red);
    -webkit-text-fill-color: initial;
    background: none;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 400;
}

/* Glassmorphic Panel Base */
.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--border-radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    transition: transform var(--transition-fast), border-color var(--transition-fast);
}

/* Input Section */
.input-section {
    padding: 1.5rem;
}

.search-form {
    display: flex;
    gap: 1rem;
    width: 100%;
}

.input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 1.25rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.search-form input {
    width: 100%;
    padding: 1.1rem 1.25rem 1.1rem 3rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    outline: none;
    transition: all var(--transition-fast);
}

.search-form input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 15px var(--accent-blue-glow);
    background: rgba(15, 23, 42, 0.85);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.1rem 2rem;
    border: none;
    border-radius: 12px;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-red) 0%, #d32f2f 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 62, 62, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 62, 62, 0.45);
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    border-radius: 8px;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--accent-green) !important;
    color: white !important;
}

/* Error Container */
.error-panel {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-left: 4px solid var(--accent-red);
    background: rgba(254, 226, 226, 0.05);
}

.error-icon {
    font-size: 1.5rem;
    color: var(--accent-red);
}

#error-message {
    flex: 1;
    color: #fecaca;
    font-weight: 500;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.close-btn:hover {
    color: var(--text-primary);
}

/* Dashboard Layout */
.dashboard {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 900px) {
    .dashboard {
        grid-template-columns: 320px 1fr;
    }
}

/* Sidebar Styles */
.sidebar {
    padding: 1.5rem;
    height: fit-content;
}

.video-card {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.thumbnail-wrapper {
    position: relative;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16/9;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.thumbnail-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-normal);
}

.thumbnail-wrapper:hover img {
    transform: scale(1.03);
}

.play-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 62, 62, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    box-shadow: 0 0 15px rgba(255, 62, 62, 0.6);
    pointer-events: none;
}

.video-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.video-meta h2 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.4;
}

.channel-name {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
}

.stats {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.stat-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* Content Area & Summary Result */
.content {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 1rem;
    gap: 1rem;
}

.content-header h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
}

.markdown-body {
    font-size: 1.05rem;
    color: var(--text-primary);
    overflow-y: auto;
    max-height: 60vh;
    padding-right: 0.5rem;
}

/* Markdown styling inside content */
.markdown-body h1, 
.markdown-body h2, 
.markdown-body h3 {
    font-family: var(--font-heading);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: #ffffff;
}

.markdown-body h1 { font-size: 1.4rem; }
.markdown-body h2 { font-size: 1.25rem; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 0.25rem; }
.markdown-body h3 { font-size: 1.1rem; }

.markdown-body p {
    margin-bottom: 1rem;
    color: #cbd5e1;
}

.markdown-body ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.markdown-body li {
    margin-bottom: 0.5rem;
    color: #cbd5e1;
}

.markdown-body strong {
    color: #ffffff;
    font-weight: 600;
}

/* Custom Scrollbar */
.markdown-body::-webkit-scrollbar {
    width: 6px;
}

.markdown-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.markdown-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.markdown-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Skeleton Loading Animation */
.shimmer {
    position: relative;
    overflow: hidden;
}

.shimmer::after {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    background-image: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.05) 20%,
        rgba(255, 255, 255, 0.1) 60%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: loading-shimmer 2s infinite;
    content: '';
}

@keyframes loading-shimmer {
    100% {
        transform: translateX(100%);
    }
}

.skeleton {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    margin-bottom: 1rem;
}

.skeleton-img {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 12px;
}

.skeleton-title {
    height: 24px;
    width: 80%;
}

.skeleton-header {
    height: 32px;
    width: 40%;
    margin-bottom: 2rem;
}

.skeleton-text {
    height: 16px;
    width: 100%;
}

.skeleton-text.short {
    width: 60%;
}

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

/* History Panel Styling */
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 0.75rem;
}

.history-header h3 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 600;
    color: #ffffff;
}

.btn-delete-all {
    background: none;
    border: none;
    color: var(--accent-red);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background var(--transition-fast);
}

.btn-delete-all:hover {
    background: rgba(255, 62, 62, 0.1);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.history-list::-webkit-scrollbar {
    width: 4px;
}

.history-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

.history-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    cursor: pointer;
    position: relative;
    transition: all var(--transition-fast);
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.history-item.active {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.3);
}

.history-item-thumb {
    width: 60px;
    aspect-ratio: 16/9;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.history-item-info {
    flex: 1;
    min-width: 0;
}

.history-item-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-channel {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-delete-item {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    opacity: 0;
    transition: all var(--transition-fast);
}

.history-item:hover .btn-delete-item {
    opacity: 1;
}

.btn-delete-item:hover {
    color: var(--accent-red);
    background: rgba(255, 62, 62, 0.1);
}

.history-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary);
}

.history-empty .empty-icon {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.history-empty p {
    font-size: 0.85rem;
}

/* Empty State Styling */
.empty-state-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 350px;
    text-align: center;
    padding: 2rem;
}

.empty-state-content {
    max-width: 450px;
    margin: auto;
}

.empty-magic-icon {
    font-size: 3rem;
    color: var(--accent-blue);
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 0 15px var(--accent-blue-glow));
    animation: pulse 3s infinite ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.08); opacity: 1; }
}

.empty-state-content h2 {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #ffffff 50%, #6366f1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.empty-state-content p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Active Video Header */
.active-video-header {
    display: flex;
    gap: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--panel-border);
    margin-bottom: 1.5rem;
}

.header-thumbnail {
    width: 180px;
    aspect-ratio: 16/9;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.header-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.header-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.5rem;
}

.header-info h2 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.3;
    color: #ffffff;
}

.header-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.header-meta span, .header-meta .stat-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* Mobile Adjustments */
@media (max-width: 900px) {
    .history-list {
        max-height: 250px;
    }
    .active-video-header {
        flex-direction: column;
        gap: 1rem;
    }
    .header-thumbnail {
        width: 100%;
        max-width: 320px;
    }
}

@media (max-width: 600px) {
    body {
        padding: 1rem 0.5rem;
    }
    
    .logo h1 {
        font-size: 2.2rem;
    }
    
    .search-form {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .content {
        padding: 1.25rem;
    }
}

/* Header Logout Button */
.app-header {
    position: relative;
}

.btn-logout {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all var(--transition-fast);
}

.btn-logout:hover {
    background: rgba(255, 62, 62, 0.15);
    border-color: rgba(255, 62, 62, 0.3);
    color: #ff3e3e;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 62, 62, 0.15);
}

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

@media (max-width: 600px) {
    .btn-logout {
        position: relative;
        top: 0;
        right: 0;
        margin-top: 1rem;
        width: 100%;
        justify-content: center;
    }
}

/* Login Page Styles */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.login-wrapper {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.login-header {
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-header .logo {
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.login-header .logo-icon {
    font-size: 3rem;
    margin-bottom: 0.25rem;
}

.login-header .logo h1 {
    font-size: 2.2rem;
    text-align: center;
    line-height: 1.25;
}

.login-header .logo h1 span {
    display: block;
    margin-top: 0.25rem;
}

.login-card {
    padding: 2.5rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.login-card input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    outline: none;
    transition: all var(--transition-fast);
}

.login-card input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 15px var(--accent-blue-glow);
    background: rgba(15, 23, 42, 0.85);
}

.btn-block {
    width: 100%;
}

.login-error-msg {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.1rem;
    border-radius: 10px;
    background: rgba(255, 62, 62, 0.1);
    border: 1px solid rgba(255, 62, 62, 0.25);
    color: #fecaca;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}
