/* ============================================
   SPAGOCCiTube — Main Styles
   ============================================ */

:root {
  --bg: #0f0f0f;
  --bg2: #181818;
  --bg3: #222222;
  --border: #2a2a2a;
  --text: #f1f1f1;
  --text2: #aaaaaa;
  --text3: #717171;
  --accent: #ff3c00;
  --accent2: #ff6b35;
  --header-h: 60px;
  --sidebar-w: 220px;
  --radius: 10px;
  --font-display: 'Bebas Neue', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  min-height: 100vh;
}

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

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 3px; }

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

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
}

.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-radius: 50%;
  transition: background 0.2s;
}
.hamburger:hover { background: var(--bg3); }
.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

.logo { display: flex; align-items: center; }
.logo-text {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 1px;
  color: var(--text);
  line-height: 1;
}
.logo-accent { color: var(--accent); }

.header-center { flex: 1; max-width: 600px; }

.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 24px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.search-bar:focus-within { border-color: var(--accent); }
.search-bar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  padding: 10px 16px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
}
.search-bar input::placeholder { color: var(--text3); }
.search-btn {
  background: var(--bg3);
  border: none;
  border-left: 1px solid var(--border);
  padding: 10px 16px;
  color: var(--text2);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.search-btn:hover { background: var(--border); color: var(--text); }

.header-right { display: flex; align-items: center; gap: 8px; min-width: 120px; justify-content: flex-end; }

.admin-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 24px;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}
.admin-btn:hover { background: var(--bg2); color: var(--text); border-color: var(--text3); }

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  background: var(--bg);
  padding: 16px 0;
  overflow-y: auto;
  z-index: 90;
  transform: translateX(0);
  transition: transform 0.25s ease;
}

.sidebar.hidden { transform: translateX(-100%); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text2);
  font-weight: 400;
  transition: all 0.15s;
  cursor: pointer;
}
.sidebar-item:hover { background: var(--bg3); color: var(--text); }
.sidebar-item.active { background: var(--bg3); color: var(--text); font-weight: 500; }

/* ============================================
   MAIN
   ============================================ */
.main {
  margin-top: var(--header-h);
  margin-left: var(--sidebar-w);
  padding: 0 24px 40px;
  min-height: calc(100vh - var(--header-h));
  transition: margin-left 0.25s ease;
}

.main.no-sidebar { margin-left: 0; }

/* ============================================
   CHANNEL BANNER
   ============================================ */
.channel-banner {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.channel-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 28px;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  transition: box-shadow 0.2s;
}

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

/* Overlay modifica avatar visibile solo quando è admin */
.channel-avatar.is-admin {
  cursor: pointer;
}
.channel-avatar.is-admin::after {
  content: '✏️';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  opacity: 0;
  transition: opacity 0.2s;
}
.channel-avatar.is-admin:hover::after { opacity: 1; }

.channel-meta-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

/* Search bar inline vicino al contatore video */
.channel-search-bar {
  display: flex;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.channel-search-bar:focus-within { border-color: var(--accent); }
.channel-search-bar input {
  background: none;
  border: none;
  outline: none;
  padding: 7px 12px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  width: 180px;
}
.channel-search-bar input::placeholder { color: var(--text3); }
.channel-search-bar .search-btn {
  background: var(--bg3);
  border: none;
  border-left: 1px solid var(--border);
  padding: 7px 12px;
  color: var(--text2);
  cursor: pointer;
  transition: background 0.2s;
}
.channel-search-bar .search-btn:hover { background: var(--border); color: var(--text); }

.channel-name {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: 1px;
  line-height: 1;
  margin-bottom: 6px;
}

.channel-meta { color: var(--text2); font-size: 13px; margin-bottom: 2px; }
.channel-handle { color: var(--text3); font-size: 12px; }

/* ============================================
   TABS
   ============================================ */
.tabs-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  padding: 0;
}

.tab {
  background: none;
  border: none;
  color: var(--text2);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s;
}
.tab:hover { color: var(--text); background: var(--bg2); }
.tab.active { color: var(--text); border-bottom-color: var(--text); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================
   SECTION HEADER
   ============================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.5px;
}

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

.shorts-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

/* ============================================
   VIDEO CARD
   ============================================ */
