/* ===== PROFESSIONAL MOBILE CSS - ENHANCED VERSION ===== */
/* Baseline mobile vars and utilities (safe fallbacks) */
:root {
  --space-xxs: 2px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --transition-fast: 150ms;
  --primary: #3b82f6;
  --fg: var(--text-primary, #333);
  --line: rgba(0, 0, 0, 0.1);
}

/* Global overflow and media responsiveness */
html, body { overflow-x: hidden !important; }
img, svg, video { max-width: 100% !important; height: auto !important; }

/* Performance: disable heavy background animations and reduce shadows on mobile */
@media only screen and (max-width: 980px) {
  html, body { animation: none !important; }
  /* Lighter shadows for cards/modals to reduce GPU load */
  .card, .vp-card, .menu, .vp-navbar, .vp-footer, .metric-card, .chart-container,
  .top-features, .recent-activity, .system-health, .recent-errors, .quick-actions {
    box-shadow: 0 6px 16px rgba(0,0,0,0.18) !important;
  }
  /* Prevent iOS zoom on inputs by ensuring font-size >= 16px */
  input, select, textarea, button {
    font-size: 16px !important;
  }
}

/* ===== MOBILE HEADER - REMOVE CONFLICTING RULES ===== */
/* NOTE: Main mobile header CSS is now in base.html inline for consistency */

/* ===== MOBILE USER MENU CRITICAL FIXES ===== */
@media only screen and (max-width: 980px) {
  /* Force user menu to be visible on all mobile devices */
  #vpUserMenu.menu {
    position: fixed !important;
    top: auto !important;
    bottom: 5px !important;
    left: 5px !important;
    right: 5px !important;
    z-index: 999999 !important;
    transform: none !important;
    -webkit-transform: none !important;
    width: auto !important;
    max-width: none !important;
    min-width: auto !important;
    will-change: transform, opacity !important;
    contain: layout style paint !important;
    height: auto !important;
  /* Use viewport-relative min-height to better fit small screens */
  min-height: 60vh !important;
    max-height: calc(100vh - 20px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 20px !important;
    border-radius: 20px !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4) !important;
  }
  
  /* Ensure parent container doesn't clip the menu */
  .vp-user {
    position: static !important;
    overflow: visible !important;
  }
  
  .vp-controls {
    overflow: visible !important;
  }
  
  .vp-navbar {
    overflow: visible !important;
  }
  
  /* Force all containers to not clip */
  .vp-container {
    overflow: visible !important;
  }
  
  /* Mobile specific menu item styles */
  #vpUserMenu.menu .menu-item {
    min-height: 48px !important;
    padding: 12px 16px !important;
    font-size: 16px !important;
    touch-action: manipulation !important;
  }
}

/* Portrait specific fixes */
@media only screen and (max-width: 980px) and (orientation: portrait) {
  #vpUserMenu.menu {
    bottom: 5px !important;
    max-height: calc(100vh - 20px) !important;
  /* Slightly taller in portrait but still viewport-relative */
  min-height: 70vh !important;
    height: auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
  
  body {
    overflow-x: hidden !important;
  }
  
  /* Ensure header doesn't interfere */
  .vp-navbar {
    position: relative !important;
    z-index: 1000 !important;
  }
  
  /* Allow menu to expand for content */
  #vpUserMenu.menu .menu-item {
    min-height: 56px !important;
    padding: 18px 24px !important;
    white-space: nowrap !important;
    font-size: 17px !important;
  }
  
  /* Better spacing for user info */
  #vpUserMenu.menu .muted {
    padding: 24px !important;
    margin-bottom: 12px !important;
  }
  
  /* Ensure all content is visible */
  #vpUserMenu.menu hr {
    margin: 12px 0 !important;
  }
}

