/* ===================================================
   YouTube 2015 - Estilos principales
   =================================================== */

:root {
    --yt-red: #cc0000;
    --yt-red-hover: #aa0000;
    --yt-blue: #065fd4;
    --yt-blue-hover: #054aba;
    --text-primary: #212121;
    --text-secondary: #757575;
    --text-link: #065fd4;
    --border-color: #e0e0e0;
    --bg-main: #f1f1f1;
    --bg-white: #ffffff;
    --bg-hover: #f5f5f5;
    --bg-active: #e8e8e8;
    --header-height: 56px;
    --sidebar-width: 226px;
    --sidebar-mini: 72px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
    --shadow-md: 0 2px 6px rgba(0,0,0,.1), 0 1px 4px rgba(0,0,0,.07);
}

/* ===== RESET ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; }
body {
    font-family: 'Roboto', Arial, sans-serif;
    color: var(--text-primary);
    background: var(--bg-main);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
ul { list-style: none; }
img { display: block; max-width: 100%; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #bbb; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #999; }

/* ===================================================
   HEADER / TOP BAR
   =================================================== */
.top-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px 0 16px;
    z-index: 1000;
    gap: 8px;
}

/* Logo */
.top-bar-left { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.menu-button {
    width: 40px; height: 40px;
    border: none; background: none;
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 18px;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.menu-button:hover { background: var(--bg-hover); }

.logo {
    display: flex; align-items: center; gap: 4px;
    text-decoration: none;
    padding: 4px;
}
.yt-logo-icon { width: 36px; height: 26px; }
.logo-text {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-primary);
    font-family: 'Roboto', Arial, sans-serif;
}

/* Búsqueda */
.search-container { flex: 1; max-width: 620px; min-width: 0; }
.search-form { display: flex; height: 34px; }
.search-input {
    flex: 1;
    border: 1px solid #ccc;
    border-right: none;
    border-radius: 2px 0 0 2px;
    padding: 0 10px;
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    background: #fff;
    min-width: 0;
    transition: border-color .15s, box-shadow .15s;
}
.search-input:focus {
    border-color: #1c62b9;
    box-shadow: inset 0 1px 2px rgba(0,0,0,.1);
}
.search-button {
    width: 62px;
    background: #f8f8f8;
    border: 1px solid #ccc;
    border-left: none;
    border-radius: 0 2px 2px 0;
    color: var(--text-secondary);
    font-size: 15px;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.search-button:hover { background: #ececec; border-color: #bbb; }

/* Top-right buttons */
.top-bar-right { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }

.icon-button {
    width: 40px; height: 40px;
    border: none; background: none;
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.icon-button:hover { background: var(--bg-hover); }

.user-avatar {
    width: 32px; height: 32px;
    background: #9e9e9e;
    border-radius: 50%;
    color: #fff;
    font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    margin-left: 4px;
    overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ===================================================
   LAYOUT PRINCIPAL
   =================================================== */
.main-layout {
    display: flex;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    position: relative;
}

/* ===================================================
   SIDEBAR IZQUIERDO
   =================================================== */
.sidebar-left {
    width: var(--sidebar-width);
    background: var(--bg-white);
    border-right: 1px solid var(--border-color);
    height: calc(100vh - var(--header-height));
    position: sticky;
    top: var(--header-height);
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    transition: width .2s ease, transform .2s ease;
}

.sidebar-left.mini {
    width: var(--sidebar-mini);
}

/* Nav items */
.nav-section { padding: 8px 0; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 24px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    border-radius: 0;
    transition: background .12s;
    user-select: none;
}
.nav-item i {
    width: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 16px;
    flex-shrink: 0;
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active {
    background: var(--bg-active);
    font-weight: 500;
}
.nav-item.active i { color: var(--yt-red); }

/* Mini mode */
.sidebar-left.mini .nav-item {
    justify-content: center;
    padding: 14px 0;
    flex-direction: column;
    gap: 4px;
    font-size: 10px;
}
.sidebar-left.mini .nav-item i { font-size: 18px; margin: 0; }
.sidebar-left.mini .category-title,
.sidebar-left.mini .login-prompt,
.sidebar-left.mini .sidebar-footer,
.sidebar-left.mini .nav-bottom { display: none; }

.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
}

.category-title {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 10px 24px 4px;
}

/* Login prompt */
.login-prompt { padding: 16px 24px; }
.login-prompt p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
}
.login-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 7px 14px;
    background: none;
    border: 1px solid var(--yt-blue);
    border-radius: 2px;
    color: var(--yt-blue);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    transition: background .15s;
}
.login-button:hover { background: #e8f0fe; }

/* Footer del sidebar */
.sidebar-footer {
    padding: 12px 24px 16px;
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.8;
}
.footer-links a { color: var(--text-secondary); margin-right: 2px; }
.footer-links a:hover { color: var(--text-primary); }
.footer-copy { margin-top: 6px; }

/* Overlay móvil */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
}
.sidebar-overlay.active { display: block; }

/* ===================================================
   CONTENIDO PRINCIPAL
   =================================================== */
.main-content {
    flex: 1;
    padding: 24px 24px 40px;
    min-width: 0;
}

.section-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

/* ===================================================
   VIDEO GRID
   =================================================== */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
}

/* ===================================================
   VIDEO CARD
   =================================================== */
.video-card {
    background: var(--bg-white);
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
    box-shadow: var(--shadow-sm);
}
.video-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.video-card-thumbnail {
    position: relative;
    aspect-ratio: 16/9;
    background: #e0e0e0;
    overflow: hidden;
}
.video-card-thumbnail img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform .2s;
}
.video-card:hover .video-card-thumbnail img { transform: scale(1.04); }

.video-duration {
    position: absolute;
    bottom: 6px; right: 6px;
    background: rgba(0,0,0,.82);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 5px;
    border-radius: 2px;
    letter-spacing: .3px;
    pointer-events: none;
}

.video-card-details {
    display: flex;
    padding: 10px;
    gap: 10px;
}

.channel-avatar-small {
    width: 34px; height: 34px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: #e0e0e0;
    cursor: pointer;
}
.channel-avatar-small img {
    width: 100%; height: 100%; object-fit: cover;
}
.channel-avatar-small .avatar-placeholder {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}

.video-info { flex: 1; min-width: 0; }

.video-card .video-title {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 4px;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-channel {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}
.video-channel:hover { color: var(--text-primary); }

.video-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===================================================
   ESTADOS: LOADING / ERROR / EMPTY
   =================================================== */
.state-box {
    grid-column: 1/-1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--text-secondary);
    text-align: center;
    gap: 14px;
}
.state-box i { font-size: 48px; }
.state-box p { font-size: 14px; line-height: 1.5; }
.state-box.error i { color: #f44336; }
.state-spinner { font-size: 32px; color: var(--yt-red); animation: spin 1s linear infinite; }

.retry-button {
    margin-top: 8px;
    padding: 9px 22px;
    background: var(--yt-blue);
    color: #fff;
    border: none;
    border-radius: 2px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: .5px;
    display: inline-flex; align-items: center; gap: 8px;
    transition: background .15s;
}
.retry-button:hover { background: var(--yt-blue-hover); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ===================================================
   PAGINACIÓN
   =================================================== */
.pagination {
    grid-column: 1/-1;
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}
.pagination-btn {
    padding: 8px 18px;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    font-size: 13px;
    color: var(--text-primary);
    display: inline-flex; align-items: center; gap: 8px;
    transition: all .15s;
}
.pagination-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: #aaa;
}
.pagination-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ===================================================
   RESPONSIVE
   =================================================== */
@media (max-width: 900px) {
    .sidebar-left {
        position: fixed;
        top: var(--header-height);
        left: 0;
        height: calc(100vh - var(--header-height));
        z-index: 1000;
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform .2s ease;
    }
    .sidebar-left.open { transform: translateX(0); }
    .sidebar-left.mini { width: var(--sidebar-width); }
}

@media (max-width: 600px) {
    .logo-text { display: none; }
    .top-bar { padding: 0 8px; }
    .main-content { padding: 16px; }
    .video-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
}