.video-card {
  cursor: pointer;
  border-radius: var(--radius);
  overflow: hidden;
  background: transparent;
  transition: transform 0.2s;
}
.video-card:hover { transform: translateY(-2px); }
.video-card:hover .video-thumb img { opacity: 0.85; }

.video-thumb {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  background: var(--bg3);
  border-radius: var(--radius);
  overflow: hidden;
}
.shorts-grid .video-thumb { padding-bottom: 177.78%; }

.video-thumb img {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transition: opacity 0.2s;
}

.video-thumb-placeholder {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
}

.play-overlay {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 48px; height: 48px;
  background: rgba(0,0,0,0.8);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}
.video-card:hover .play-overlay { transform: translate(-50%, -50%) scale(1); }

.duration-badge {
  position: absolute;
  bottom: 6px; right: 6px;
  background: rgba(0,0,0,0.85);
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.video-info { padding: 10px 4px 4px; }

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

.video-meta {
  font-size: 12px;
  color: var(--text3);
  display: flex;
  gap: 6px;
}

/* ============================================
   PLAYLIST GRID
   ============================================ */
.playlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.playlist-card {
  cursor: pointer;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg2);
  border: 1px solid var(--border);
  transition: border-color 0.2s, transform 0.2s;
}
.playlist-card:hover { border-color: var(--accent); transform: translateY(-2px); }

.playlist-thumb {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  background: var(--bg3);
  overflow: hidden;
}
.playlist-thumb img { position: absolute; top:0;left:0;width:100%;height:100%;object-fit:cover; }
.playlist-count {
  position: absolute;
  top: 0; right: 0;
  background: rgba(0,0,0,0.85);
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.playlist-info { padding: 12px; }
.playlist-name { font-weight: 600; margin-bottom: 4px; }
.playlist-meta { font-size: 12px; color: var(--text3); }

/* ============================================
   LOADING STATE
   ============================================ */
.loading-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--text3);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}
.empty-state svg { opacity: 0.3; margin-bottom: 12px; }

/* ============================================
   VIDEO MODAL
   ============================================ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal-content {
  background: var(--bg2);
  border-radius: 12px;
  width: 100%;
  max-width: 860px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  border: 1px solid var(--border);
}

.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  background: var(--bg3);
  border: none;
  color: var(--text);
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s;
}
.modal-close:hover { background: var(--border); }

.video-player-wrapper {
  width: 100%;
  padding-bottom: 56.25%;
  position: relative;
  background: #000;
  border-radius: 12px 12px 0 0;
  overflow: hidden;
}
.video-player-wrapper iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

.modal-info { padding: 20px; }
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.modal-meta { font-size: 13px; color: var(--text3); margin-bottom: 10px; }
.modal-desc { font-size: 14px; color: var(--text2); line-height: 1.6; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main { margin-left: 0; padding: 0 12px 40px; }
  .header-center { display: none; }
  .video-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .channel-banner { padding: 16px 0; }
  .channel-name { font-size: 22px; }
  .channel-avatar { width: 60px; height: 60px; font-size: 22px; }
  .channel-search-bar input { width: 130px; }
}

/* ============================================
   SPAGOCCiTube v2 — Stili aggiuntivi
   ============================================ */

/* ---- SIDEBAR DIVIDER ---- */
.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 14px;
}

/* ---- VIDEO ROW (stile YouTube, scroll orizzontale) ---- */
.video-row {
  margin-bottom: 36px;
}

.video-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.show-all-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text3);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
}
.show-all-btn:hover { color: var(--text); border-color: var(--text3); }

