/* PawTube - MD3 & YouTube Clone UI */
:root {
  --bg-primary: #0f0f0f;
  --bg-secondary: #121212;
  --bg-elevated: #272727;
  --bg-hover: #3f3f3f;
  --bg-active: #ffffff20;
  
  --text-primary: #f1f1f1;
  --text-secondary: #aaaaaa;
  --text-disabled: #717171;
  
  --brand-color: #3ea6ff;
  --brand-blue: #3ea6ff;
  --error: #ff4e45;
  
  --border-color: #303030;
  --border-color-light: rgba(255, 255, 255, 0.1);
  
  --header-height: 56px;
  --sidebar-width: 240px;
  --mini-sidebar-width: 72px;
  --bottom-nav-height: 48px;
  
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  
  --font-base: 'Roboto', Arial, sans-serif;
  --font-heading: 'Google Sans', 'Roboto', sans-serif;
}

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

html { scroll-behavior: smooth; }
body {
  font-family: var(--font-base);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Typography & Icons */
.material-symbols-rounded {
  font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
  font-size: 24px;
}
.filled-icon { font-variation-settings: 'FILL' 1 !important; }

button { background: none; border: none; color: inherit; cursor: pointer; font-family: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* Header */
.header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-height);
  background: var(--bg-primary);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; z-index: 100;
}
.header-left, .header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.header-center { flex: 1; max-width: 720px; display: flex; align-items: center; gap: 12px; margin: 0 40px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s; flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-elevated); }

.logo { display: flex; align-items: center; gap: 4px; padding-right: 14px; }
.logo-icon { width: 30px; height: 30px; border-radius: 6px; }
.logo-text { font-family: var(--font-heading); font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }

/* In-Page Search Sections */
.search-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 24px;
}
.search-row { display: flex; gap: 10px; align-items: center; width: 100%; max-width: 500px; }
.search-input {
  flex: 1; height: 44px; padding: 0 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  color: var(--text-primary); font-size: 15px; outline: none;
}
.search-input:focus { border-color: var(--brand-blue); }
.btn-primary { 
  background: var(--text-primary); color: var(--bg-primary); 
  padding: 0 20px; height: 44px; border-radius: var(--radius-pill); 
  font-weight: 500; font-size: 15px; display:flex; align-items:center; justify-content:center; gap:8px; cursor: pointer; border: none;
}
.btn-primary:hover { background: #e0e0e0; }

/* Top Header Search Bar */
.search-bar {
  display: flex; flex: 1; align-items: center;
  height: 40px; border: 1px solid var(--border-color);
  border-radius: var(--radius-pill); overflow: hidden;
  background: #121212; margin-left: 40px;
}
.search-input-wrapper {
  flex: 1; display: flex; align-items: center;
  padding-left: 16px; position: relative;
}
.search-icon-hidden { display: none; font-size: 20px; color: var(--text-secondary); margin-right: 8px; }
.search-input-wrapper:focus-within .search-icon-hidden { display: block; }
.search-input-wrapper input {
  flex: 1; height: 100%; background: transparent; border: none;
  color: var(--text-primary); font-size: 16px; outline: none; width: 100%;
}
/* Strip default clear buttons from webkit */
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration { display: none; }

.search-btn {
  width: 64px; height: 100%; background: var(--bg-elevated);
  border-left: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.search-btn:hover { background: var(--bg-hover); }

.voice-search-btn { background: #181818; }
.voice-search-btn:hover { background: var(--bg-elevated); }

.profile-btn img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }

/* Mobile Search State Elements */
.mobile-search-trigger { display: none; }
.mobile-search-back { display: none; }

/* Sidebars */
.sidebar, .mini-sidebar {
  position: fixed; top: var(--header-height); bottom: 0; left: 0;
  background: var(--bg-primary); z-index: 90;
  overflow-y: auto; overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: transparent; border-radius: 4px; }
.sidebar:hover::-webkit-scrollbar-thumb { background: var(--text-disabled); }

.sidebar { width: var(--sidebar-width); padding: 12px; transition: transform 0.2s; }
.mini-sidebar { width: var(--mini-sidebar-width); padding: 4px; display: none; flex-direction: column; align-items: center; }

.nav-item {
  display: flex; align-items: center; gap: 24px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
}
.nav-item:hover, .nav-item.active { background: var(--bg-elevated); }
.nav-item.active { font-weight: 700; }
.nav-item.active .nav-icon { font-variation-settings: 'FILL' 1; }

.mini-nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 64px; height: 74px; border-radius: var(--radius-sm);
  font-size: 10px; gap: 6px;
}
.mini-nav-item:hover { background: var(--bg-elevated); }
.mini-nav-item.active .material-symbols-rounded { font-variation-settings: 'FILL' 1; }

.divider { height: 1px; background: var(--border-color-light); margin: 12px 0; }
.sidebar-heading { padding: 8px 12px; font-size: 16px; font-weight: 600; display: flex; align-items: center; }
.sidebar-footer { padding: 16px 24px; font-size: 12px; color: var(--text-secondary); font-weight: 500; line-height: 1.4; }
.sidebar-footer p { margin-bottom: 8px; }
.sidebar-footer .copyright { color: var(--text-disabled); font-weight: 400; }

.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 85;
  opacity: 0; visibility: hidden; transition: 0.2s;
}
.sidebar-overlay.show { opacity: 1; visibility: visible; }