/* Landscape specific fixes */
@media only screen and (max-width: 980px) and (orientation: landscape) {
  #vpUserMenu.menu {
    bottom: 5px !important;
    max-height: calc(100vh - 20px) !important;
    min-height: 500px !important;
    height: auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
  
  /* Optimized padding in landscape to fit more content */
  #vpUserMenu.menu .menu-item {
    min-height: 52px !important;
    padding: 16px 20px !important;
    font-size: 16px !important;
  }
  
  #vpUserMenu.menu .muted {
    padding: 20px !important;
    margin-bottom: 8px !important;
  }
  
  /* Ensure all content is visible */
  #vpUserMenu.menu hr {
    margin: 8px 0 !important;
  }
}

/* ===== MOBILE ANIMATIONS ===== */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ===== MOBILE CONTAINER & LAYOUT ===== */
.vp-container { 
  width: 96%; 
  padding: 0 var(--space-sm);
  margin: 0 auto;
  max-width: 100vw;
}

/* ===== ENHANCED MOBILE NAVIGATION ===== */
.vp-nav-inner { 
  display: flex; 
  flex-wrap: wrap; 
  gap: var(--space-sm); 
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) 0;
  min-height: 56px;
}

.vp-brand { 
  flex: 1;
  display: flex; 
  justify-content: flex-start;
}

.vp-logo { 
  display: inline-flex; 
  align-items: center; 
  gap: var(--space-xs); 
  text-decoration: none; 
  color: var(--fg);
  font-size: 1rem;
  font-weight: 700;
}

.vp-logo .brand-logo { 
  margin-right: 0;
  height: 36px !important;
}

/* Hide burger button on desktop */
.vp-burger { 
  display: none;
}

/* Enhanced mobile burger button - FIXED */
@media only screen and (max-width: 980px) {
  .vp-burger { 
    display: inline-flex !important; 
    align-items: center; 
    justify-content: center; 
    border: 2px solid var(--line); 
    background: var(--card); 
    color: var(--fg); 
    border-radius: var(--radius-sm); 
    padding: var(--space-sm) var(--space-md); 
    cursor: pointer; 
    margin: 0;
    transition: all var(--transition-fast);
    font-size: 1.2rem;
    min-height: 44px;
    min-width: 44px;
    z-index: 1001;
    position: relative;
  }

  .vp-burger:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
  }

  .vp-burger:active {
    transform: scale(0.95);
  }
}

/* Hidden checkbox for mobile nav toggle */
.vp-nav-toggle {
  display: none;
}

/* Mobile navigation menu - HIDDEN BY DEFAULT */
@media only screen and (max-width: 980px) {
  .vp-nav { 
    display: none !important; 
    flex-direction: column; 
    gap: var(--space-xs); 
    width: 100%;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-top: var(--space-sm);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    order: 3;
    flex-basis: 100%;
    overflow-x: hidden;
  }
}

.vp-nav a {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  font-weight: 500;
  text-align: center;
  color: var(--fg);
  text-decoration: none;
  display: block;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vp-nav a:hover {
  background: rgba(59, 130, 246, 0.1);
  transform: translateY(-1px);
}

.vp-nav a:active {
  background: rgba(59, 130, 246, 0.15);
  transform: translateY(0);
}

/* ULTIMATE MOBILE MENU FIX - GUARANTEED TO WORK */
@media only screen and (max-width: 980px) {
  /* FORCE HIDE MENU BY DEFAULT */
  .vp-nav, #vpNav {
    display: none !important;
  }
  
  /* FORCE SHOW MENU WHEN CHECKBOX IS CHECKED */
  #vpNavToggle:checked ~ .vp-nav,
  #vpNavToggle:checked ~ #vpNav { 
    display: flex !important;
    flex-direction: column !important;
  }
  
  /* BURGER BUTTON ACTIVE STATE */
  #vpNavToggle:checked + .vp-burger { 
    background: var(--primary) !important;
    color: white !important;
    border-color: var(--primary) !important;
  }
  
  /* CONTAINER POSITIONING */
  .vp-nav-inner {
    position: relative;
    flex-wrap: wrap;
  }
}

/* Mobile controls */
.vp-controls { 
  display: flex; 
  flex-wrap: wrap; 
  gap: var(--space-sm); 
  width: 100%; 
  justify-content: space-between;
  align-items: center;
}

