@import url('https://fonts.googleapis.com/css2?family=Google+Sans+Flex:opsz,wght@8..144,100..1000&family=Google+Sans+Code:wght@400..700&display=swap');

:root {
  --color-bg: #0D0D0D;
  --color-surface: #1A1A1A;
  --color-surface-2: #2C4018;
  --color-green-dark: #2C4018;
  --color-green-mid: #51731F;
  --color-primary: #A0D925;
  --color-primary-bright: #B2F227;
  --color-text: #F2F2F2;
  --color-text-muted: #999999;
  --color-danger: #E53935;
  
  --font-main: 'Google Sans Flex', sans-serif;
  --font-code: 'Google Sans Code', monospace;
  
  --transition-smooth: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --nav-height: 70px;
}

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

body {
  font-family: var(--font-main);
  background: var(--color-bg);
  color: var(--color-text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--color-bg); }
::-webkit-scrollbar-thumb { background: var(--color-surface-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-green-mid); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-md); font-family: inherit; font-weight: 600;
  font-size: 1rem; border: none; cursor: pointer; transition: all var(--transition-smooth);
  text-decoration: none;
}
.btn-large { padding: 12px 28px; font-size: 1.1rem; }
.btn-sm { padding: 6px 12px; font-size: 0.9rem; }
.btn-primary { background: var(--color-primary); color: var(--color-bg); }
.btn-primary:hover { background: var(--color-primary-bright); transform: scale(1.03); }
.btn-ghost { background: rgba(255,255,255,0.15); color: #fff; backdrop-filter: blur(10px); }
.btn-ghost:hover { background: rgba(255,255,255,0.25); }
.btn-outline { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.3); }
.btn-outline:hover { background: rgba(255,255,255,0.1); border-color: #fff; }
.btn-icon { background: transparent; border: none; cursor: pointer; color: var(--color-text-muted); padding: 4px; border-radius: 4px; display: inline-flex; transition: all 0.2s; }
.btn-icon:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* Navbar */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--nav-height);
  display: flex; align-items: center; justify-content: space-between; padding: 0 4% 0 2%;
  background: linear-gradient(to bottom, rgba(13,13,13,0.9) 0%, rgba(13,13,13,0) 100%);
  z-index: 100; transition: background 0.3s;
}
.navbar.scrolled { background: rgba(13,13,13,0.95); backdrop-filter: blur(10px); }
.nav-logo { display: flex; align-items: center; }
.logo-img { height: 35px; }

.nav-center { flex: 1; display: flex; justify-content: center; }
.search-bar {
  display: flex; align-items: center; background: rgba(255,255,255,0.1); border: 1px solid transparent;
  border-radius: 20px; padding: 6px 16px; opacity: 0; pointer-events: none; transform: translateY(-10px);
  transition: all var(--transition-smooth); width: 0; overflow: hidden;
}
.search-bar.open { opacity: 1; pointer-events: auto; transform: translateY(0); width: 100%; max-width: 400px; }
.search-bar:focus-within { border-color: var(--color-primary); background: rgba(0,0,0,0.5); }
.search-icon { width: 18px; height: 18px; color: var(--color-text-muted); margin-right: 10px; }
.search-bar input {
  background: transparent; border: none; color: #fff; font-size: 1rem; width: 100%; outline: none;
}

.nav-right { display: flex; align-items: center; gap: 15px; }
.nav-icon-btn {
  background: transparent; border: none; color: var(--color-text); width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  cursor: pointer; transition: background 0.2s; position: relative;
}
.nav-icon-btn:hover { background: rgba(255,255,255,0.1); }
.nav-icon-btn svg { width: 22px; height: 22px; }

.wl-badge {
  position: absolute; top: 0; right: 0; background: var(--color-primary); color: #000;
  font-size: 0.7rem; font-weight: 700; width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--color-bg);
}
.user-info { font-weight: 600; font-size: 0.9rem; color: var(--color-primary); margin-left: 10px; }

