/* --- Reset & Variables --- */
:root {
    --bg-color: #0f0f0f;
    --header-bg: #0f0f0f;
    --sidebar-bg: #0f0f0f;
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --border-color: #303030;
    --hover-bg: #272727;
    --icon-color: #ffffff;
    --search-bg: #121212;
    --search-border: #303030;
    --search-btn-bg: #222222;
    --scrollbar-track: #0f0f0f;
    --scrollbar-thumb: #717171;
    --red-color: #ff0000;
}

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

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}
/* ... */
.logo-text {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 20px;
    letter-spacing: -0.5px;
    color: #fff;
    position: relative;
    bottom: 0;
}
/* ... */
.search-box input {
    width: 100%;
    background-color: var(--search-bg);
    border: 1px solid var(--search-border);
    border-right: none;
    border-radius: 40px 0 0 40px;
    padding: 0 16px;
    height: 40px;
    color: var(--text-primary);
    font-size: 16px;
    font-family: 'Poppins', sans-serif;
}

/* Shorts Shelf Styles */
.shorts-shelf {
    margin-bottom: 40px;
    grid-column: 1 / -1;
}

.shorts-header {
    display: flex;
    align-items: center;
    margin-bottom: 24px;
    gap: 8px;
}

.shorts-icon {
    width: 24px;
    height: 24px;
    fill: var(--red-color);
}

.shorts-title {
    font-size: 20px;
    font-weight: 700;
}

.shorts-grid {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 16px;
}

.shorts-grid::-webkit-scrollbar {
    height: 8px;
}

.shorts-card {
    min-width: 160px;
    max-width: 210px;
    flex: 1;
    cursor: pointer;
}

.shorts-thumbnail {
    width: 100%;
    aspect-ratio: 9/16;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    margin-bottom: 12px;
}

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