.vp-controls .btn[href^="/auth/login"] { 
  display: none; 
}

.vp-inline span[data-i18n="lang_toggle"] { 
  display: none; 
}

/* Enhanced language selector for mobile */
.vp-inline select {
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
  font-size: 0.875rem;
}

/* ===== MOBILE USER MENU STYLES ===== */
.vp-user {
  position: relative;
}

.avatar-btn {
  width: 28px !important;
  height: 28px !important;
  font-size: 0.8rem;
}

.menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  left: auto;
  min-width: 220px;
  max-width: 90vw;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  padding: var(--space-xs);
  display: none;
  z-index: 1000;
}

/* Responsive tables: prevent horizontal scroll on page level */
@media only screen and (max-width: 980px) {
  table, .table, .vp-table {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border-collapse: collapse !important;
  }
}

/* ===== MOBILE FIX: HIDE SUMMARY MARKER AND FILE INPUT OVERLAY ===== */
@media only screen and (max-width: 980px) {
  /* Remove blue triangle from "Advanced" summary */
  details summary::-webkit-details-marker,
  details > summary::-webkit-details-marker {
    display: none !important;
  }
  details summary::marker,
  details > summary::marker {
    content: '' !important;
    display: none !important;
  }
  /* In case any theme injects its own icon */
  details summary::before,
  details > summary::before { content: '' !important; display: none !important; }

  details summary {
    list-style: none !important;
    padding-left: 12px !important;
  }
  
  /* Remove iOS upload icon from file inputs */
  input[type="file"]::-webkit-file-upload-button {
    -webkit-appearance: none !important;
    appearance: none !important;
    background-image: none !important;
    background: rgba(102, 126, 234, 0.1) !important;
    border: 2px solid rgba(102, 126, 234, 0.3) !important;
    padding: 12px 20px !important;
    border-radius: 8px !important;
    color: inherit !important;
    font-size: 16px !important;
    cursor: pointer !important;
  }
  
  input[type="file"]::file-selector-button {
    -webkit-appearance: none !important;
    appearance: none !important;
    background-image: none !important;
    background: rgba(102, 126, 234, 0.1) !important;
    border: 2px solid rgba(102, 126, 234, 0.3) !important;
    padding: 12px 20px !important;
    border-radius: 8px !important;
    color: inherit !important;
    font-size: 16px !important;
    cursor: pointer !important;
  }

  /* Stronger hide for the actual input inside our drop zones on mobile */
  html.is-touch .dragdrop-zone input[type="file"],
  html.is-touch .drag-drop-zone input[type="file"],
  .mobile-file-input input[type="file"],
  .mobile-file-control[type="file"] {
    position: absolute !important;
    left: -9999px !important;
    width: 0.1px !important;
    height: 0.1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
  }
}

/* Cards general spacing on mobile */
@media only screen and (max-width: 980px) {
  .card, .vp-card {
    border-radius: var(--radius-md) !important;
    padding: var(--space-md) !important;
    box-sizing: border-box !important;
  }
}

