/**
 * Shared CSS Styles
 * Common styles used across all pages
 */

/* ===== Screen Reader Only ===== */
/* Hides content visually but keeps it accessible to screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ===== Prevent White Flash on Load ===== */
html {
  background-color: #1a1a1a;
}

body {
  background-color: #1a1a1a;
  /* Hide content until Tailwind loads */
  opacity: 0;
  transition: opacity 0.15s ease-in;
}

body.ready {
  opacity: 1;
}

/* ===== Custom Scrollbar (Global) ===== */
/* CSS Variables for scrollbar theming */
:root {
  --scrollbar-thumb: rgba(120, 120, 128, 0.3);
  --scrollbar-thumb-hover: rgba(120, 120, 128, 0.5);
  --scrollbar-width: 8px;
}

.dark {
  --scrollbar-thumb: rgba(255, 255, 255, 0.15);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.3);
}

/* WebKit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  height: var(--scrollbar-width);
  width: var(--scrollbar-width);
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  background-clip: content-box;
  border: 2px solid transparent;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  background-clip: content-box;
  border: 2px solid transparent;
}

/* Firefox */
* {
  scrollbar-color: var(--scrollbar-thumb) transparent;
  scrollbar-width: thin;
}

/* Thin scrollbar variant for panels/sidebars */
.scrollbar-thin::-webkit-scrollbar {
  width: 5px;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border: 0;
  border-radius: 3px;
}

.scrollbar-thin::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* ===== Custom Select Dropdown Styling ===== */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1rem;
  padding-right: 2rem;
}

.dark select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
}

/* Options need dark background and text for readability (browser renders natively) */
select option {
  background-color: #1f2937;
  color: #f3f4f6;
  padding: 0.5rem;
}


/* ===== Glass Panel Effect ===== */
.glass-panel {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.dark .glass-panel {
  background: rgba(23, 23, 23, 0.95);
}

/* ===== Hero Background with Crossfade ===== */
.hero-bg {
  position: relative;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

/* Crossfade overlay for theme transition */
.hero-bg::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
  pointer-events: none;
}

/* When transitioning, show the overlay */
.hero-bg.theme-transitioning::before {
  opacity: 1;
}

/* ===== Input Focus States ===== */
input:focus, select:focus {
  outline: none;
}

input:not([type="checkbox"]):not([type="radio"]):focus {
  box-shadow: 0 0 0 3px rgba(139, 109, 74, 0.15);
}

.dark input:not([type="checkbox"]):not([type="radio"]):focus {
  box-shadow: 0 0 0 3px rgba(124, 174, 102, 0.15);
}

/* ===== Button Transitions ===== */
button[type="submit"] {
  transition: transform 0.15s ease, opacity 0.15s ease;
}

button[type="submit"]:hover {
  transform: translateY(-1px);
}

button[type="submit"]:active {
  transform: translateY(0);
}

/* ===== Transitions ===== */
input, select, button {
  transition: box-shadow 0.2s ease, background-color 0.2s ease;
}

/* ===== Hide Browser Password Toggle ===== */
/* MS Edge & Chromium */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
  display: none;
}

/* Safari */
input[type="password"]::-webkit-credentials-auto-fill-button,
input[type="password"]::-webkit-textfield-decoration-container {
  visibility: hidden;
  pointer-events: none;
}

/* Chrome - password reveal eye */
input::-webkit-contacts-auto-fill-button,
input::-webkit-password-reveal {
  display: none !important;
}

/* ===== Unified Mobile Footer ===== */
/* Floating footer with tab title and action icons */
.mobile-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
  z-index: 30;
}

.mobile-footer > * {
  pointer-events: auto;
}

