:root {
    --bg-color: #f9f9f9;
    --header-bg: #ffffff;
    --sidebar-bg: #ffffff;
    --text-primary: #0f0f0f;
    --text-secondary: #606060;
    --border-color: #e5e5e5;
    --hover-bg: #f2f2f2;
    --primary-red: #cc0000;
    --primary-red-hover: #b30000;
    --card-bg: #ffffff;
    --input-border: #cccccc;
    --input-focus: #1c62b9;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.1);
    --shadow-md: 0 10px 30px rgba(0,0,0,0.10);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    
    --header-height: 56px;
    --sidebar-width: 220px;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #181818;
        --header-bg: #202020;
        --sidebar-bg: #202020;
        --text-primary: #ffffff;
        --text-secondary: #aaaaaa;
        --border-color: #303030;
        --hover-bg: #383838;
        --card-bg: #202020;
        --input-border: #404040;
        --input-focus: #3ea6ff;
    }
}

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

body {
    font-family: Roboto, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    padding-top: var(--header-height); /* Space for fixed header */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Utility Classes */
.container {
    max-width: 100%;
    margin: 0 auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    height: 36px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
    text-transform: none;
}
.btn:active { transform: translateY(1px); }

.btn.primary {
    background-color: var(--primary-red);
    color: white;
}
.btn.primary:hover {
    background-color: var(--primary-red-hover);
    box-shadow: var(--shadow-sm);
}
.btn.primary:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.btn.secondary {
    color: #065fd4;
    background: transparent;
}
.btn.secondary:hover {
    background-color: rgba(6, 95, 212, 0.1);
}

.btn.danger {
    color: var(--primary-red);
    border: 1px solid var(--border-color);
    background: transparent;
}
.btn.danger:hover {
    background-color: rgba(204, 0, 0, 0.1);
}

/* HEADER */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--header-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-icon {
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.18s ease, transform 0.18s ease;
}
.menu-icon:hover {
    background-color: var(--hover-bg);
}
.menu-icon:active { transform: scale(0.96); }

.logo {
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 4px;
    letter-spacing: -0.5px;
}
.logo span {
    color: var(--primary-red);
}

.header-center {
    flex: 1;
    max-width: 600px;
    margin: 0 20px;
    display: none; /* Hidden on mobile */
}
@media (min-width: 600px) {
    .header-center { display: flex; }
}

.search-bar {
    display: flex;
    width: 100%;
}
.search-input {
    flex: 1;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border-color);
    border-right: none;
    background-color: var(--bg-color);
    color: var(--text-primary);
    border-radius: 2px 0 0 2px;
}
.search-btn {
    width: 64px;
    height: 36px;
    background-color: var(--hover-bg);
    border: 1px solid var(--border-color);
    cursor: pointer;
    border-radius: 0 2px 2px 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-icon {
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
}
.header-icon:hover {
    background-color: var(--hover-bg);
}

/* LAYOUT GRID */
.app-layout {
    display: flex;
    min-height: calc(100vh - var(--header-height));
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    padding: 10px 0;
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    overflow-y: auto;
    display: block;
    z-index: 900;
    border-right: 1px solid var(--border-color);
    box-shadow: 0 10px 24px rgba(0,0,0,0.08);
    transform: translateX(-110%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s ease, opacity 0.22s ease;
}

@media (min-width: 1024px) {
    .sidebar {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }
    .main-content {
        margin-left: var(--sidebar-width);
    }
    .watch-content {
        /* Watch page usually has no sidebar or different layout */
        margin-left: 0; 
    }
}

.sidebar-backdrop {
    position: fixed;
    inset: var(--header-height) 0 0 0;
    background: rgba(0,0,0,0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    z-index: 850;
}

body.sidebar-open .sidebar {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
}

.nav-text { display: inline; }

@media (min-width: 768px) and (max-width: 1023px) {
    :root { --sidebar-width: 84px; }
    .sidebar {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }
    .main-content { margin-left: var(--sidebar-width); }
    .nav-text { display: none; }
    .nav-item { justify-content: center; }
    .nav-icon { margin-right: 0; }
}

@media (min-width: 768px) {
    .sidebar-backdrop { display: none; }
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0 12px;
    height: 42px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    margin: 4px 8px;
    border-radius: 10px;
    gap: 10px;
    transition: background-color 0.18s ease, transform 0.18s ease;
}
.nav-item:hover {
    background-color: var(--hover-bg);
}
.nav-item.active {
    background-color: var(--hover-bg);
    font-weight: 500;
}
.nav-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

/* MAIN CONTENT */
.main-content {
    flex: 1;
    padding: 20px;
    width: 100%;
}

/* VIDEO GRID */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    row-gap: 40px;
}

.video-card {
    display: flex;
    flex-direction: column;
    background-color: transparent;
    cursor: pointer;
}

.thumbnail-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    background-color: #000;
    overflow: hidden;
    border-radius: 12px;
    margin-bottom: 12px;
}

.thumbnail-wrapper img, 
.thumbnail-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-info {
    display: flex;
    gap: 12px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #ccc;
    flex-shrink: 0;
}

.video-details {
    flex: 1;
    overflow: hidden;
}

.video-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.2;
}