/* Inputs and buttons: touch size and no iOS zoom */
@media only screen and (max-width: 980px) {
  /* Mobile CTA and filename inside drop zones */
  .mobile-file-hint {
    display: block !important;
    text-align: center !important;
    color: var(--text-secondary, #888) !important;
    margin: 0 !important; /* no extra margins to avoid growing the block */
    font-size: 14px !important;
    line-height: 1.35 !important;
    position: relative !important;
    top: 12px !important; /* a bit more separation from the icon */
  }
  .mobile-file-name {
    display: none !important;
    text-align: center !important;
    margin: 10px 0 0 0 !important;
    font-weight: 600 !important;
    color: var(--text-primary, #fff) !important;
    word-break: break-word !important;
  }
  .drag-drop-zone.has-file .mobile-file-hint,
  .dragdrop-zone.has-file .mobile-file-hint { display: none !important; }
  .drag-drop-zone.has-file .mobile-file-name,
  .dragdrop-zone.has-file .mobile-file-name { display: block !important; }

  /* Restore prior drop-zone vertical rhythm on mobile (no shrink) */
  .drag-drop-zone,
  .dragdrop-zone {
    padding-top: 28px !important;
    padding-bottom: 28px !important;
  }

  /* Extra-strong suppression of any pseudo icons on drop zones (mobile only) */
  .drag-drop-zone::before,
  .drag-drop-zone::after,
  .dragdrop-zone::before,
  .dragdrop-zone::after,
  .enhanced-file-input::before,
  .enhanced-file-input::after {
    content: '' !important;
    display: none !important;
    background: none !important;
    mask: none !important;
    -webkit-mask: none !important;
  }

  /* If any UA adds a background/icon to file input, wipe it */
  html.is-touch input[type="file"],
  .mobile-file-input input[type="file"],
  .mobile-file-control[type="file"] {
    background: transparent !important;
    background-image: none !important;
  }

  input, select, textarea, button, .btn, .input {
    font-size: 16px !important; /* prevent iOS zoom */
    min-height: 44px !important; /* touch target */
  }
  label { font-size: 14px !important; }
  .form-group, .field, .form-row { width: 100% !important; }
}

/* Common grids collapse to 1 column on mobile */
@media only screen and (max-width: 980px) {
  .templates-grid,
  .presets-grid,
  .summary-grid,
  .trends-grid,
  .metrics-grid,
  .patterns-grid,
  .prediction-grid,
  .temporal-grid,
  .trending-grid,
  .insights-grid,
  .pricing-grid,
  .platforms-grid,
  .vp-grid,
  .features-grid,
  .feature-grid,
  .enhancement-type-grid,
  .vp-footer-grid,
  .stats-grid,
  .admin-grid,
  .actions-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: var(--space-md) !important;
  }
}

/* Modal usability on mobile */
@media only screen and (max-width: 980px) {
  .modal { align-items: center !important; justify-content: center !important; padding: var(--space-sm) !important; }
  .modal-content {
    width: 96vw !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .modal-header, .modal-footer { position: sticky; top: 0; bottom: 0; background: var(--card); z-index: 1; }
  .modal-close { min-width: 44px; min-height: 44px; line-height: 1; }
}

.menu-item {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-fast);
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  min-height: 40px;
}

.menu-item:hover {
  background-color: rgba(59, 130, 246, 0.08);
  color: var(--primary);
  transform: translateX(2px);
}

.menu-item:active {
  background-color: rgba(59, 130, 246, 0.12);
  transform: translateX(0);
}

/* Mobile user info section */
.menu .muted {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space-xs);
}

.menu .muted > div:first-child {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  align-items: flex-start !important;
}

/* Pills styling for mobile */
.menu .pill {
  font-size: 10px;
  padding: 1px 4px;
}

/* Divider for mobile */
.divider {
  height: 1px;
  background: var(--line);
  margin: var(--space-xs) var(--space-sm);
  border-radius: 1px;
}

.brand-logo { 
  height: 40px !important; 
}

.mobile-demo { 
  display: block !important; 
}

/* ===== MOBILE HOME & CARDS ===== */
.home-grid { 
  display: grid; 
  grid-template-columns: 1fr; 
  gap: var(--space-md); 
  align-items: start;
}

.hero { 
  display: none; /* esconder hero en móvil */
}

/* Enhanced mobile hero replacement */
.mobile-hero-replacement { 
  display: block; 
  margin-bottom: var(--space-lg);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}

@media (min-width: 981px) {
  .mobile-hero-replacement { 
    display: none !important; 
  }
}

.mobile-hero-title { 
  font-size: 1.5rem; 
  font-weight: 700; 
  margin: 0 0 var(--space-md) 0; 
  text-align: center; 
  overflow-wrap: anywhere; 
  word-break: normal;
  color: var(--fg);
  font-family: var(--font-head);
}

/* Enhanced mobile features */
.mobile-features { 
  display: flex; 
  flex-direction: column; 
  gap: var(--space-sm); 
  margin-bottom: var(--space-md);
}

