/* ==========================================================================
   AITube Layout Styles
   Responsive shell, sticky header, collapsible sidebar, responsive grid
   ========================================================================== */

/* App Container */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 16px;
  backdrop-filter: blur(8px);
}

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

.brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-text-ai {
  color: var(--text-main);
}

.brand-badge {
  background: var(--accent);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 5px;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.brand-tagline {
  display: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
  margin-left: 6px;
  border-left: 1px solid var(--border-subtle);
  padding-left: 10px;
}

@media (min-width: 900px) {
  .brand-tagline {
    display: inline-block;
  }
}

/* Search Bar */
.header-center {
  flex: 1;
  max-width: 580px;
  margin: 0 auto;
}

.search-form {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-input {
  width: 100%;
  height: 38px;
  padding: 0 42px 0 38px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  color: var(--text-main);
  font-size: 13.5px;
  transition: var(--transition);
}

.search-input:focus {
  background: var(--bg-tertiary);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-icon {
  position: absolute;
  left: 12px;
  pointer-events: none;
  color: var(--text-faint);
  width: 17px;
  height: 17px;
}

.search-shortcut {
  position: absolute;
  right: 12px;
  pointer-events: none;
}

/* Header Right Actions */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--text-muted);
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.zen-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 18px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  transition: var(--transition);
}

.zen-toggle-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-main);
  border-color: var(--border-focus);
}

.zen-toggle-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* Main Layout: Sidebar + Content */
.main-wrapper {
  display: flex;
  flex: 1;
}

/* Sidebar */
.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--bg-primary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 12px 8px;
  gap: 4px;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  transition: width 0.2s ease, transform 0.2s ease;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-faint);
  padding: 10px 12px 4px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
}

.nav-item svg {
  width: 19px;
  height: 19px;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.nav-item.active {
  background: var(--bg-secondary);
  color: var(--accent);
  font-weight: 600;
}

.nav-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 8px 4px;
}

/* Collapsed Sidebar on desktop */
body.collapsed .sidebar {
  width: 68px;
  padding: 12px 4px;
}

body.collapsed .sidebar .nav-item {
  flex-direction: column;
  gap: 4px;
  padding: 10px 4px;
  font-size: 10.5px;
  text-align: center;
}

body.collapsed .sidebar .nav-section-title,
body.collapsed .sidebar .nav-item span.full-label,
body.collapsed .brand-tagline {
  display: none;
}

/* Content Area */
.content-area {
  flex: 1;
  min-width: 0;
  padding: 24px 28px 60px 28px;
}

@media (max-width: 640px) {
  .content-area {
    padding: 16px 14px 40px 14px;
  }
}

/* Scrim overlay for mobile drawer */
.drawer-scrim {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 200;
    height: 100vh;
    transform: translateX(-100%);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.4);
  }

  body.drawer-open .sidebar {
    transform: translateX(0);
  }

  body.drawer-open .drawer-scrim {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Page Header & Breadcrumbs */
.page-header {
  margin-bottom: 20px;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-faint);
  margin-bottom: 6px;
}

.breadcrumbs a {
  color: var(--text-muted);
}

.breadcrumbs a:hover {
  color: var(--accent);
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
  max-width: 780px;
  line-height: 1.5;
}

/* Video Grid */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px 20px;
  margin-top: 20px;
}

@media (min-width: 1440px) {
  .video-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 500px) {
  .video-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

/* Toast Notification */
.toast-notice {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  font-size: 13px;
  font-weight: 500;
  z-index: 500;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-notice.show {
  opacity: 1;
  transform: translateY(0);
}
