/* ============================================
   VISION TV v2.0 — LAYOUT
   App Shell, Navigation, Grid, Responsive
   ============================================ */

/* ============================================
   APP SHELL
   ============================================ */
#app {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* ============================================
   HEADER
   ============================================ */
.header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  height: var(--header-height);
  background: rgba(15, 15, 15, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-logo img {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
}

.header-logo span {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  color: var(--text-primary);
  font-size: 18px;
  transition: background var(--ease-normal);
}

.header-btn:hover {
  background: var(--bg-elevated);
}

.header-btn .notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--error);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-primary);
}

/* ============================================
   BOTTOM NAVIGATION
   ============================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  height: var(--bottom-nav-height);
  background: rgba(15, 15, 15, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-around;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  transition: all var(--ease-normal);
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.nav-item .nav-icon {
  font-size: 24px;
  line-height: 1;
  transition: all var(--ease-normal);
  text-align: center;
  opacity: 0.7;
}

.nav-item .nav-icon img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--gold);
  filter: none;
}

.nav-item .nav-label {
  font-size: 10px;
  font-weight: 500;
  color: #999;
  transition: color var(--ease-normal);
}

.nav-item.active .nav-icon {
  opacity: 1;
  transform: scale(1.15);
}

.nav-item.active .nav-label {
  color: var(--gold);
  font-weight: 600;
}

.nav-item:active {
  transform: scale(0.9);
}

/* Active indicator dot */
.nav-item.active::before {
  content: '';
  position: absolute;
  top: -1px;
  width: 20px;
  height: 3px;
  background: var(--gold);
  border-radius: 0 0 3px 3px;
}

/* ============================================
   PAGE CONTENT
   ============================================ */
.page-content {
  padding-top: var(--header-height);
  padding-bottom: calc(var(--bottom-nav-height) + var(--space-lg));
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.page {
  display: none;
  padding: var(--space-lg);
  animation: pageIn 0.3s ease;
}

.page.active {
  display: block;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Page Header (inside content) */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
}

.page-title {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
}

/* ============================================
   GRID SYSTEMS
   ============================================ */

/* Home Section Grid (2 columns) */
.section-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

/* Product Grid (2 columns) */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}

/* Profile List */
.profile-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Stories Row */
.stories-row {
  display: flex;
  gap: var(--space-md);
  overflow-x: auto;
  scrollbar-width: none;
  padding: var(--space-sm) 0;
}

.stories-row::-webkit-scrollbar {
  display: none;
}

.story-bubble {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
  cursor: pointer;
}

.story-ring {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  padding: 3px;
  background: var(--gold-gradient);
}

.story-ring img {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--bg-primary);
}

.story-ring.seen {
  background: var(--bg-elevated);
}

.story-name {
  font-size: 11px;
  color: var(--text-secondary);
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

/* ============================================
   SEARCH BAR
   ============================================ */
.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 10px var(--space-lg);
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  border: 1px solid transparent;
  transition: border-color var(--ease-normal);
}

.search-bar:focus-within {
  border-color: rgba(212, 175, 55, 0.3);
}

.search-bar svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-muted);
  flex-shrink: 0;
}

.search-bar input {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 15px;
  width: 100%;
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

/* ============================================
   FLOATING ACTION BUTTON
   ============================================ */
.fab {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + var(--space-lg));
  right: calc(50% - var(--max-width) / 2 + var(--space-lg));
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--gold-gradient);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-gold), var(--shadow-lg);
  cursor: pointer;
  border: none;
  font-size: 24px;
  z-index: 90;
  transition: all var(--ease-normal);
}

.fab:active {
  transform: scale(0.9);
}

/* ============================================
   LIVE BANNER
   ============================================ */
.live-banner {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(255, 127, 0, 0.1));
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  cursor: pointer;
}

.live-dot {
  width: 10px;
  height: 10px;
  background: var(--error);
  border-radius: var(--radius-full);
  animation: livePulse 1.5s infinite;
  flex-shrink: 0;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

.live-banner .live-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--gold);
}

/* ============================================
   VIDEO GRID (Vision TV page)
   Mobile: 2 cols (shows ~5 videos visible)
   Tablet: 3 cols
   Desktop: 4-5 cols (9+ visible)
   ============================================ */
.video-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.video-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid rgba(255,255,255,0.04);
}
.video-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.video-card:active {
  transform: scale(0.97);
}
.video-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--bg-elevated);
  overflow: hidden;
}
.video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.video-live-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: #FF0000;
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}
.video-play-btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.video-card:hover .video-play-btn {
  opacity: 1;
}
.video-play-btn svg {
  background: rgba(0,0,0,0.6);
  border-radius: 50%;
  padding: 10px;
  backdrop-filter: blur(4px);
}
.video-info {
  padding: 8px 10px 10px;
}
.video-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}
.video-meta {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 4px;
}

/* On mobile, always show play button */
@media (max-width: 767px) {
  .video-play-btn { opacity: 1; }
  .video-play-btn svg { padding: 8px; }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 380px) {
  .section-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  h1, .h1 { font-size: 26px; }
  h2, .h2 { font-size: 20px; }
}

@media (min-width: 481px) {
  #app {
    border-left: 1px solid rgba(255, 255, 255, 0.04);
    border-right: 1px solid rgba(255, 255, 255, 0.04);
  }
}

/* ============================================
   DESKTOP / WEBSITE LAYOUT (768px+)
   Full-width on PC, centered content
   ============================================ */
@media (min-width: 768px) {
  :root {
    --max-width: 100%;
  }

  #app {
    max-width: 100%;
  }

  .header {
    max-width: 100%;
    padding: 0 40px;
  }

  .bottom-nav {
    max-width: 100%;
    padding: 0 40px;
    justify-content: center;
    gap: 48px;
  }

  .nav-item {
    min-width: 64px;
  }

  .page-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-xl) 40px calc(var(--bottom-nav-height) + 24px);
  }

  .section-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }

  .product-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .video-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  .search-bar {
    max-width: 600px;
  }

  /* Hero banner scales nicely */
  .hero-banner {
    height: 240px !important;
  }
}

/* Large Desktop (1024px+) */
@media (min-width: 1024px) {
  .header {
    padding: 0 60px;
  }

  .page-content {
    max-width: 1400px;
    padding: 32px 60px calc(var(--bottom-nav-height) + 32px);
  }

  .section-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 20px;
  }

  .product-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .video-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
  }

  .bottom-nav {
    gap: 64px;
  }
}

/* Extra-large Desktop (1440px+) */
@media (min-width: 1440px) {
  .page-content {
    max-width: 1600px;
    padding: 40px 80px calc(var(--bottom-nav-height) + 40px);
  }

  .video-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
  }
}