.mobile-features .feature-pill { 
  width: 100%; 
  font-size: 1rem; 
  align-items: flex-start; 
  padding: var(--space-md); 
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.mobile-features .feature-pill:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.mobile-features .icon { 
  font-size: 1.4em; 
  margin-right: var(--space-sm);
  color: var(--primary);
}

.mobile-features b, .mobile-features .muted { 
  overflow-wrap: anywhere; 
  word-break: normal; 
}

.grid-2 { 
  grid-template-columns: 1fr; 
}

/* ===== MOBILE CARDS & BUTTONS ===== */
.card {
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  border-radius: var(--radius-md);
}

.btn {
  width: 100%;
  justify-content: center;
  padding: var(--space-md) var(--space-lg);
  font-size: 1rem;
  font-weight: 600;
}

/* ===== MOBILE TYPOGRAPHY ===== */
h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

/* ===== MOBILE FORMS ===== */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
}

.form-group {
  margin-bottom: var(--space-md);
}

.enhanced-file-input {
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.input, select, textarea {
  font-size: 16px; /* Prevents zoom on iOS */
  padding: var(--space-md);
}

/* Touch improvements */
.btn, button {
  -webkit-tap-highlight-color: transparent !important;
  touch-action: manipulation !important;
}

/* Tone down heavy transforms on small screens */
.section-card { transform: none !important; }
.section-card:hover { transform: none !important; }

@media only screen and (max-width: 480px) {
  .form-row { grid-template-columns: 1fr !important; }
}

/* ===== MOBILE INTERACTIONS ===== */
.toast {
  right: var(--space-sm);
  left: var(--space-sm);
  max-width: none;
}

.loading-spinner {
  width: 24px;
  height: 24px;
}

/* ===== MOBILE TEXT WRAPPING ===== */
.hero-card { 
  display: flex; 
  flex-direction: column; 
  align-items: flex-start; 
}

.hero-card > * { 
  min-width: 0; 
}

.hero-media img { 
  max-width: 100%; 
}

.feature-pill > div { 
  min-width: 0; 
}

.feature-pill b, .feature-pill .muted { 
  overflow-wrap: anywhere; 
  word-break: normal; 
}

.hero-copy h1, .hero-copy p { 
  overflow-wrap: anywhere; 
  word-break: normal; 
}

.stat b, .stat .muted { 
  overflow-wrap: anywhere; 
}

/* ===== MOBILE FORM LAYOUTS ===== */
.home-grid .card form.row { 
  flex-direction: column; 
  align-items: stretch; 
}

.home-grid .card .input, .home-grid .card .btn { 
  width: 100%; 
}

.home-grid .card .input { 
  min-width: 0 !important; 
}

/* ===== MOBILE NAVIGATION ITEMS ===== */
.mobile-login { 
  display: block !important; 
}

/* ===== MOBILE TOUCH TARGETS ===== */
.vp-nav a, .btn, input, select, textarea {
  min-height: 44px; /* Apple's recommended minimum touch target */
}

/* ===== ENHANCED MOBILE FORMS ===== */
.form-row {
  grid-template-columns: 1fr !important;
  gap: var(--space-md);
}

.form-group {
  width: 100%;
  margin-bottom: var(--space-lg);
}

.form-group label {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-sm);
  display: block;
}

.form-group input, 
.form-group select, 
.form-group textarea {
  width: 100%;
  min-height: 48px;
  font-size: 16px; /* Prevents zoom on iOS */
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 2px solid var(--line);
  transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

/* Enhanced mobile buttons */
.btn {
  width: 100%;
  min-height: 48px;
  padding: var(--space-md) var(--space-lg);
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: 2px solid var(--primary);
}

.btn-primary:hover,
.btn-primary:active {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: none; /* Disable transform on mobile for better UX */
}

/* Enhanced mobile drag & drop */
.enhanced-file-input,
.drag-drop-zone {
  min-height: 120px;
  padding: var(--space-lg);
  border: 2px dashed var(--line);
  border-radius: var(--radius-md);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  background: var(--card);
  transition: all var(--transition-fast);
}

.enhanced-file-input:hover,
.drag-drop-zone:hover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.05);
}