.video-meta {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* WATCH PAGE */
.watch-container {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px;
}

.watch-primary {
    flex: 1;
    min-width: 0; /* Fix flex overflow */
    min-width: 640px;
}

.watch-secondary {
    width: 400px;
    flex-shrink: 0;
}

@media (max-width: 1000px) {
    .watch-primary { min-width: 100%; }
    .watch-secondary { width: 100%; }
}

.player-container {
    width: 100%;
    background: #000;
    aspect-ratio: 16/9;
    margin-bottom: 20px;
}
.player-container video {
    width: 100%;
    height: 100%;
}

.watch-info h1 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 10px;
}

.watch-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
    margin-bottom: 16px;
}

.desc-box {
    background: var(--hover-bg);
    padding: 12px;
    border-radius: 12px;
    font-size: 14px;
    white-space: pre-wrap;
}

/* Related Videos (Sidebar style) */
.related-video-card {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    cursor: pointer;
}
.related-thumb {
    width: 168px;
    height: 94px;
    background: #000;
    border-radius: 8px;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}
.related-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.related-info h3 {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.related-info p {
    font-size: 12px;
    color: var(--text-secondary);
}


/* FORMS & UPLOAD */
.upload-container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: 8px;
    padding: 0; /* padding handled by children */
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}
.upload-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.upload-body {
    padding: 24px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
}

.input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin-bottom: 16px;
    font-size: 14px;
}
.input:focus {
    border-color: var(--input-focus);
    outline: none;
}

/* UPLOAD QUEUE */
.upload-queue {
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}
.queue-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    margin-bottom: 8px;
    border-radius: 4px;
}
.queue-info {
    flex: 1;
}
.queue-name {
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 4px;
}
.queue-status {
    font-size: 12px;
    color: var(--text-secondary);
}
.progress-bar-wrap {
    width: 100px;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-left: 12px;
}
.progress-bar {
    height: 100%;
    background: #065fd4;
    width: 0%;
    transition: width 0.3s;
}
.status-icon {
    margin-left: 12px;
    font-size: 16px;
}

/* ALERTS */
.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 24px;
    font-size: 14px;
}
.alert.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.alert.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* PAGINATION */
.pagination {
    margin-top: 40px;
    display: flex;
    justify-content: center;
    gap: 10px;
    align-items: center;
}
.page-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    background-color: var(--card-bg);
}
.page-btn:hover {
    background-color: var(--hover-bg);
}

/* EMPTY STATE */
.empty-state {
    text-align: center;
    padding: 60px 0;
    color: var(--text-secondary);
}

/* LOGIN / CENTERED CARD */
.centered-layout {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - var(--header-height));
    background-color: var(--bg-color);
}
.login-card {
    background: var(--card-bg);
    padding: 40px; /* Mais espaçoso */
    border-radius: 8px;
    width: 100%;
    max-width: 450px;
    border: 1px solid var(--border-color);
    text-align: center;
}
.login-card h1 {
    margin-bottom: 24px;
    font-weight: 500;
}
.login-card .logo-big {
    font-size: 40px;
    margin-bottom: 16px;
    color: var(--primary-red);
}

/* ADMIN PANEL SPECIFIC */
.admin-table-row {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}
.admin-table-row:last-child {
    border-bottom: none;
}
.admin-thumb {
    width: 120px;
    margin-right: 16px;
    border-radius: 4px;
    overflow: hidden;
}
.admin-thumb video {
    width: 100%;
    vertical-align: middle;
}
.admin-info {
    flex: 1;
}
.admin-actions {
    margin-left: 16px;
}