/* Tab title styling (bottom-left) */
.mobile-tab-title {
  font-size: 1.875rem;
  font-weight: 700;
  color: white;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

.mobile-tab-icon {
  color: white;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

/* Card-less input style for hero backgrounds */
.mobile-input {
  width: 100%;
  border-radius: 0.75rem;
  border: 0;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0.75rem 1rem;
  font-size: 1rem;
  color: white;
  outline: none;
}

.mobile-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.mobile-input:focus {
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

/* Action icon buttons (theme, language, etc.) */
.action-icon-btn {
  color: rgba(255, 255, 255, 0.7);
  transition: color 0.15s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.action-icon-btn:hover {
  color: white;
}

/* Lock scroll for full-viewport layouts */
.mobile-lock-scroll {
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

/* ===== FAB (Floating Action Button) ===== */
.fab {
  position: fixed;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  z-index: 25;
}

.fab:hover {
  transform: scale(1.05);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
}

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

/* ===== Card-less Info Box ===== */
.info-box {
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 1rem;
  color: white;
}

/* ===== Dropzone Style ===== */
.dropzone-unified {
  border-radius: 1rem;
  border: 2px dashed rgba(255, 255, 255, 0.4);
  padding: 2rem;
  text-align: center;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.dropzone-unified:hover,
.dropzone-unified.dragover {
  border-color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.05);
}

/* ===== Collapsible Content Base ===== */
/* Base class for collapsible/expandable content with fade animation */
.collapsible-content {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.35s ease-out, opacity 0.25s ease-out;
}

.collapsible-content.open {
  max-height: var(--collapsible-max-height, 800px);
  opacity: 1;
  transition: max-height 0.35s ease-in, opacity 0.25s ease-in 0.1s;
}

/* ===== Menu Page Styles ===== */

/* Tab panels container for swipe */
.tab-panels-container {
  position: relative;
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
}

.tab-panels-wrapper {
  display: flex;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
  align-items: flex-start;
  height: auto;
}

.tab-panel {
  flex: 0 0 100%;
  min-width: 100%;
  padding: 0 2px;
}

/* Links panel uses flex layout with internal scroll - grows from bottom */
#panelLinks {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end; /* Content anchored to bottom, grows upward */
  max-height: calc(100dvh - 75px); /* Footer ~60px + safe-area */
}

#panelLinks .flex-1 {
  min-height: 0; /* Allow flex child to shrink below content size */
  flex: 0 1 auto; /* Don't grow, can shrink, size by content */
}

.tab-panel:not(.active) {
  visibility: hidden;
  height: 0;
  overflow: hidden;
}

.tab-panel.active {
  visibility: visible;
  height: auto;
}

/* About section toggle buttons */
.about-toggle-btn {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid transparent;
}
.about-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.9);
}
.about-toggle-btn.active {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border-color: rgba(255, 255, 255, 0.3);
}

/* About section slide animation - extends collapsible-content */
.about-section {
  --collapsible-max-height: 1000px;
}

/* Button loading state */
.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}
.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.btn-loading > * {
  visibility: hidden;
}

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

/* Link card selection state */
.link-card {
  border: 2px solid transparent;
}
.link-card.selected {
  border-color: rgba(139, 109, 74, 0.6);
  background: rgba(139, 109, 74, 0.1);
}
.dark .link-card.selected {
  border-color: rgba(124, 174, 102, 0.6);
  background: rgba(124, 174, 102, 0.1);
}

/* Card action bar - slide animation */
.card-actions {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.3s ease-out, opacity 0.2s ease-out;
}
.card-actions.expanded {
  grid-template-rows: 1fr;
  opacity: 1;
}
.card-actions-inner {
  overflow: hidden;
}

/* Tab navigation buttons in footer */
.tab-nav-btn {
  color: rgba(255,255,255,0.5);
  background: transparent;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}
.tab-nav-btn:hover {
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.1);
}
.tab-nav-btn.active {
  color: white;
  background: rgba(255,255,255,0.2);
}

/* Link card info row - default (no wrap) */
.link-card-info {
  white-space: nowrap;
  overflow: hidden;
}

/* Date display: short by default, long when card is selected */
.link-card .date-long {
  display: none;
}
.link-card.selected .date-short {
  display: none;
}
.link-card.selected .date-long {
  display: inline;
}

/* ===== Responsive Breakpoints ===== */

