:root {
    --bg-main: #0f0f0f;
    --bg-surface: #1e1e1e;
    --bg-surface-hover: #272727;
    --bg-elevated: #282828;
    --border-color: #333333;
    --border-subtle: #222222;
    --text-main: #f1f1f1;
    --text-secondary: #aaaaaa;
    --text-muted: #717171;
    --primary: #ff0000;
    --primary-hover: #cc0000;
    --accent-red: #e63946;
    --success: #2ec4b6;
    --danger: #ef233c;
    --warning: #ffb703;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

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

/* NAVBAR */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background-color: var(--bg-main);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-logo, .logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-main);
    text-decoration: none;
}

.brand-logo .logo-icon, .logo .logo-icon {
    background: var(--primary);
    color: #fff;
    width: 32px;
    height: 24px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.logo-text {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
    color: #fff;
}

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

.nav-center {
    flex: 1;
    max-width: 600px;
    margin: 0 2rem;
}

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

.search-input-wrap {
    display: flex;
    flex: 1;
    position: relative;
}

.search-input-wrap input {
    width: 100%;
    background-color: #121212;
    border: 1px solid var(--border-color);
    border-right: none;
    border-top-left-radius: var(--radius-full);
    border-bottom-left-radius: var(--radius-full);
    padding: 0.6rem 1.2rem;
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-input-wrap input:focus {
    border-color: #1c62b9;
}

.btn-search {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-top-right-radius: var(--radius-full);
    border-bottom-right-radius: var(--radius-full);
    padding: 0 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.btn-search:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-main);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s, opacity 0.2s;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background-color: var(--bg-surface-hover);
}

.btn-upload {
    background-color: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}
.btn-upload:hover {
    background-color: var(--bg-surface-hover);
}

.btn-danger {
    background-color: rgba(239, 35, 60, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 35, 60, 0.3);
}
.btn-danger:hover {
    background-color: rgba(239, 35, 60, 0.25);
}

.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-main);
}
.btn-icon:hover, .btn-icon.active {
    background-color: var(--bg-surface);
}

/* USER DROPDOWN */
.user-menu-dropdown {
    position: relative;
}

.user-avatar-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    display: none;
    flex-direction: column;
    padding: 0.5rem 0;
    z-index: 200;
}

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

.dropdown-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    color: var(--text-main);
    transition: background-color 0.15s;
}

.dropdown-item:hover {
    background-color: var(--bg-surface-hover);
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-subtle);
    margin: 0.4rem 0;
}

.text-danger {
    color: var(--danger) !important;
}

/* MAIN CONTENT */
.main-container {
    flex: 1;
    padding: 1.5rem 2rem;
    max-width: 1800px;
    margin: 0 auto;
    width: 100%;
}

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

.video-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.thumbnail-wrapper, .thumbnail-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: #1a1a1a;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.thumbnail-wrapper img, .thumbnail-wrap img, .thumbnail-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease;
}

.video-card:hover .thumbnail-wrapper img,
.video-card:hover .thumbnail-wrap img,
.video-card:hover .thumbnail-img {
    transform: scale(1.03);
}

.thumbnail-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 2rem;
    background: #181818;
}

.duration-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.3px;
}

.badge-hdr {
    background: linear-gradient(135deg, #ffd166, #ff9f1c);
    color: #111;
    font-weight: 800;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.thumbnail-hdr-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: linear-gradient(135deg, #ffd166, #ff9f1c);
    color: #111;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: 3px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.video-info {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.channel-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.video-details {
    flex: 1;
    min-width: 0;
}

.video-title {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.25rem;
}

.channel-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 2px;
}

.video-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* WATCH PAGE LAYOUT */
.watch-container {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .watch-container {
        grid-template-columns: 1fr;
    }
}

.primary-content {
    min-width: 0;
}

.player-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.video-player {
    width: 100%;
    height: 100%;
    display: block;
    outline: none;
}

/* PLAYER QUALITY CONTROLS BAR */
.player-quality-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #141414;
    border: 1px solid var(--border-color);
    border-top: none;
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.quality-picker-wrapper {
    position: relative;
    display: inline-block;
}

.btn-quality-menu {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: var(--radius-full);
    padding: 0.35rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: background-color 0.15s;
}

.btn-quality-menu:hover {
    background-color: var(--bg-surface-hover);
}

.quality-menu-popup {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    min-width: 220px;
    display: none;
    flex-direction: column;
    padding: 0.4rem 0;
    z-index: 300;
}

.quality-menu-popup.show {
    display: flex;
}

.quality-menu-header {
    padding: 0.5rem 0.85rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    border-bottom: 1px solid var(--border-subtle);
}

.quality-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.85rem;
    font-size: 0.85rem;
    color: var(--text-main);
    cursor: pointer;
    transition: background-color 0.15s;
}

