/* SiliconShorts - Pure Monochrome Stylesheet with Perfect Light & Dark Modes */

:root, [data-theme="dark"], html[data-theme="dark"] {
  --bg-page: #000000;
  --bg-sidebar: #0a0a0a;
  --bg-header: #080808;
  --bg-surface: #0a0a0a;
  --bg-surface-2: #141414;
  --bg-surface-3: #1f1f1f;
  --bg-summary-box: #141414;
  --border-color: #262626;
  --border-light: #404040;
  
  --text-main: #ffffff;
  --text-primary: #ffffff;
  --text-secondary: #e4e4e7;
  --text-muted: #a1a1aa;
  --text-faint: #71717a;
  
  --card-bg: #0a0a0a;
  --card-border: #262626;
  --card-border-hover: #525252;
  
  --input-bg: #141414;
  --input-border: #262626;
  --input-text: #ffffff;
  
  --pill-active-bg: #ffffff;
  --pill-active-text: #000000;
  --pill-inactive-bg: #141414;
  --pill-inactive-text: #a1a1aa;
  
  --btn-primary-bg: #ffffff;
  --btn-primary-text: #000000;
  --btn-secondary-bg: #171717;
  --btn-secondary-text: #ffffff;
  --btn-secondary-border: #262626;
  
  --scrollbar-thumb: #262626;
}

:root[data-theme="light"], html[data-theme="light"], [data-theme="light"] {
  --bg-page: #f8f9fa;
  --bg-sidebar: #ffffff;
  --bg-header: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-2: #f4f4f5;
  --bg-surface-3: #e4e4e7;
  --bg-summary-box: #f4f4f5;
  --border-color: #e4e4e7;
  --border-light: #d4d4d8;
  
  --text-main: #09090b;
  --text-primary: #09090b;
  --text-secondary: #18181b;
  --text-muted: #3f3f46;
  --text-faint: #71717a;
  
  --card-bg: #ffffff;
  --card-border: #e4e4e7;
  --card-border-hover: #a1a1aa;
  
  --input-bg: #ffffff;
  --input-border: #d4d4d8;
  --input-text: #09090b;
  
  --pill-active-bg: #09090b;
  --pill-active-text: #ffffff;
  --pill-inactive-bg: #f4f4f5;
  --pill-inactive-text: #3f3f46;
  
  --btn-primary-bg: #09090b;
  --btn-primary-text: #ffffff;
  --btn-secondary-bg: #f4f4f5;
  --btn-secondary-text: #09090b;
  --btn-secondary-border: #d4d4d8;
  
  --scrollbar-thumb: #d4d4d8;
}

/* Base resets & typography */
html {
  scroll-behavior: smooth;
  background-color: var(--bg-page);
  color: var(--text-main);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.font-mono {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
}

/* Minimalist Monochrome Scrollbar */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: var(--bg-page);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}

.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* =========================================
   REEL SCROLL-SNAP ENGINE (TIKTOK / INSTAGRAM REELS)
   ========================================= */

.reel-scroll-track {
  height: calc(100dvh - 150px);
  min-height: 480px;
  max-height: calc(100dvh - 150px);
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  border-radius: 1rem;
}