/* Small phones (< 380px, e.g. iPhone SE, Galaxy S8) */
@media (max-width: 380px) {
  /* Reduce padding globally */
  .mobile-footer {
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .mobile-tab-title {
    font-size: 1.5rem;
  }

  .mobile-tab-icon {
    width: 1.5rem;
    height: 1.5rem;
  }

  /* Smaller dropzone */
  .dropzone-unified {
    padding: 1.25rem;
  }

  /* Smaller info boxes */
  .info-box {
    padding: 0.75rem;
    font-size: 0.8125rem;
  }

  /* Smaller inputs */
  .mobile-input {
    padding: 0.625rem 0.75rem;
    font-size: 0.9375rem;
  }

  /* Link cards - tighter spacing */
  .link-card {
    padding: 0.625rem;
  }

  /* Link card info row - allow wrapping on small screens */
  .link-card-info {
    flex-wrap: wrap !important;
    white-space: normal !important;
    overflow: visible !important;
    gap: 0.25rem 0.5rem !important;
  }

  /* Tab navigation */
  .tab-nav-btn {
    padding: 0.25rem 0.375rem;
    font-size: 0.8125rem;
  }
  .tab-nav-btn svg {
    width: 1rem;
    height: 1rem;
  }


  /* Action icon buttons */
  .action-icon-btn svg {
    width: 1.125rem;
    height: 1.125rem;
  }
}

/* Medium phones (380px - 480px) */
@media (max-width: 480px) {
  .tab-nav-btn {
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
  }

  .mobile-tab-title {
    font-size: 1.625rem;
  }
}

/* ===== Menu Page Layout ===== */
/* These styles use ID selectors for page-specific layout that shouldn't be reused */
body.menu-page {
  padding-bottom: env(safe-area-inset-bottom);
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

#swipeArea {
  padding-bottom: calc(60px + env(safe-area-inset-bottom));
}

#swipeArea > div {
  width: 100%;
  max-width: 48rem;
  align-self: flex-end;
}

/* Background preview containers - dynamic styles set via JS */
.bg-preview {
  width: 100%;
  height: 6rem;
  background-size: cover;
  background-position: center;
}

/* Mobile footer safe-area padding */
.mobile-footer-safe {
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

/* ===== Sidepanel ===== */
.sidepanel {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

.sidepanel.open {
  pointer-events: auto;
}

.sidepanel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidepanel.open .sidepanel-backdrop {
  opacity: 1;
}

.sidepanel-content {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  max-width: 320px;
  background: rgba(23, 23, 23, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidepanel.open .sidepanel-content {
  transform: translateX(0);
}

.sidepanel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.sidepanel-account {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.sidepanel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.sidepanel-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

/* Section Headers (collapsible) */
.sidepanel-section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.5);
  transition: color 0.2s;
}

.sidepanel-section-toggle:hover {
  color: rgba(255, 255, 255, 0.8);
}

.sidepanel-section-toggle::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, rgba(255, 255, 255, 0.1), transparent);
}

.sidepanel-section-toggle .chevron {
  width: 0.875rem;
  height: 0.875rem;
  transition: transform 0.25s ease;
  opacity: 0.5;
}

.sidepanel-section-toggle.open .chevron {
  transform: rotate(0deg);
}

.sidepanel-section-toggle:not(.open) .chevron {
  transform: rotate(-90deg);
}

/* Section content - extends collapsible-content with layout */
.sidepanel-section-content {
  --collapsible-max-height: 800px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 0;
  padding-top: 0;
  transition: max-height 0.35s ease-out, opacity 0.25s ease-out, padding 0.25s ease-out;
}

.sidepanel-section-content.open {
  padding-bottom: 0.5rem;
  padding-top: 0.5rem;
  transition: max-height 0.35s ease-in, opacity 0.25s ease-in 0.1s, padding 0.25s ease-in;
}

/* Collapsible section toggle */
.sidepanel-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0.75rem;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.875rem;
  transition: background 0.2s, color 0.2s;
}

.sidepanel-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

.sidepanel-toggle .chevron {
  transition: transform 0.25s ease;
}

.sidepanel-toggle.open .chevron {
  transform: rotate(0deg);
}

.sidepanel-toggle:not(.open) .chevron {
  transform: rotate(-90deg);
}

/* Collapsible content - extends collapsible-content */
.sidepanel-collapse {
  --collapsible-max-height: 500px;
}
