/* ===== CSS Variables ===== */
:root {
    --primary-900: #0a0e1a;
    --primary-800: #0f1629;
    --primary-700: #151d38;
    --primary-600: #1a2547;
    --primary-500: #1e3a8a;
    --primary-400: #2563eb;
    --primary-300: #3b82f6;
    --accent-primary: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --white: #ffffff;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --container-max: 1400px;
    --header-height: 60px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--primary-900), var(--primary-800));
    color: var(--gray-200);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
}

img {
    max-width: 100%;
    display: block;
}

.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 16px;
}

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

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: rgba(10, 14, 26, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(59, 130, 246, 0.2);
    z-index: 1000;
    display: flex;
    align-items: center;
}

.header .container {
    display: flex;
    align-items: center;
    height: 100%;
    width: 100%;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.3rem;
    font-weight: 700;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-400), var(--primary-300));
    border-radius: var(--radius-md);
    font-size: 0.9rem;
}

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

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

/* Main */
.main {
    margin-top: var(--header-height);
    padding: 24px 0 60px;
    min-height: calc(100vh - var(--header-height) - 150px);
}

/* Video Grid - 2 columns x 10 rows = 20 cards */
.video-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (min-width: 640px) {
    .video-grid {
        gap: 16px;
    }
}

@media (min-width: 768px) {
    .video-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .video-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1280px) {
    .video-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Video Card - Compact */
.video-card {
    background: var(--primary-700);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--transition-normal);
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.video-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 20px var(--accent-glow);
    border-color: rgba(59, 130, 246, 0.3);
}

.video-thumbnail {
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: var(--primary-800);
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.video-card:hover .video-thumbnail img {
    transform: scale(1.08);
}

.video-duration {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.85);
    color: var(--white);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.video-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.video-card:hover .video-play-overlay {
    opacity: 1;
}

.play-icon {
    width: 44px;
    height: 44px;
    background: var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0.85);
    transition: transform var(--transition-fast);
}

.video-card:hover .play-icon {
    transform: scale(1);
}

.play-icon svg {
    width: 18px;
    height: 18px;
    color: var(--white);
    margin-left: 2px;
}

/* Compact video info */
.video-info {
    padding: 10px;
}

.video-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.video-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: var(--gray-400);
    margin-top: 4px;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--primary-600);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 40px;
    flex-wrap: wrap;
}