.video-row-scroll {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

/* Quando "mostra tutti" è attivo, mostra tutto in griglia normale */
.video-row-scroll.expanded {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.shorts-row {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

/* Thumb verticale per shorts */
.short-thumb {
  padding-bottom: 177.78% !important;
}

/* ---- DRAG HANDLE ---- */
.drag-handle {
  font-size: 18px;
  color: var(--text3);
  cursor: grab;
  padding: 0 8px;
  flex-shrink: 0;
  user-select: none;
}
.drag-handle:active { cursor: grabbing; }

.drag-item {
  transition: border-color 0.15s, opacity 0.15s;
}
.drag-item[draggable="true"]:active { opacity: 0.6; }

/* ============================================
   SPAGOCCiTube v2 — Layout aggiornato
   ============================================ */

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

.header-left { display: flex; align-items: center; min-width: 80px; }
.header-center { display: flex; align-items: center; justify-content: center; flex: 1; }
.header-right { display: flex; align-items: center; gap: 8px; min-width: 80px; justify-content: flex-end; }

/* ---- MENU BUTTON (top right) ---- */
.menu-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text2);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.menu-btn:hover, .menu-btn.active {
  background: var(--bg2);
  color: var(--text);
  border-color: var(--accent);
}
.menu-btn svg { transition: transform 0.2s; }
.menu-btn.active svg { transform: rotate(180deg); }

/* ---- DROPDOWN MENU ---- */
.dropdown-menu {
  position: fixed;
  top: calc(var(--header-h) + 6px);
  right: 16px;
  width: 220px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  z-index: 300;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.dropdown-menu.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.dropdown-nav { display: flex; flex-direction: column; gap: 2px; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text2);
  font-size: 14px;
  font-weight: 400;
  transition: all 0.15s;
  cursor: pointer;
  text-decoration: none;
}
.dropdown-item:hover { background: var(--bg3); color: var(--text); }

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

/* Overlay trasparente per chiudere il menu */
.menu-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 299;
}
.menu-overlay.active { display: block; }

/* ---- MAIN senza sidebar ---- */
.main {
  margin-top: var(--header-h);
  margin-left: 0;
  padding: 0 24px 40px;
  min-height: calc(100vh - var(--header-h));
}

/* ---- TOP TABS BAR ---- */
.top-tabs-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  padding: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.top-tabs-bar::-webkit-scrollbar { display: none; }

.top-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text2);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  padding: 14px 16px;
  cursor: pointer;
  white-space: nowrap;
  margin-bottom: -1px;
  transition: all 0.2s;
  flex-shrink: 0;
}
.top-tab:hover { color: var(--text); background: var(--bg2); }
.top-tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---- SEARCH BAR compatta ---- */
.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  transition: border-color 0.2s;
  max-width: 280px;
}
.search-bar input { padding: 8px 14px; font-size: 13px; }

/* ---- RESPONSIVE ---- */
/* ---- X/TWITTER BADGE ---- */
.x-badge {
  position: absolute;
  bottom: 6px;
  left: 8px;
  background: #000;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.3px;
  border: 1px solid #333;
  line-height: 1.4;
}

.twitter-placeholder {
  color: #1d9bf0;
  background: #0a0a0a;
}

@media (max-width: 600px) {
  .main { padding: 0 12px 40px; }
  .search-bar { max-width: 140px; }
  .search-bar input { padding: 7px 10px; font-size: 12px; }
  .menu-btn { padding: 7px 10px; font-size: 12px; }
}

/* ============================================
   VIDEO ROW — scroll orizzontale con frecce
   ============================================ */

.video-row {
  margin-bottom: 36px;
  position: relative;
}

.video-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

/* Frecce navigazione */
.row-arrows {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.row-arrow {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.row-arrow:hover {
  background: var(--bg3);
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.08);
}
.row-arrow:active { transform: scale(0.95); }

/* Scroll orizzontale — UNA sola riga */
.video-row-scroll {
  display: flex;
  flex-direction: row;
  gap: 16px;
  overflow-x: auto;
  overflow-y: visible;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 8px;
  cursor: grab;
}
.video-row-scroll:active { cursor: grabbing; }
.video-row-scroll::-webkit-scrollbar { display: none; }

/* Card fissa in larghezza dentro la riga */
.video-row-scroll .video-card {
  flex: 0 0 240px;
  min-width: 0;
  scroll-snap-align: start;
}

@media (max-width: 600px) {
  .video-row-scroll .video-card {
    flex: 0 0 160px;
  }
  .row-arrow {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }
}

/* ---- NOTIFICATION BUTTON ---- */
.notif-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 6px 12px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.notif-btn:hover { border-color: var(--accent); color: var(--accent); }
.notif-btn.notif-active { border-color: #4ade80; color: #4ade80; }
.notif-btn.notif-denied { border-color: #666; color: #666; cursor: default; }
@media (max-width: 600px) {
  .notif-btn span { display: none; }
  .notif-btn { padding: 6px 8px; }
}