/* Main Content */
.main-content {
  margin-top: var(--header-height);
  margin-left: var(--sidebar-width);
  padding: 24px;
  min-height: calc(100vh - var(--header-height));
  transition: margin-left 0.2s;
}

/* Category Chips */
.category-bar {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 16px;
  margin-bottom: 8px; scrollbar-width: none;
}
.category-bar::-webkit-scrollbar { display: none; }
.category-chip {
  padding: 8px 12px; background: var(--bg-elevated);
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  white-space: nowrap; transition: 0.2s;
}
.category-chip:hover { background: var(--bg-hover); }
.category-chip.active { background: var(--text-primary); color: var(--bg-primary); }

/* Video Grid */
.video-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 40px 16px;
}

.video-card { cursor: pointer; display: flex; flex-direction: column; gap: 12px; }
.thumbnail-wrap {
  position: relative; width: 100%; aspect-ratio: 16/9;
  border-radius: var(--radius-md); overflow: hidden;
  background: var(--bg-elevated);
}
.thumbnail-wrap img { width: 100%; height: 100%; object-fit: cover; transition: 0.3s; }
.video-card:hover .thumbnail-wrap img { border-radius: 0; }

.duration-badge {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(0,0,0,0.8); padding: 3px 4px;
  border-radius: var(--radius-xs); font-size: 12px; font-weight: 500;
}
.save-btn {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,0.8); width: 32px; height: 32px;
  border-radius: var(--radius-pill); display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: 0.2s;
}
.video-card:hover .save-btn { opacity: 1; }
.save-btn:hover { background: var(--bg-hover); }
.save-btn.saved { opacity: 1; background: var(--text-primary); color: var(--bg-primary); }
.save-btn.saved .material-symbols-rounded { font-variation-settings: 'FILL' 1; }

.card-info { display: flex; gap: 12px; align-items: flex-start; }
.channel-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #555; flex-shrink: 0; overflow: hidden;
}
.channel-avatar img { width: 100%; height: 100%; object-fit: cover; }
.card-meta { display: flex; flex-direction: column; padding-right: 24px; }
.card-title {
  font-size: 16px; font-weight: 500; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 4px;
}
.card-channel, .card-extra { font-size: 14px; color: var(--text-secondary); line-height: 1.4; }
.card-channel:hover { color: var(--text-primary); }

/* Watch Layout */
.watch-page { max-width: 1600px; margin: 0 auto; padding-top: 12px; }
.watch-layout { display: flex; gap: 24px; flex-wrap: wrap; }
.player-section { flex: 1; min-width: 64%; }

.player-container {
  width: 100%; aspect-ratio: 16/9;
  border-radius: var(--radius-md); overflow: hidden; background: #000;
}
.player-container iframe { width: 100%; height: 100%; border: none; }

.video-details { margin-top: 12px; }
.video-title { font-family: var(--font-heading); font-size: 20px; font-weight: 700; margin-bottom: 12px; }