/* Hero */
.hero {
  position: relative; height: 80vh; min-height: 500px; display: flex; align-items: flex-end;
  background-size: cover; background-position: center; padding: 0 4% 5%;
}
.hero-gradient {
  position: absolute; inset: 0;
  background: linear-gradient(0deg, var(--color-bg) 0%, rgba(13,13,13,0.5) 40%, rgba(13,13,13,0.8) 100%);
}
.hero-content { position: relative; z-index: 2; max-width: 800px; }
.hero-cat-badge {
  display: inline-block; background: rgba(255,255,255,0.1); padding: 4px 10px; border-radius: 4px;
  font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 15px;
}
.hero-title { font-size: 3.5rem; font-weight: 800; line-height: 1.1; margin-bottom: 15px; text-shadow: 0 2px 10px rgba(0,0,0,0.5); }
.hero-desc { font-size: 1.2rem; line-height: 1.5; color: #ddd; margin-bottom: 30px; text-shadow: 0 2px 4px rgba(0,0,0,0.8); }
.hero-actions { display: flex; gap: 15px; }
.wl-toggle.active { background: rgba(160,217,37,0.2); color: var(--color-primary); border-color: var(--color-primary); }

/* Categories Bar */
.cat-filter-wrapper { padding: 20px 4%; position: relative; z-index: 10; margin-top: -30px; }
.category-bar { display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none; padding-bottom: 10px; }
.category-bar::-webkit-scrollbar { display: none; }
.cat-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: 30px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); color: #fff;
  font-family: inherit; font-size: 0.95rem; font-weight: 500; cursor: pointer;
  transition: all var(--transition-smooth); white-space: nowrap;
}
.cat-chip:hover { background: rgba(255,255,255,0.15); }
.cat-chip.active { background: var(--cat-color, var(--color-primary)); color: #000; border-color: transparent; font-weight: 700; }
.cat-chip-dot { width: 10px; height: 10px; border-radius: 50%; }
.cat-chip-count { background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 10px; font-size: 0.8rem; margin-left: 5px; }

/* Catalog */
.catalog { padding: 0 4% 50px; }
.catalog-section { margin-bottom: 40px; position: relative; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.section-title { font-size: 1.4rem; font-weight: 700; border-left: 4px solid var(--color-primary); padding-left: 10px; line-height: 1.2; }
.section-nav { display: flex; gap: 10px; opacity: 0; transition: opacity 0.2s; }
.catalog-section:hover .section-nav { opacity: 1; }
.scroll-btn { background: rgba(255,255,255,0.1); border: none; color: #fff; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; }
.scroll-btn:hover { background: rgba(255,255,255,0.3); }

/* Video Grid */
.video-row {
  display: grid; grid-auto-flow: column; grid-auto-columns: calc(20% - 12px); gap: 15px;
  overflow-x: auto; scrollbar-width: none; padding-bottom: 20px; padding-top: 10px; scroll-behavior: smooth;
}
@media (max-width: 1400px) { .video-row { grid-auto-columns: calc(25% - 11.25px); } }
@media (max-width: 1024px) { .video-row { grid-auto-columns: calc(33.333% - 10px); } }
@media (max-width: 768px) { .video-row { grid-auto-columns: calc(50% - 7.5px); } }
@media (max-width: 480px) { .video-row { grid-auto-columns: 85%; } }
.video-row::-webkit-scrollbar { display: none; }

/* Flat Grid (Search/Filter) */
.catalog-section.grid .video-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); grid-auto-flow: row; }

/* Video Card */
.video-card {
  position: relative; border-radius: var(--radius-md); overflow: hidden;
  background: var(--color-surface); cursor: pointer; transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
}
.video-card:hover { transform: scale(1.05) translateY(-5px); box-shadow: 0 15px 30px rgba(0,0,0,0.6); z-index: 10; }
.card-thumb-wrap { position: relative; aspect-ratio: 16/9; background: #222; }
.card-thumb { width: 100%; height: 100%; object-fit: cover; }
.featured-badge { position: absolute; top: 8px; left: 8px; background: var(--color-primary); color: #000; font-size: 0.7rem; font-weight: 700; padding: 3px 8px; border-radius: 4px; text-transform: uppercase; z-index: 3; }
.card-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.6); display: flex; flex-direction: column;
  align-items: center; justify-content: center; opacity: 0; transition: opacity var(--transition-smooth); z-index: 2;
}
.video-card:hover .card-overlay { opacity: 1; }
.card-play-btn {
  background: rgba(160,217,37,0.9); border: none; width: 48px; height: 48px; border-radius: 50%;
  color: #000; display: flex; align-items: center; justify-content: center; cursor: pointer;
  transform: scale(0.8); transition: transform var(--transition-smooth);
}
.card-play-btn svg { width: 24px; height: 24px; margin-left: 3px; }
.video-card:hover .card-play-btn { transform: scale(1); }
.card-actions { position: absolute; bottom: 10px; right: 10px; display: flex; gap: 8px; align-items: center; }
.card-watchlater-btn {
  background: rgba(0,0,0,0.7); border: 1px solid rgba(255,255,255,0.4); color: #fff; width: 28px; height: 28px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 1.2rem;
}
.card-watchlater-btn:hover { background: #fff; color: #000; }
.card-watchlater-btn.active { background: var(--color-primary); color: #000; border-color: transparent; }
.source-badge {
  background: rgba(0,0,0,0.7); padding: 4px 8px; border-radius: 4px; font-size: 0.7rem; font-weight: 700;
  backdrop-filter: blur(4px); color: #fff; border: 1px solid rgba(255,255,255,0.1);
}
.source-youtube { color: #FF0000; }
.source-vimeo { color: #1AB7EA; }
.source-instagram { color: #E1306C; }
.source-mp4 { color: var(--color-primary); }

.card-info { padding: 12px; }
.card-title { font-size: 0.95rem; font-weight: 600; margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-cat { font-size: 0.8rem; color: var(--color-text-muted); }

/* Modals */
.modal { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity var(--transition-smooth); }
.modal.open { opacity: 1; pointer-events: auto; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.85); backdrop-filter: blur(5px); }
.modal-content {
  position: relative; z-index: 1; width: 90%; max-width: 800px; max-height: 90vh; overflow-y: auto;
  background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: 0 25px 50px rgba(0,0,0,0.5);
  transform: scale(0.95) translateY(20px); transition: all var(--transition-smooth);
}
.modal.open .modal-content { transform: scale(1) translateY(0); }
.modal-close {
  position: absolute; top: 15px; right: 15px; background: rgba(0,0,0,0.5); border: none; color: #fff;
  width: 36px; height: 36px; border-radius: 50%; font-size: 1.2rem; cursor: pointer; z-index: 10;
}
.modal-close:hover { background: #fff; color: #000; }
.modal-media { position: relative; width: 100%; aspect-ratio: 16/9; background: #000; }
.modal-thumb { width: 100%; height: 100%; object-fit: cover; }
.modal-thumb-gradient { position: absolute; inset: 0; background: linear-gradient(to top, var(--color-surface) 0%, rgba(26,26,26,0) 50%); }
.modal-body { padding: 30px; position: relative; margin-top: -60px; z-index: 2; }
.modal-meta-row { display: flex; gap: 10px; margin-bottom: 10px; }
.modal-cat-badge, .modal-source-badge { font-size: 0.8rem; font-weight: 700; padding: 4px 10px; border-radius: 4px; background: rgba(255,255,255,0.1); }
.modal-title { font-size: 2rem; font-weight: 800; margin-bottom: 15px; }
.modal-desc { font-size: 1rem; color: #ccc; line-height: 1.6; margin-bottom: 25px; }
.modal-actions { display: flex; gap: 15px; flex-wrap: wrap; }

/* Side Panel (Watch Later) */
.side-panel { position: fixed; inset: 0; z-index: 2000; display: flex; justify-content: flex-end; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.side-panel.open { opacity: 1; pointer-events: auto; }
.side-panel-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(2px); }
.side-panel-content {
  position: relative; z-index: 1; width: 100%; max-width: 400px; background: var(--color-surface);
  height: 100%; display: flex; flex-direction: column; transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.side-panel.open .side-panel-content { transform: translateX(0); }
.side-panel-header { padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.1); display: flex; justify-content: space-between; align-items: center; }
.wl-list { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 15px; }
.wl-item { display: flex; gap: 15px; background: rgba(255,255,255,0.05); padding: 10px; border-radius: 8px; transition: background 0.2s; }
.wl-item:hover { background: rgba(255,255,255,0.1); }
.wl-thumb { width: 100px; height: 56px; object-fit: cover; border-radius: 4px; }
.wl-info { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.wl-title { font-size: 0.9rem; font-weight: 600; line-height: 1.3; margin-bottom: 5px; }
.wl-cat { font-size: 0.75rem; color: var(--color-text-muted); }
.wl-actions { display: flex; flex-direction: column; gap: 5px; }
.wl-play, .wl-remove { background: rgba(255,255,255,0.1); border: none; color: #fff; width: 28px; height: 28px; border-radius: 4px; cursor: pointer; }
.wl-play:hover { background: var(--color-primary); color: #000; }
.wl-remove:hover { background: var(--color-danger); }
.wl-empty { text-align: center; color: var(--color-text-muted); margin-top: 50px; font-size: 1rem; line-height: 1.5; }

/* Toasts */
.toast-container { position: fixed; top: 90px; right: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--color-surface-2); color: #fff; padding: 12px 20px; border-radius: 8px; border-left: 4px solid var(--color-primary); box-shadow: 0 5px 15px rgba(0,0,0,0.5); transform: translateX(120%); transition: transform 0.3s; font-size: 0.95rem; }
.toast.toast-error { border-left-color: var(--color-danger); }
.toast.show { transform: translateX(0); }

/* Banners & Empty states */
.db-offline-banner { background: #FF9800; color: #000; padding: 10px 20px; display: flex; justify-content: space-between; font-weight: 600; position: fixed; bottom: 20px; left: 20px; right: 20px; border-radius: 8px; z-index: 9999; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.db-offline-banner button { background: transparent; border: none; font-weight: 700; cursor: pointer; color: #000; }
.empty-state { text-align: center; padding: 80px 20px; }
.empty-icon { font-size: 3rem; margin-bottom: 20px; opacity: 0.5; }

/* Skeletons */
.skeleton { background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%); background-size: 200% 100%; animation: skeletonLoading 1.5s infinite; border-radius: 4px; }
@keyframes skeletonLoading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-title { width: 200px; height: 24px; margin: 0 4% 20px; }
.skeleton-row { display: flex; gap: 15px; padding: 0 4% 40px; overflow: hidden; }
.skeleton-card { width: calc(20vw - 20px); min-width: 200px; aspect-ratio: 16/9; border-radius: 8px; }

/* Footer */
.footer { padding: 40px 4%; text-align: center; border-top: 1px solid rgba(255,255,255,0.05); margin-top: 40px; }
.footer-inner { max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 15px; }
.footer-logo { height: 24px; opacity: 0.5; }
.footer-copy { color: var(--color-text-muted); font-size: 0.85rem; }
.footer-admin-link { color: var(--color-text-muted); text-decoration: none; font-size: 0.85rem; }
.footer-admin-link:hover { color: var(--color-primary); }