.pagination-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--primary-700);
    color: var(--white);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-numbers {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-num {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-700);
    color: var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.page-num:hover {
    background: var(--primary-600);
    color: var(--white);
}

.page-num.active {
    background: var(--accent-primary);
    color: var(--white);
    border-color: var(--accent-primary);
}

.page-dots {
    color: var(--gray-500);
    padding: 0 4px;
}

/* Footer */
.footer {
    background: var(--primary-900);
    border-top: 1px solid rgba(59, 130, 246, 0.2);
    padding: 30px 0 20px;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.footer-links {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.footer-links a {
    font-size: 0.85rem;
    color: var(--gray-400);
    transition: color var(--transition-fast);
}

.footer-links a:hover {
    color: var(--accent-primary);
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-bottom p {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.disclaimer-text {
    font-size: 0.75rem;
    color: var(--gray-600);
}

/* Age Modal */
.age-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.age-modal.hidden {
    display: none;
}

.age-modal-content {
    background: #1a2547;
    border-radius: 12px;
    padding: 20px;
    max-width: 300px;
    width: 90%;
    text-align: center;
    border: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
}

.age-modal-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.age-modal-content h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 8px;
}

.age-modal-content p {
    font-size: 0.95rem;
    color: var(--gray-300);
    margin-bottom: 12px;
}

.disclaimer-small {
    font-size: 0.8rem !important;
    color: var(--gray-500) !important;
}

.disclaimer-small a {
    color: var(--accent-primary);
}

.age-modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn-enter,
.btn-exit {
    flex: 1;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.btn-enter {
    background: linear-gradient(135deg, var(--accent-primary), var(--primary-400));
    color: var(--white);
}

.btn-enter:hover {
    opacity: 0.9;
}

.btn-exit {
    background: var(--primary-600);
    color: var(--gray-300);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-exit:hover {
    background: #ef4444;
    color: var(--white);
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.video-card {
    animation: fadeIn 0.4s ease forwards;
    opacity: 0;
}

.video-card:nth-child(1) {
    animation-delay: 0.02s;
}

.video-card:nth-child(2) {
    animation-delay: 0.04s;
}

.video-card:nth-child(3) {
    animation-delay: 0.06s;
}

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

.video-card:nth-child(5) {
    animation-delay: 0.1s;
}

.video-card:nth-child(6) {
    animation-delay: 0.12s;
}

/* ... existing styles ... */

/* Hero Section */
.hero {
    position: relative;
    padding: 120px 0 60px;
    background: radial-gradient(circle at top right, #1e3a8a 0%, #0a0e1a 40%);
    overflow: hidden;
    text-align: center;
}

.hero-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%233b82f6' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    z-index: 1;
    opacity: 0.5;
}

.hero-content {
    position: relative;
    z-index: 2;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 16px;
    letter-spacing: -1px;
    line-height: 1.2;
}

.text-gradient {
    background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--gray-400);
    max-width: 600px;
    margin: 0 auto 30px;
}

/* Connection Status */
.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f59e0b;
    /* Orange = Connecting */
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
    transition: all 0.3s ease;
}

.status-dot.online {
    background: #10b981;
    /* Green = Online */
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.status-dot.offline {
    background: #ef4444;
    /* Red = Offline */
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

@media (min-width: 768px) {
    .hero-title {
        font-size: 3.5rem;
    }
}

/* ===== Authentication Modal ===== */
.auth-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.auth-modal.hidden {
    display: none;
}

.auth-box {
    background: #1a2547;
    width: 100%;
    max-width: 400px;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(59, 130, 246, 0.2);
    position: relative;
}

.auth-close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
}

.auth-close:hover {
    color: white;
}

.auth-title {
    font-size: 1.5rem;
    color: white;
    margin-bottom: 20px;
    text-align: center;
}

.auth-form .form-group {
    margin-bottom: 15px;
}

.auth-form label {
    display: block;
    color: #9ca3af;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.auth-form input,
.upload-grid input[type="text"],
.upload-grid input[type="url"],
.upload-grid textarea,
.upload-grid select {
    width: 100%;
    padding: 12px 16px;
    background: #0f1629;
    border: 1px solid #2d3748;
    border-radius: 8px;
    color: white;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.auth-form input:focus,
.upload-grid input:focus,
.upload-grid textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    outline: none;
    background: #1a2547;
}

.form-group label {
    font-weight: 500;
    margin-bottom: 8px;
    display: block;
    color: #e2e8f0;
    font-size: 0.9rem;
}

.btn-auth {
    width: 100%;
    padding: 12px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 10px;
}

.btn-auth:hover {
    background: #2563eb;
}

.auth-switch {
    text-align: center;
    margin-top: 15px;
    color: #9ca3af;
    font-size: 0.9rem;
}

.auth-switch a {
    color: #3b82f6;
    cursor: pointer;
    text-decoration: underline;
}

/* ===== Dashboard Styles ===== */
.dashboard-container {
    max-width: 1000px;
    margin: 80px auto 40px;
    padding: 20px;
}

.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 1px solid #333;
    padding-bottom: 20px;
}

.dash-title {
    font-size: 1.8rem;
    color: white;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: #3b82f6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #1a2547;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: white;
}

.stat-label {
    color: #9ca3af;
}

/* Upload Form */
.upload-box {
    background: #1a2547;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 40px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.box-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.box-title {
    font-size: 1.2rem;
    color: white;
}

.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.full-width {
    grid-column: 1 / -1;
}

/* File Upload */
.file-upload-wrapper {
    position: relative;
    width: 100%;
}

.file-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #0f1629;
    border: 1px dashed #4b5563;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #9ca3af;
}

.file-label:hover {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.05);
    color: white;
}

.file-icon {
    font-size: 1.2rem;
}

.seo-tip {
    font-size: 0.8rem;
    color: #34d399;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Dashboard Video List */
.dash-video-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.dash-video-item {
    display: flex;
    flex-direction: row;
    /* Horizontal layout */
    align-items: center;
    background: #0f1629;
    padding: 12px;
    border-radius: 8px;
    gap: 15px;
    border: 1px solid #1f2937;
    transition: transform 0.2s;
}

.dash-video-item:hover {
    transform: translateY(-2px);
    border-color: #3b82f6;
}

.dash-thumb {
    width: 140px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.dash-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    /* Prevent flex overflow */
}

.dash-title-text {
    font-weight: 600;
    font-size: 1rem;
    color: white;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-meta {
    font-size: 0.8rem;
    color: #9ca3af;
}

/* Kebab Menu */
.menu-container {
    position: relative;
}

.menu-trigger {
    background: transparent;
    border: none;
    color: #9ca3af;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 8px;
    line-height: 1;
    transition: color 0.2s;
}

.menu-trigger:hover {
    color: white;
}

.menu-dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 6px;
    min-width: 140px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    z-index: 10;
    display: none;
    overflow: hidden;
}

.menu-dropdown.show {
    display: block;
}

.menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 16px;
    background: none;
    border: none;
    color: #e5e7eb;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.menu-item:hover {
    background: #374151;
}

.menu-item.text-red {
    color: #ef4444;
}

.menu-item.text-red:hover {
    background: rgba(239, 68, 68, 0.1);
}

.dash-actions {
    display: flex;
    gap: 8px;
    margin-top: 0;
    /* Reset margin */
    align-self: center;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 4px;
    cursor: pointer;
    border: none;
}

.btn-edit {
    background: #4b5563;
    color: white;
}

.btn-delete {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-delete:hover {
    background: #ef4444;
    color: white;
}

.btn-view {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.btn-view:hover {
    background: #3b82f6;
    color: white;
}

/* Nav Auth */
.nav-auth {
    margin-left: auto;
    display: flex;
    gap: 10px;
}

.auth-link {
    color: white;
    font-weight: 500;
    margin-left: 20px;
    cursor: pointer;
    transition: color 0.2s;
}

.auth-link:hover {
    color: #3b82f6;
}

.btn-header-login {
    padding: 8px 16px;
    background: #3b82f6;
    color: white;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-header-login:hover {
    background: #2563eb;
}

@media (max-width: 768px) {
    .upload-grid {
        grid-template-columns: 1fr;
    }

    /* Dash Video Item: Keep Horizontal on Mobile */
    .dash-video-item {
        padding: 10px;
        gap: 10px;
    }

    .dash-thumb {
        width: 100px;
        /* Smaller thumb on mobile */
        height: 60px;
    }

    .dash-title-text {
        font-size: 0.9rem;
    }

    .dash-actions {
        width: auto;
    }
}