/* Mobile Reels Immersion Mode (< 768px): Full-height viewport snap */
@media (max-width: 767px) {
  html.mobile-reels-locked,
  body.mobile-reels-mode {
    height: 100dvh !important;
    height: 100vh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    left: 0 !important;
    top: 0 !important;
    margin: 0 !important;
  }

  body.mobile-reels-mode #mainContentWrapper,
  body.mobile-reels-mode .themed-main {
    height: 100dvh !important;
    height: 100vh !important;
    max-height: 100dvh !important;
    padding-top: 42px !important;
    padding-bottom: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    min-height: 0 !important;
  }

  body.mobile-reels-mode #mainContentArea,
  body.mobile-reels-mode main {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: calc(100dvh - 42px) !important;
    height: calc(100vh - 42px) !important;
    max-height: calc(100dvh - 42px) !important;
    overflow: hidden !important;
    padding: 6px 10px 8px 10px !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
  }

  body.mobile-reels-mode #contentContainer {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
  }

  body.mobile-reels-mode #mainFooter {
    display: none !important;
  }

  body.mobile-reels-mode .reels-root-layout {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    width: 100% !important;
  }

  body.mobile-reels-mode .reels-tab-header {
    flex-shrink: 0 !important;
    padding-bottom: 4px !important;
    margin-bottom: 4px !important;
    width: 100% !important;
  }

  body.mobile-reels-mode .reels-tab-container {
    margin-bottom: 0 !important;
    flex-shrink: 0 !important;
  }

  body.mobile-reels-mode .reels-viewport-area {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    width: 100% !important;
  }

  /* Only the ACTIVE reel column should flex-fill; the inactive one stays hidden.
     Using :not(.hidden) keeps Tailwind's `hidden` class authoritative on mobile. */
  body.mobile-reels-mode .reel-column-wrapper:not(.hidden) {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    width: 100% !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  body.mobile-reels-mode .reel-column-wrapper.hidden,
  body.mobile-reels-mode .reel-column-wrapper[style*="display: none"] {
    display: none !important;
    height: 0 !important;
    max-height: 0 !important;
    min-height: 0 !important;
    flex: 0 0 0% !important;
    visibility: hidden !important;
    opacity: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.mobile-reels-mode .reel-scroll-track {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch !important;
    scroll-snap-type: y mandatory !important;
    overscroll-behavior-y: contain !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0.75rem !important;
    display: flex !important;
    flex-direction: column !important;
    /* gap must be 0 so one card pitch === clientHeight, keeping
       scroll-snap, Next/Prev buttons and the reel counter in sync */
    gap: 0 !important;
  }

  body.mobile-reels-mode .reel-card-snap {
    flex: 0 0 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
    flex-shrink: 0 !important;
    scroll-snap-align: start !important;
    scroll-snap-stop: always !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    padding: 14px 16px 12px 16px !important;
    border-radius: 0.85rem !important;
    overflow: hidden !important;
    background-color: var(--card-bg) !important;
    border: 1px solid var(--card-border) !important;
  }

  body.mobile-reels-mode .reel-card-body {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    padding-bottom: 4px !important;
  }

  body.mobile-reels-mode .reel-card-title {
    font-size: 0.95rem !important;
    line-height: 1.35 !important;
    margin-bottom: 0.4rem !important;
    font-weight: 700 !important;
  }

  body.mobile-reels-mode .reel-summary-box {
    padding: 8px 10px !important;
    margin-bottom: 6px !important;
    flex: 1 1 auto !important;
    min-height: 50px !important;
    max-height: 38vh !important;
    overflow-y: auto !important;
  }

  body.mobile-reels-mode .reel-summary-text {
    font-size: 0.775rem !important;
    line-height: 1.4 !important;
  }

  body.mobile-reels-mode .reel-card-actions {
    flex-shrink: 0 !important;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    padding-top: 8px !important;
    margin-top: auto !important;
    border-top: 1px solid var(--border-color) !important;
    width: 100% !important;
    position: relative !important;
    z-index: 20 !important;
    background-color: var(--card-bg) !important;
  }

  body.mobile-reels-mode .reel-btn-read {
    display: flex !important;
    width: 100% !important;
    text-align: center !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 10px 14px !important;
    font-size: 0.85rem !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
    background-color: var(--btn-primary-bg) !important;
    color: var(--btn-primary-text) !important;
    text-decoration: none !important;
    box-sizing: border-box !important;
  }
}

@media (min-width: 1024px) {
  .reel-scroll-track {
    height: calc(100vh - 210px);
    min-height: 540px;
    max-height: 720px;
  }
}

/* Mobile Filter Bottom Sheet Animation */
#mobileFilterDrawer {
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#mobileFilterDrawer.open {
  transform: translateY(0) !important;
}