.file-drop-active {
  border-color: var(--primary) !important;
  background: rgba(59, 130, 246, 0.1) !important;
  animation: pulse 1s infinite;
}

/* Mobile toast notifications */
.toast {
  left: var(--space-sm);
  right: var(--space-sm);
  max-width: none;
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  font-size: 0.875rem;
}

/* Enhanced mobile cards */
.card {
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.card:hover {
  transform: none; /* Disable hover transforms on mobile */
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

/* Mobile details/summary */
details {
  padding: var(--space-md);
  margin: var(--space-md) 0;
}

summary {
  padding: var(--space-md);
  font-size: 1rem;
  font-weight: 600;
}

/* Mobile progress indicators */
.progress-bar {
  height: 8px;
  border-radius: 4px;
}

.loading-spinner {
  width: 24px;
  height: 24px;
}

/* Mobile file preview */
.file-preview {
  padding: var(--space-md);
  margin-top: var(--space-md);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
}

/* Mobile validation feedback */
.field-feedback {
  font-size: 0.75rem;
  margin-top: var(--space-xs);
}

/* Hide desktop hero on mobile, show mobile replacement */
.desktop-hero { 
  display: none !important; 
}

.mobile-hero-replacement { 
  display: block; 
  margin-bottom: var(--space-lg); 
}

@media (min-width: 981px) {
  .desktop-hero { 
    display: block !important; 
  }
  .mobile-hero-replacement { 
    display: none !important; 
  }
}

/* ===== MOBILE USER MENU ENHANCEMENTS ===== */
/* Dark mode specific styles for mobile menu */
[data-theme="dark"] .menu-item:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

/* Improved touch targets for mobile */
@media (hover: none) {
  .menu-item {
    min-height: 48px; /* Better touch target */
    padding: var(--space-md);
  }
  
  .avatar-btn {
    width: 32px !important;
    height: 32px !important;
    min-height: 48px; /* Touch-friendly button */
    min-width: 48px;
  }
}

/* Mobile animations */
@keyframes slideIn {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* Mobile menu positioning adjustments */
@media (max-width: 480px) {
  .menu {
    min-width: 200px;
    max-width: 85vw;
    left: auto;
    right: 0;
  }
  
  .vp-controls {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  
  .vp-controls::-webkit-scrollbar {
    display: none;
  }
}

/* Enhanced mobile interactions */
@media (max-width: 768px) {
  /* Make menu items more thumb-friendly */
  .menu-item {
    font-size: 1rem;
    font-weight: 500;
  }
  
  /* Better visual feedback */
  .menu-item:active {
    background-color: rgba(59, 130, 246, 0.15);
    transform: scale(0.98);
  }
  
  /* Ensure menu stays on screen */
  .menu {
    transform: translateX(0);
    max-height: 70vh;
    overflow-y: auto;
  }
}

/* ===== MOBILE ANIMATION OVERRIDES ===== */
@media (prefers-reduced-motion: reduce) {
  .hover-lift:hover, .btn:hover, .card:hover {
    transform: none;
  }
  
  .animate-in, .scale-in, .fade-in {
    animation: none;
  }
  
  .menu-item:hover, .menu-item:active {
    transform: none;
  }
}

/* ===== FILE INPUT & FORM CONTROLS MOBILE FIX ===== */
@media (max-width: 980px) {
  /* Fix file input buttons to show full text */
  input[type="file"] {
    width: 100% !important;
    max-width: 100% !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    min-height: 48px !important;
    box-sizing: border-box !important;
  }
  
  /* Custom file button styling */
  input[type="file"]::file-selector-button,
  input[type="file"]::-webkit-file-upload-button {
    -webkit-appearance: none !important;
    appearance: none !important;
    background-image: none !important;
    box-shadow: none !important;
    padding: 10px 16px !important;
    font-size: 14px !important;
    white-space: nowrap !important;
    margin-right: 12px !important;
    border-radius: 6px !important;
    background: var(--primary, #3b82f6) !important;
    color: white !important;
    border: none !important;
    cursor: pointer !important;
    min-height: 44px !important;
  }
  /* Some iOS versions still render an overlay icon; force-hide */
  input[type="file"] { 
    -webkit-appearance: none !important; 
    appearance: none !important; 
    background-image: none !important;
  }
  
  /* Text inputs with long content - truncate with ellipsis */
  input[type="text"],
  input[type="url"],
  input[type="email"] {
    width: 100% !important;
    max-width: 100% !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
    box-sizing: border-box !important;
    min-height: 48px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  
  /* Fix checkbox labels with emojis or long text */
  label {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    word-wrap: break-word !important;
    white-space: normal !important;
    line-height: 1.4 !important;
    padding: 8px 0 !important;
  }
  
  input[type="checkbox"] {
    min-width: 20px !important;
    min-height: 20px !important;
    width: 20px !important;
    height: 20px !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    cursor: pointer !important;
  }
  
  /* Form groups - stack vertically on mobile */
  .form-group,
  .input-group {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    margin-bottom: 16px !important;
    width: 100% !important;
  }
  
  /* Buttons should use full width on very small screens */
  @media (max-width: 480px) {
    button,
    .btn,
    input[type="submit"],
    input[type="button"] {
      width: 100% !important;
      max-width: 100% !important;
      box-sizing: border-box !important;
    }
  }
  
  /* Dashboard/Jobs tables: contained horizontal scrolling inside cards */
  .card > div[style*="overflow:auto"],
  .table-responsive,
  .table-scroll {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .card table.table {
    min-width: 640px !important; /* allow columns to breathe while container scrolls */
  }
  /* Improve tap targets for table actions */
  table.table td .btn,
  table.table th .btn,
  .table .btn {
    min-height: 44px !important;
    padding: 10px 12px !important;
  }
  /* Avoid layout breaks: allow action groups to wrap */
  table.table td form,
  table.table td div,
  table.table td { 
    white-space: normal !important; 
  }
  table.table td div[style*="display:flex"],
  table.table td .row {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  
  /* Path display - show with horizontal scroll if needed */
  .path-display,
  .file-path {
    max-width: 100% !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    padding: 8px 12px !important;
    background: rgba(0, 0, 0, 0.05) !important;
    border-radius: 6px !important;
    font-family: monospace !important;
    font-size: 12px !important;
    scrollbar-width: thin !important;
  }
  
  /* Fix analyze.html specific elements */
  /* Enhanced file input zones */
  .enhanced-file-input,
  .drag-drop-zone {
    min-height: 60px !important;
  }
  
  /* Details/summary (Advanced options) */
  details summary {
    cursor: pointer !important;
    padding: 12px 16px !important;
    background: rgba(102, 126, 234, 0.1) !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    margin-bottom: 12px !important;
    list-style: none !important;
    position: relative !important;
    padding-left: 16px !important; /* make room if any marker remains */
  }
  /* Hide default disclosure marker so it doesn't overlap first letter */
  details summary::-webkit-details-marker { display: none !important; }
  details summary::marker { content: '' !important; }
  
  details[open] summary {
    margin-bottom: 16px !important;
  }
  
  /* Checkbox labels with emoji fix */
  details label {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 10px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border-radius: 6px !important;
    margin: 4px 0 !important;
    cursor: pointer !important;
    min-height: 44px !important;
  }
  
  details label input[type="checkbox"] {
    min-width: 22px !important;
    min-height: 22px !important;
    width: 22px !important;
    height: 22px !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
  }
  
  details label span {
    word-break: break-word !important;
    line-height: 1.4 !important;
  }
  
  /* Analyzer path form - stack on mobile */
  form.row {
    flex-direction: column !important;
    gap: 12px !important;
  }
  
  form.row input[type="text"] {
    min-width: auto !important;
    width: 100% !important;
  }
  
  form.row button {
    width: 100% !important;
  }
  
  /* Code blocks with long paths */
  code {
    word-break: break-all !important;
    white-space: normal !important;
    display: inline-block !important;
    max-width: 100% !important;
  }
  
  /* Admin Dashboard (Owner/Security/Monitoring) — mobile tweaks */
  /* Utility classes for mobile-only visibility */
  .mobile-only { display: inline !important; }
  .desktop-only { display: none !important; }

  /* Compact admin toggle for mobile */
  .admin-toggle {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 10px 12px !important;
    background: rgba(0,0,0,0.05) !important;
    border-radius: 8px !important;
    min-height: 44px !important;
    font-size: 14px !important;
  }
  .admin-toggle input[type="checkbox"] {
    width: 20px !important;
    height: 20px !important;
  }

  .admin-dashboard .admin-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
    position: sticky !important;
    top: 64px !important; /* below mobile navbar */
    z-index: 900 !important;
    background: var(--card) !important;
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08) !important;
    margin-bottom: 20px !important;
  }
  
  .admin-dashboard .admin-nav {
    display: flex !important;
    gap: 8px !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    padding-bottom: 6px !important;
    position: relative !important;
  }
  /* Fading edge to hint scrollability */
  .admin-dashboard .admin-nav::after {
    content: "";
    position: sticky;
    right: 0;
    margin-left: auto;
    width: 36px;
    min-width: 36px;
    height: 100%;
    background: linear-gradient(to right, rgba(255,255,255,0), var(--card));
    pointer-events: none;
  }
  .admin-dashboard .admin-nav .nav-link {
    flex: 0 0 auto !important;
    min-height: 44px !important;
    padding: 10px 14px !important;
  }
  /* Softer spacing and borders on cards for mobile */
  .admin-dashboard .metric-card,
  .admin-dashboard .chart-container,
  .admin-dashboard .recent-activity,
  .admin-dashboard .top-features,
  .admin-dashboard .system-health,
  .admin-dashboard .recent-errors,
  .admin-dashboard .quick-actions {
    margin-bottom: 16px !important;
    padding: 16px !important;
    border-radius: 10px !important;
    border-color: rgba(0,0,0,0.08) !important;
  }

  /* Compact chart padding on mobile */
  .admin-dashboard .chart-container h3 { margin-bottom: 12px !important; }

  /* Empty state styling (mobile) */
  .admin-dashboard .empty-state {
    display: block !important;
    padding: 12px !important;
    text-align: center !important;
    color: var(--muted, #6b7280) !important;
    background: rgba(0,0,0,0.04) !important;
    border: 1px dashed var(--line, rgba(0,0,0,0.1)) !important;
    border-radius: 8px !important;
  }

  /* Action grids: two columns on small, single on very small */
  .admin-dashboard .actions-grid { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
  @media (max-width: 480px) {
    .admin-dashboard .actions-grid { grid-template-columns: 1fr !important; }
  }
  
  .admin-dashboard .charts-section,
  .admin-dashboard .activity-section,
  .admin-dashboard .health-section {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  
  .admin-dashboard .chart-container canvas {
    width: 100% !important;
    height: auto !important;
  }
  
  .admin-dashboard .chart-summary {
    flex-direction: column !important;
    gap: 8px !important;
    align-items: flex-start !important;
  }
  
  .admin-dashboard .metric-card {
    align-items: flex-start !important;
  }
  .admin-dashboard .metric-content h3,
  .admin-dashboard .metric-value,
  .admin-dashboard .metric-change {
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
  }
  
  /* Trending freshness grid: prevent long lines from forcing overflow */
  .admin-dashboard #freshnessGrid .metric-card { min-width: 0 !important; }
  .admin-dashboard #freshnessGrid .metric-content { min-width: 0 !important; }
  .admin-dashboard #freshnessGrid .metric-content .metric-change { white-space: normal !important; }
  
  /* Quick actions: stack buttons and ensure tappable size */
  .admin-dashboard .actions-grid { grid-template-columns: 1fr !important; }
  .admin-dashboard .action-btn { width: 100% !important; min-height: 44px !important; }
}