.shorts-details h3 {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.shorts-views {
    font-size: 12px;
    color: var(--text-secondary);
}

button {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 8px;
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

/* --- Header --- */
.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 56px;
    background-color: var(--header-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    z-index: 1000;
}

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

.menu-btn {
    padding: 8px;
    border-radius: 50%;
}

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

.logo-container {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 18px 14px 18px 0;
}

.logo-text {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 20px;
    letter-spacing: -0.5px;
    color: #fff;
    position: relative;
    bottom: 0;
}

.header-center {
    display: flex;
    align-items: center;
    flex: 0 1 728px;
    gap: 16px;
}

.search-box {
    display: flex;
    flex: 1;
    align-items: center;
    margin-left: 40px;
}

.search-box input {
    width: 100%;
    background-color: var(--search-bg);
    border: 1px solid var(--search-border);
    border-right: none;
    border-radius: 40px 0 0 40px;
    padding: 0 16px;
    height: 40px;
    color: var(--text-primary);
    font-size: 16px;
    font-family: 'Poppins', sans-serif;
}

.search-box input:focus {
    outline: none;
    border-color: #1c62b9;
    margin-left: 0; /* Prevents layout shift */
}

.search-btn {
    height: 40px;
    width: 64px;
    background-color: var(--search-btn-bg);
    border: 1px solid var(--search-border);
    border-radius: 0 40px 40px 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.search-btn:hover {
    background-color: #3d3d3d;
}

.search-btn svg {
    fill: var(--text-primary);
}

.mic-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #181818;
    display: flex;
    justify-content: center;
    align-items: center;
}

.mic-btn:hover {
    background-color: #303030;
}

.mic-btn svg {
    fill: var(--text-primary);
}

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

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.icon-btn:hover {
    background-color: var(--hover-bg);
}

.icon-btn.active svg {
    fill: var(--text-primary);
    animation: pulse 0.3s ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.icon-btn svg {
    fill: var(--text-primary);
}

.avatar-btn {
    padding: 0 8px;
    margin-left: 8px;
}

.avatar-btn img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* --- Profile Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 3000;
    display: none;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.profile-modal {
    background-color: #282828; /* Dark mode card color */
    padding: 24px;
    border-radius: 12px;
    width: 400px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    color: var(--text-primary);
}

.close-modal-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
}

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

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 20px;
}

.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.input-group input {
    width: 100%;
    padding: 10px;
    background-color: #121212;
    border: 1px solid #3e3e3e;
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 16px;
}

.input-group input:focus {
    outline: none;
    border-color: #3ea6ff;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}

.action-btn {
    padding: 10px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.save-btn {
    background-color: #ffffff;
    color: #000000;
    font-weight: 700;
}

.save-btn:hover {
    background-color: #e0e0e0;
}

.login-btn {
    background-color: transparent;
    color: #ffffff;
    border: 2px solid #ffffff;
    font-weight: 700;
}

.login-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* --- Container --- */
.container {
    display: flex;
    margin-top: 56px;
    height: calc(100vh - 56px);
}

/* --- Sidebar --- */
.sidebar {
    width: 240px;
    background-color: var(--sidebar-bg);
    height: 100%;
    overflow-y: auto;
    position: fixed;
    left: 0;
    top: 56px;
    padding-right: 12px;
    transition: transform 0.2s ease;
}

/* Collapsed state logic handled via JS toggling classes or media queries */
.sidebar.collapsed {
    width: 72px;
    padding-right: 0;
}

.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .divider {
    display: none;
}

.sidebar.collapsed .sidebar-link {
    flex-direction: column;
    padding: 16px 0;
    gap: 6px;
    border-radius: 10px;
    margin: 0 4px;
    height: auto; /* Allow height to grow */
    justify-content: center;
}

.sidebar.collapsed .sidebar-link span {
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-section {
    padding: 12px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0 12px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    margin-bottom: 1px;
}

.sidebar-link:hover {
    background-color: var(--hover-bg);
}

.sidebar-link.active {
    background-color: var(--hover-bg);
    font-weight: 500;
}

.sidebar-link.active svg {
    fill: var(--text-primary);
}

.sidebar-link svg {
    margin-right: 24px;
    fill: var(--text-primary);
}

.sidebar.collapsed .sidebar-link svg {
    margin-right: 0;
    margin-bottom: 6px;
}

.sidebar-link span {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.sidebar-title {
    padding: 6px 12px;
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
}

.divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 12px 0;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    background-color: var(--bg-color);
    margin-left: 240px; /* Matches sidebar width */
    padding: 24px;
    overflow-y: auto;
}

/* Chips Bar */
.chips-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.chips-bar::-webkit-scrollbar {
    height: 0;
}

.chip {
    background-color: #272727;
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color 0.2s;
}

.chip:hover {
    background-color: #3f3f3f;
}

.chip.active {
    background-color: #f1f1f1;
    color: #0f0f0f;
}

/* --- Video Grid --- */
.video-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    row-gap: 40px;
}

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

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

.thumbnail-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.video-card:hover .thumbnail-container img {
    transform: scale(1.05); /* Slight scale effect */
    border-radius: 0; /* YouTube removes radius on hover sometimes, but keeping it looks cleaner. Let's stick to scale. */
}

.duration-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 3px 4px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.new-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background-color: rgba(204, 0, 0, 0.9);
    color: white;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    z-index: 10;
    transition: opacity 0.3s ease;
}

.video-card:hover .new-badge {
    opacity: 0;
}

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

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

.channel-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.video-details {
    display: flex;
    flex-direction: column;
}

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

.channel-name, .video-meta {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.3;
}

.channel-name:hover {
    color: var(--text-primary);
}

/* Shorts Shelf Styles */
.shorts-shelf {
    margin-bottom: 40px;
    grid-column: 1 / -1;
}

.shorts-header {
    display: flex;
    align-items: center;
    margin-bottom: 24px;
    gap: 8px;
}

.shorts-icon {
    width: 24px;
    height: 24px;
    fill: var(--red-color);
}

.shorts-title {
    font-size: 20px;
    font-weight: 700;
}

.shorts-grid {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 16px;
}

.shorts-grid::-webkit-scrollbar {
    height: 8px;
}

.shorts-card {
    min-width: 160px;
    max-width: 210px;
    flex: 1;
    cursor: pointer;
}

.shorts-thumbnail {
    width: 100%;
    aspect-ratio: 9/16;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    margin-bottom: 12px;
}

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

.shorts-details h3 {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.shorts-views {
    font-size: 12px;
    color: var(--text-secondary);
}

/* --- Responsiveness --- */

/* Large Screens (1400px+) - 4 columns (Default) */
@media (min-width: 1400px) {
    .video-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Medium Screens (1100px - 1399px) - 3 columns */
@media (max-width: 1399px) {
    .video-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Tablet Screens (768px - 1099px) - 2 columns */
@media (max-width: 1099px) {
    .video-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Auto collapse sidebar on smaller screens */
    .sidebar {
        width: 72px;
    }
    .sidebar-title, .divider {
        display: none;
    }
    .sidebar-link {
        flex-direction: column;
        padding: 16px 0;
        gap: 6px;
        justify-content: center;
    }
    .sidebar-link svg {
        margin-right: 0;
    }
    .sidebar-link span {
        font-size: 10px;
    }
    .main-content {
        margin-left: 72px;
    }
}

/* Mobile Screens (480px - 767px) - 1 column */
@media (max-width: 767px) {
    .video-grid {
        grid-template-columns: 1fr;
    }
    .header-center {
        display: none; /* Hide search bar on mobile for simplicity or replace with icon */
    }
    .header-right {
        margin-left: auto;
    }
    .sidebar {
        transform: translateX(-100%); /* Hide sidebar completely */
        width: 240px; /* Reset width for drawer mode */
        z-index: 1001;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
}

/* Small Mobile (<480px) */
@media (max-width: 480px) {
    .video-grid {
        grid-template-columns: 1fr;
    }
}