.reel-column-wrapper {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* Below the desktop breakpoint the inactive reel column must stay hidden.
   The base `display: flex` above would otherwise beat Tailwind's non-important
   `hidden` class for 768-1023px screens, showing two sections at once.
   At >=1024px we deliberately let Tailwind's `lg:flex` win (2-up split view). */
@media (max-width: 1023px) {
  .reel-column-wrapper.hidden {
    display: none !important;
  }
}

.reel-column-header {
  padding: 0.875rem 1rem;
  background-color: var(--bg-surface-2);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.reel-column-title {
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.reel-card-snap {
  height: 100%;
  min-height: 100%;
  max-height: 100%;
  box-sizing: border-box;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.5rem;
  border-radius: 1rem;
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s ease, background-color 0.2s ease;
  color: var(--text-main);
  overflow: hidden;
}

.reel-card-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.reel-card-actions {
  flex-shrink: 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
  width: 100%;
  background-color: inherit;
}

@media (min-width: 640px) {
  .reel-card-snap {
    padding: 1.75rem;
  }
}

.reel-card-snap:hover {
  border-color: var(--card-border-hover);
}

/* Reel Title & Links - 100% Guaranteed High Contrast in Light & Dark */
.reel-card-title {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 0.85rem;
  color: var(--text-primary) !important;
}

.reel-card-title a {
  color: var(--text-primary) !important;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.reel-card-title a:hover {
  text-decoration: underline;
  opacity: 0.85;
}

.reel-source-name {
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.025em;
  font-size: 0.8rem;
}

.reel-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.65rem;
  font-family: var(--font-mono);
  font-weight: 700;
  text-transform: uppercase;
  background-color: var(--pill-active-bg);
  color: var(--pill-active-text) !important;
}

.reel-badge-sec {
  padding: 0.15rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.65rem;
  font-family: var(--font-mono);
  font-weight: 700;
  text-transform: uppercase;
  background-color: var(--bg-surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

/* Reel Summary Box */
.reel-summary-box {
  background-color: var(--bg-summary-box);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.reel-summary-label {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.reel-summary-text {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
}

.reel-btn-read {
  padding: 0.5rem 0.95rem;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
  border-radius: 0.5rem;
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-text) !important;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: opacity 0.15s ease;
  text-decoration: none;
}

.reel-btn-read:hover {
  opacity: 0.85;
}

.reel-btn-nav {
  padding: 0.45rem 0.75rem;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  border-radius: 0.5rem;
  background-color: var(--bg-surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.15s ease;
}

.reel-btn-nav:hover {
  background-color: var(--border-color);
}

.reel-btn-next {
  padding: 0.45rem 0.875rem;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
  border-radius: 0.5rem;
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-text) !important;
  border: 1px solid var(--border-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  transition: opacity 0.15s ease;
}

.reel-btn-next:hover {
  opacity: 0.85;
}

/* =========================================
   INSTAGRAM / TIKTOK STYLE TOP SWITCHER
   ========================================= */

.reels-tab-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.25rem;
  background-color: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  width: fit-content;
}

.reels-tab-btn {
  padding: 0.45rem 1.1rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  font-weight: 600;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  background: transparent;
  border: none;
}

.reels-tab-btn:hover {
  color: var(--text-primary);
}

.reels-tab-btn.active {
  background-color: var(--pill-active-bg);
  color: var(--pill-active-text);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Component Theming Hooks */
.themed-sidebar {
  background-color: var(--bg-sidebar);
  border-color: var(--border-color);
  color: var(--text-main);
}

.themed-header {
  background-color: var(--bg-header);
  border-color: var(--border-color);
  color: var(--text-main);
}

.themed-main {
  background-color: var(--bg-page);
  color: var(--text-main);
}

.themed-input {
  background-color: var(--input-bg);
  border-color: var(--input-border);
  color: var(--input-text);
}

.themed-input:focus {
  border-color: var(--text-primary);
}

.themed-card {
  background-color: var(--card-bg);
  border-color: var(--card-border);
  color: var(--text-main);
}

.themed-card:hover {
  border-color: var(--card-border-hover);
}

/* Category Sidebar Navigation Items */
.nav-cat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.15s ease;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
}

.nav-cat-btn:hover {
  background-color: var(--bg-surface-2);
  color: var(--text-primary);
}

.nav-cat-btn.active {
  background-color: var(--pill-active-bg);
  color: var(--pill-active-text);
  font-weight: 700;
}

.nav-cat-count {
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
  background-color: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.nav-cat-btn.active .nav-cat-count {
  background-color: var(--pill-active-bg);
  color: var(--pill-active-text);
  border-color: transparent;
}

/* =========================================
   LIST VIEW UI/UX ENHANCEMENTS (LINEAR / PRO FEEL)
   ========================================= */

.list-view-container {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

.list-view-row {
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background-color: var(--card-bg);
}

@media (min-width: 640px) {
  .list-view-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
  }
}

.list-view-row:last-child {
  border-bottom: none;
}

.list-view-row:hover {
  background-color: var(--bg-surface-2);
}

.list-title {
  color: var(--text-primary) !important;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.4;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.list-title:hover {
  text-decoration: underline;
  opacity: 0.85;
}

.list-summary {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.5;
  margin-top: 0.35rem;
  font-family: 'Inter', sans-serif;
}

.list-btn-open {
  padding: 0.5rem 0.95rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-text) !important;
  border: 1px solid var(--border-color);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  transition: transform 0.1s ease, opacity 0.15s ease;
  cursor: pointer;
  text-decoration: none;
}

.list-btn-open:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.list-btn-open:active {
  transform: scale(0.96);
}

/* =========================================
   SETTINGS MODAL & OPTIONS
   ========================================= */

.settings-option-card {
  border: 1px solid var(--border-color);
  background-color: var(--card-bg);
  transition: all 0.15s ease;
}

.settings-option-card:hover {
  border-color: var(--text-primary);
  background-color: var(--bg-surface-2);
}

.settings-option-card.active {
  border-color: var(--text-primary) !important;
  background-color: var(--bg-surface-2) !important;
}

.settings-option-card.active .setting-check {
  background-color: var(--pill-active-bg) !important;
  color: var(--pill-active-text) !important;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.animate-spin {
  animation: spin 0.8s linear infinite !important;
}