.watch-actions-bar {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
}
.watch-channel-info { display: flex; align-items: center; gap: 12px; }
.watch-channel-avatar { width: 40px; height: 40px; border-radius: 50%; background: #555; overflow: hidden; }
.watch-channel-text { display: flex; flex-direction: column; }
.w-channel-name { font-weight: 500; font-size: 16px; }
.w-channel-subs { font-size: 12px; color: var(--text-secondary); }
.btn-subscribe {
  background: var(--text-primary); color: var(--bg-primary);
  padding: 0 16px; height: 36px; border-radius: var(--radius-pill);
  font-weight: 500; font-size: 14px; margin-left: 12px;
  transition: all 0.2s;
}

.watch-action-buttons { display: flex; gap: 8px; }
.pill-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-elevated); height: 36px; padding: 0 16px;
  border-radius: var(--radius-pill); font-size: 14px; font-weight: 500;
  transition: all 0.2s;
}
.pill-btn:hover { background: var(--bg-hover); }
.pill-btn.active-liked { background: var(--text-primary) !important; color: var(--bg-primary) !important; }
.pill-group {
  display: flex; background: var(--bg-elevated); border-radius: var(--radius-pill);
  overflow: hidden; height: 36px;
}
.pill-group .pill-btn { background: transparent; border-radius: 0; }
.pill-group .pill-btn:hover { background: rgba(255,255,255,0.1); }
.pill-group .pill-btn.active-liked { background: rgba(255,255,255,0.9); color: #000; }
.pill-divider { width: 1px; background: rgba(255,255,255,0.2); margin: 6px 0; }

.video-description {
  background: var(--bg-elevated); border-radius: var(--radius-md);
  padding: 12px; font-size: 14px; line-height: 1.5;
}

.related-section { width: 400px; flex-shrink: 0; }
.related-card { display: flex; gap: 8px; margin-bottom: 8px; cursor: pointer; }
.related-thumb {
  width: 168px; aspect-ratio: 16/9; border-radius: var(--radius-sm);
  background: #222; position: relative; overflow: hidden; flex-shrink: 0;
}
.related-thumb img { width: 100%; height: 100%; object-fit: cover; }
.related-meta { flex: 1; display: flex; flex-direction: column; }
.related-title-text {
  font-size: 14px; font-weight: 500; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.related-channel { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* Bottom Nav (Mobile) */
.bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-height); background: var(--bg-primary);
  border-top: 1px solid var(--border-color); z-index: 100;
}
.bnav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.bnav-item .material-symbols-rounded { font-size: 24px; }
.bnav-label { font-size: 10px; }
.bnav-profile { width: 24px; height: 24px; border-radius: 50%; }

/* Utility & States */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; text-align: center; color: var(--text-secondary);
}
.empty-state .material-symbols-rounded { font-size: 80px; opacity: 0.5; margin-bottom: 16px; }

.section-header { margin-bottom: 24px; display: flex; justify-content: space-between; align-items: center; }
.section-title { font-family: var(--font-heading); font-size: 24px; font-weight: 700; }

.toast {
  position: fixed; bottom: 24px; left: 24px; background: var(--text-primary); color: var(--bg-primary);
  padding: 12px 24px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  transform: translateY(100px); opacity: 0; transition: 0.3s; z-index: 1000; box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.toast.show { transform: translateY(0); opacity: 1; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex;
  align-items: center; justify-content: center; z-index: 2000; opacity: 0; visibility: hidden; transition: 0.2s;
}
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal {
  background: var(--bg-secondary); border-radius: var(--radius-md); width: 90%; max-width: 500px;
  overflow: hidden; border: 1px solid var(--border-color);
}
.modal-header { padding: 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color-light); }
.modal-body { padding: 24px; }
.about-hero { text-align: center; margin-bottom: 24px; }
.about-hero-logo { width: 80px; border-radius: 16px; margin: 0 auto 16px; }
.feat-item { display: flex; gap: 16px; align-items: center; margin-bottom: 12px; }
.feat-item .material-symbols-rounded { color: var(--brand-color); }

/* Responsive adjustments */
@media (max-width: 1300px) {
  .sidebar { transform: translateX(-100%); }
  .mini-sidebar { display: flex; }
  .main-content { margin-left: var(--mini-sidebar-width); }
  .header-center { margin: 0 16px; }
}
@media (max-width: 900px) {
  .related-section { width: 100%; margin-top: 24px; }
  .video-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
}
@media (max-width: 600px) {
  .mini-sidebar { display: none; }
  .main-content { margin-left: 0; padding: 16px 0; padding-bottom: calc(var(--bottom-nav-height) + 16px); }
  .bottom-nav { display: flex; }
  .header-center { display: none; }
  .video-card { gap: 8px; }
  .thumbnail-wrap { border-radius: 0; }
  .video-grid { gap: 24px 0; grid-template-columns: 1fr; }
  .card-info { padding: 0 16px; }
  .watch-layout { gap: 0; }
  .player-container { border-radius: 0; }
  .video-details, .related-section { padding: 0 16px; }
  
  /* Mobile Search Integration */
  .mobile-search-trigger { display: flex; }
  
  .header.search-active .header-center {
    display: flex; position: absolute; left: 0; right: 0; top: 0; bottom: 0;
    background: var(--bg-primary); margin: 0; padding: 0 12px; z-index: 10;
    align-items: center; width: 100%; max-width: 100%;
  }
  .header.search-active .header-left,
  .header.search-active .header-right { display: none; }
  .header.search-active .mobile-search-back { display: flex; flex-shrink: 0; margin-right: 8px; }
  .header.search-active .search-bar { margin: 0; flex: 1; }
  .header.search-active .voice-search-btn { margin-left: 8px; }
}

/* Theater Mode overrides */
body.theater .header, body.theater .sidebar, body.theater .mini-sidebar, body.theater .bottom-nav { display: none; }
body.theater .main-content { margin: 0; padding: 0; }
body.theater .player-container { border-radius: 0; max-height: 100vh; }