.quality-menu-item:hover {
    background-color: var(--bg-surface-hover);
}

.quality-menu-item.active {
    color: var(--primary);
    font-weight: 600;
}

.watch-header {
    margin-top: 1rem;
}

.watch-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.watch-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.uploader-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.uploader-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
}

.uploader-meta {
    display: flex;
    flex-direction: column;
}

.uploader-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.upload-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-pill-group {
    display: flex;
    align-items: center;
    background-color: var(--bg-surface);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.btn-pill {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 500;
    background: transparent;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    transition: background-color 0.15s;
}

.btn-pill:hover, .btn-pill.active {
    background-color: var(--bg-surface-hover);
}

.btn-pill.active {
    color: var(--primary);
}

.btn-pill-divider {
    width: 1px;
    height: 18px;
    background-color: var(--border-color);
}

/* DESCRIPTION BOX */
.description-card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    margin-top: 1rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.description-stats {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.description-text {
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
}

/* COMMENTS */
.comments-section {
    margin-top: 1.5rem;
}

.comments-header {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
}

.comment-form {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.comment-input-wrap {
    flex: 1;
}

.comment-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    padding: 0.4rem 0;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.comment-input:focus {
    border-color: var(--text-main);
}

.comment-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.comment-item {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.comment-body {
    flex: 1;
}

.comment-author {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.comment-author .comment-time {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.comment-text {
    font-size: 0.875rem;
    color: var(--text-main);
    line-height: 1.4;
}

/* SIDEBAR / UP NEXT */
.watch-sidebar {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.sidebar-video-card {
    display: flex;
    gap: 0.6rem;
    text-decoration: none;
    color: inherit;
}

.sidebar-thumb-wrap {
    position: relative;
    width: 140px;
    aspect-ratio: 16 / 9;
    background-color: #1a1a1a;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-details {
    flex: 1;
    min-width: 0;
}

.sidebar-title {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 3px;
}

.sidebar-channel, .sidebar-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* AUTH FORMS (LOGIN / REGISTER) */
.auth-wrapper {
    max-width: 420px;
    margin: 4rem auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.auth-header p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    background-color: #121212;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 0.7rem;
    font-size: 0.95rem;
}

/* ALERTS */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-danger {
    background-color: rgba(239, 35, 60, 0.15);
    border: 1px solid rgba(239, 35, 60, 0.4);
    color: #ff6b7b;
}

.alert-success {
    background-color: rgba(46, 196, 182, 0.15);
    border: 1px solid rgba(46, 196, 182, 0.4);
    color: #48e5d5;
}

/* UPLOAD PAGE */
.upload-container {
    max-width: 750px;
    margin: 1rem auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
}

.dropzone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    background: #161616;
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background-color: rgba(255, 0, 0, 0.05);
}

.dropzone-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.progress-wrap {
    margin-top: 1.5rem;
    display: none;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background-color: #222;
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--primary);
    width: 0%;
    transition: width 0.1s ease;
}

.progress-status {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* TABLES (ADMIN / MY VIDEOS) */
.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    text-align: left;
}

.data-table th {
    background-color: #151515;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.data-table tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-admin {
    background-color: rgba(230, 57, 70, 0.2);
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
}
