/* ===================================================
   YouTube 2015 - Estilos principales (revisado)
   =================================================== */

:root {
  --yt-red:          #cc0000;
  --yt-red-hover:    #aa0000;
  --yt-blue:         #065fd4;
  --yt-blue-hover:   #054aba;
  --text-primary:    #212121;
  --text-secondary:  #606060;   /* 2015 usa un gris más oscuro que #757575 */
  --text-link:       #065fd4;
  --border-color:    #e0e0e0;
  --bg-main:         #f9f9f9;   /* 2015 es casi blanco, no gris */
  --bg-white:        #ffffff;
  --bg-hover:        #f2f2f2;
  --bg-active:       #e8e8e8;
  --header-height:   56px;
  --sidebar-width:   210px;     /* 2015 sidebar era más angosto */
  --sidebar-mini:    68px;
  --shadow-sm:       0 1px 2px rgba(0,0,0,.1);
  --shadow-md:       0 2px 4px rgba(0,0,0,.12);
}

/* ===== RESET ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 13px; }   /* 2015 usaba 13px base */
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: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c6c6c6; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0a0a0; }

/* ===================================================
   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 #ddd;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 12px;
  z-index: 1000;
  gap: 8px;
}

/* Logo */
.top-bar-left { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.menu-button {
  width: 38px; height: 38px;
  border: none; background: none;
  color: #c11212;
  font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.menu-button:hover { background: var(--bg-hover); }

.logo {
  display: flex; align-items: center;
  text-decoration: none; padding: 4px 4px;
  flex-shrink: 0;
  height: 38px;
}

/* Logo wordmark estilo 2015 */
.yt-logo-2015 {
  height: 28px;
  width: auto;
}

/* Mantener compatibilidad si alguien usa el ícono viejo */
.yt-logo-icon { width: 32px; height: 22px; }
.logo-text {
  font-size: 18px; font-weight: 700;
  letter-spacing: -0.5px; color: #282828;
}

/* Búsqueda — más angosta y cuadrada como 2015 */
.search-container { flex: 1; max-width: 580px; min-width: 0; }
.search-form { display: flex; height: 32px; }
.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;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.07);
  transition: border-color .15s, box-shadow .15s;
}
.search-input:focus {
  border-color: #1565c0;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.12);
}
.search-button {
  width: 56px;
  background: #f8f8f8;
  border: 1px solid #ccc;
  border-left: 1px solid #d4d4d4;
  border-radius: 0 2px 2px 0;
  color: #606060;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.search-button:hover { background: #ececec; }

/* Top-right */
.top-bar-right { display: flex; align-items: center; gap: 1px; flex-shrink: 0; }

.icon-button {
  width: 38px; height: 38px;
  border: none; background: none;
  border-radius: 50%;
  color: #606060;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.icon-button:hover { background: var(--bg-hover); }

.user-avatar {
  width: 30px; height: 30px;
  background: #9e9e9e;
  border-radius: 50%;
  color: #fff;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  margin-left: 6px;
  overflow: hidden;
}

/* ===================================================
   LAYOUT PRINCIPAL
   =================================================== */
.main-layout {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

/* ===================================================
   SIDEBAR IZQUIERDO — fiel al 2015
   =================================================== */
.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: 6px 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 7px 20px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  transition: background .12s;
  user-select: none;
  border-left: 3px solid transparent;   /* indicador activo 2015 */
}
.nav-item i {
  width: 18px;
  text-align: center;
  color: #606060;
  font-size: 15px;
  flex-shrink: 0;
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active {
  background: #f0f0f0;
  font-weight: 500;
  border-left-color: var(--yt-red);
}
.nav-item.active i { color: var(--yt-red); }

/* Mini mode */
.sidebar-left.mini .nav-item {
  justify-content: center;
  padding: 12px 0;
  flex-direction: column;
  gap: 3px;
  font-size: 10px;
  border-left: none;
}
.sidebar-left.mini .nav-item i { font-size: 17px; }
.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: 6px 0;
}

.category-title {
  font-size: 11px;
  font-weight: 500;
  color: #909090;
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 10px 20px 4px;
}

/* Login prompt */
.login-prompt { padding: 12px 20px; }
.login-prompt p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 10px;
}
.login-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 6px 12px;
  background: none;
  border: 1px solid var(--yt-blue);
  border-radius: 2px;
  color: var(--yt-blue);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  transition: background .15s;
}
.login-button:hover { background: #e8f0fe; }

/* Footer del sidebar */
.sidebar-footer {
  padding: 10px 20px 14px;
  font-size: 11px;
  color: #aaa;
  line-height: 1.9;
}
.footer-links a { color: #aaa; margin-right: 2px; }
.footer-links a:hover { color: var(--text-secondary); }
.footer-copy { margin-top: 4px; }

/* 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: 20px 20px 40px;
  min-width: 0;
}

.section-title {
  font-size: 13px;
  font-weight: 500;
  color: #909090;
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: .7px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

/* ===================================================
   VIDEO GRID — más columnas, cards más compactas
   =================================================== */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px 12px;
}

/* ===================================================
   VIDEO CARD — fiel al 2015
   =================================================== */
.video-card {
  background: transparent;   /* 2015 no tenía fondo en las cards */
  border-radius: 0;
  overflow: hidden;
  cursor: pointer;
  transition: opacity .15s;
}
.video-card:hover { opacity: .9; }

/* Thumbnail */
.video-card-thumbnail {
  position: relative;
  aspect-ratio: 16/9;
  background: #e0e0e0;
  overflow: hidden;
  margin-bottom: 8px;
}
.video-card-thumbnail img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .2s;
  display: block;
}
.video-card:hover .video-card-thumbnail img { transform: scale(1.03); }

.video-duration {
  position: absolute;
  bottom: 4px; right: 4px;
  background: rgba(0,0,0,.85);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 1px 4px;
  border-radius: 2px;
  letter-spacing: .2px;
  pointer-events: none;
}

/* Detalles debajo del thumb */
.video-card-details {
  display: flex;
  gap: 8px;
  padding: 0;
}

.channel-avatar-small {
  width: 32px; height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: #e0e0e0;
  cursor: pointer;
  margin-top: 1px;
}
.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: 13px; 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.35;
  margin-bottom: 3px;
  color: #212121;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-card:hover .video-title { color: var(--yt-blue); }

.video-channel {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  cursor: pointer;
}
.video-channel:hover { color: #212121; }

.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: 13px; line-height: 1.5; }
.state-box.error i { color: #f44336; }
.state-spinner { font-size: 28px !important; color: var(--yt-red); animation: spin 1s linear infinite; }

.retry-button {
  margin-top: 8px;
  padding: 8px 20px;
  background: var(--yt-blue);
  color: #fff;
  border: none;
  border-radius: 2px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .5px;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .15s;
}
.retry-button:hover { background: var(--yt-blue-hover); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===================================================
   PAGINACIÓN
   =================================================== */
.pagination {
  grid-column: 1/-1;
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
}
.pagination-btn {
  padding: 7px 16px;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 2px;
  font-size: 12px;
  color: var(--text-primary);
  display: inline-flex; align-items: center; gap: 7px;
  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: 1200px) {
  .video-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}

@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); }
  .video-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px 10px; }
}

@media (max-width: 600px) {
  .logo-text { display: none; }
  .top-bar { padding: 0 6px; }
  .main-content { padding: 14px 12px 40px; }
  .video-grid { grid-template-columns: repeat(2, 1fr); gap: 10px 8px; }
  .icon-button:not(:last-child) { display: none; }
}

@media (max-width: 380px) {
  .video-grid { grid-template-columns: 1fr; }
}