/**
 * Mobile-Specific Utilities and Overrides
 * 
 * Breakpoint: < 768px (Mobile devices)
 * 
 * @package SGLE_Theme
 * @version 1.0.0
 * @date 2026-01-16
 */

/* ========================================
   MOBILE DISPLAY UTILITIES
   ======================================== */

.mobile-only {
  display: block;
}

.desktop-only {
  display: none;
}

@media (min-width: 768px) {
  .mobile-only {
    display: none;
  }
  
  .desktop-only {
    display: block;
  }
}

/* Inline variants */
.mobile-only-inline {
  display: inline;
}

.mobile-only-flex {
  display: flex;
}

@media (min-width: 768px) {
  .mobile-only-inline,
  .mobile-only-flex {
    display: none !important;
  }
}

/* ========================================
   TOUCH TARGET UTILITIES
   ======================================== */

/**
 * Ensures minimum touch target size
 * iOS: 44x44px minimum
 * Material Design: 48x48px recommended
 */
.touch-target {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.touch-target-lg {
  min-width: 48px;
  min-height: 48px;
}

/* Touch feedback */
.touch-feedback:active {
  opacity: 0.7;
  transition: opacity 0.1s ease;
}

/* ========================================
   MOBILE SPACING UTILITIES
   ======================================== */

/* Only apply on mobile devices */
@media (max-width: 767px) {
  /* Padding utilities */
  .mobile-p-2 { padding: 0.5rem !important; }
  .mobile-p-3 { padding: 0.75rem !important; }
  .mobile-p-4 { padding: 1rem !important; }
  .mobile-p-5 { padding: 1.25rem !important; }
  .mobile-p-6 { padding: 1.5rem !important; }
  
  /* Padding X (horizontal) */
  .mobile-px-2 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
  .mobile-px-3 { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
  .mobile-px-4 { padding-left: 1rem !important; padding-right: 1rem !important; }
  .mobile-px-5 { padding-left: 1.25rem !important; padding-right: 1.25rem !important; }
  .mobile-px-6 { padding-left: 1.5rem !important; padding-right: 1.5rem !important; }
  
  /* Padding Y (vertical) */
  .mobile-py-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
  .mobile-py-3 { padding-top: 0.75rem !important; padding-bottom: 0.75rem !important; }
  .mobile-py-4 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
  .mobile-py-5 { padding-top: 1.25rem !important; padding-bottom: 1.25rem !important; }
  .mobile-py-6 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
  
  /* Margin utilities */
  .mobile-m-2 { margin: 0.5rem !important; }
  .mobile-m-3 { margin: 0.75rem !important; }
  .mobile-m-4 { margin: 1rem !important; }
  .mobile-m-5 { margin: 1.25rem !important; }
  
  /* Margin bottom */
  .mobile-mb-2 { margin-bottom: 0.5rem !important; }
  .mobile-mb-3 { margin-bottom: 0.75rem !important; }
  .mobile-mb-4 { margin-bottom: 1rem !important; }
  .mobile-mb-5 { margin-bottom: 1.25rem !important; }
  .mobile-mb-6 { margin-bottom: 1.5rem !important; }
  
  /* Gap utilities */
  .mobile-gap-2 { gap: 0.5rem !important; }
  .mobile-gap-3 { gap: 0.75rem !important; }
  .mobile-gap-4 { gap: 1rem !important; }
}

/* ========================================
   MOBILE TYPOGRAPHY UTILITIES
   ======================================== */

@media (max-width: 767px) {
  /* Font sizes */
  .mobile-text-xs { font-size: 0.6875rem !important; line-height: 1rem !important; }      /* 11px */
  .mobile-text-sm { font-size: 0.8125rem !important; line-height: 1.125rem !important; }  /* 13px */
  .mobile-text-base { font-size: 0.9375rem !important; line-height: 1.375rem !important; } /* 15px */
  .mobile-text-lg { font-size: 1rem !important; line-height: 1.5rem !important; }         /* 16px */
  .mobile-text-xl { font-size: 1.125rem !important; line-height: 1.625rem !important; }   /* 18px */
  .mobile-text-2xl { font-size: 1.375rem !important; line-height: 1.875rem !important; }  /* 22px */
  .mobile-text-3xl { font-size: 1.625rem !important; line-height: 2.125rem !important; }  /* 26px */
  
  /* Text truncation */
  .mobile-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  /* Multi-line truncation */
  .mobile-line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  
  .mobile-line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* ========================================
   SAFE AREA INSETS (iOS)
   ======================================== */

/**
 * Support for iOS notch and home indicator
 * Uses CSS environment variables
 */
.safe-top {
  padding-top: env(safe-area-inset-top);
}

.safe-bottom {
  padding-bottom: env(safe-area-inset-bottom);
}

.safe-left {
  padding-left: env(safe-area-inset-left);
}

.safe-right {
  padding-right: env(safe-area-inset-right);
}

.safe-all {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Margin variants */
.safe-margin-bottom {
  margin-bottom: env(safe-area-inset-bottom);
}

/* ========================================
   MOBILE LAYOUT UTILITIES
   ======================================== */

@media (max-width: 767px) {
  /* Full width on mobile */
  .mobile-full-width {
    width: 100% !important;
  }
  
  /* Full height on mobile */
  .mobile-full-height {
    height: 100vh !important;
  }
  
  /* Flex direction column on mobile */
  .mobile-flex-col {
    flex-direction: column !important;
  }
  
  /* Hide on mobile */
  .mobile-hidden {
    display: none !important;
  }
  
  /* Stack elements vertically */
  .mobile-stack > * {
    width: 100% !important;
  }
  
  /* Grid to single column */
  .mobile-grid-1 {
    grid-template-columns: 1fr !important;
  }
}

/* ========================================
   MOBILE SCROLL UTILITIES
   ======================================== */

/* Smooth scrolling */
.mobile-scroll-smooth {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* Hide scrollbar but keep functionality */
.mobile-scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.mobile-scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* Horizontal scroll container */
.mobile-scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.mobile-scroll-x::-webkit-scrollbar {
  display: none;
}

/* ========================================
   MOBILE INTERACTION UTILITIES
   ======================================== */

/* Prevent text selection on buttons/interactive elements */
.no-select {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Remove tap highlight (iOS) */
.no-tap-highlight {
  -webkit-tap-highlight-color: transparent;
}

/* Active state for mobile buttons */
.mobile-active:active {
  transform: scale(0.97);
  transition: transform 0.1s ease-out;
}

/* Prevent zoom on input focus (iOS) */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
textarea,
select {
  font-size: 16px !important;
}

/* ========================================
   MOBILE COMPONENT OVERRIDES
   ======================================== */

@media (max-width: 767px) {
  /* Buttons - ensure minimum touch target */
  .btn,
  button {
    min-height: 44px;
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  /* Inputs - ensure minimum touch target */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  input[type="url"],
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"],
  textarea,
  select {
    min-height: 44px;
    font-size: 16px;
  }
  
  /* Cards - reduce padding */
  .card {
    padding: 1rem;
  }
  
  /* Modals - full screen on mobile */
  .modal-content {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    border-radius: 0;
  }
  
  /* Tables - hide on mobile (use card view instead) */
  .data-table {
    display: block;
  }
}

/* ========================================
   MOBILE FORM ENHANCEMENTS (Phase 5)
   ======================================== */

@media (max-width: 767px) {
  /* Input Component Mobile Optimizations */
  
  /* Ensure proper padding for touch on all inputs */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  input[type="url"],
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"],
  textarea,
  select {
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
  }
  
  /* Textarea specific height */
  textarea {
    min-height: 88px; /* 44px * 2 for multi-line */
  }
  
  /* Error states more visible on mobile */
  input.error,
  select.error,
  textarea.error,
  input:invalid:not(:placeholder-shown),
  select:invalid:not(:placeholder-shown),
  textarea:invalid:not(:placeholder-shown) {
    border-color: rgb(239 68 68);
    border-width: 2px;
    padding-right: 2.5rem;
    background-image: url('data:image/svg+xml;charset=utf-8,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%2720%27 height=%2720%27 viewBox=%270 0 20 20%27%3E%3Cpath fill=%27%23ef4444%27 d=%27M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm1 15H9v-2h2v2zm0-4H9V5h2v6z%27/%3E%3C/svg%3E');
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 20px 20px;
  }
  
  /* Success states on mobile */
  input.success,
  select.success,
  textarea.success,
  input:valid:not(:placeholder-shown):not([type="search"]),
  select:valid:not(:placeholder-shown),
  textarea:valid:not(:placeholder-shown) {
    border-color: rgb(34 197 94);
    border-width: 2px;
  }
  
  /* Focus states enhanced for mobile */
  input:focus,
  select:focus,
  textarea:focus {
    outline: none;
    border-width: 2px;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  }
  
  /* Error message styling */
  .text-red-500[role="alert"],
  [id$="-error"]:not(.hidden) {
    font-size: 0.8125rem;
    line-height: 1.25rem;
    margin-top: 0.375rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
  }
  
  .text-red-500[role="alert"]::before,
  [id$="-error"]:not(.hidden)::before {
    content: '⚠';
    font-size: 1rem;
  }
}

/* ========================================
   MOBILE SELECT & DROPDOWN ENHANCEMENTS (Phase 5)
   ======================================== */

@media (max-width: 767px) {
  /* Native select on mobile for better UX */
  select {
    appearance: auto;
    -webkit-appearance: menulist;
    -moz-appearance: menulist;
    background-image: none !important;
    padding-right: 1rem !important;
    cursor: pointer;
  }
  
  /* Select with custom arrow - override only on mobile */
  select[class*="appearance-none"] {
    appearance: auto !important;
    -webkit-appearance: menulist !important;
    background-image: none !important;
  }
  
  /* Multiple select optimization */
  select[multiple] {
    min-height: 132px; /* 44px * 3 */
    padding: 0.5rem;
  }
  
  select[multiple] option {
    padding: 0.75rem;
    min-height: 44px;
    border-radius: 0.5rem;
    margin-bottom: 0.25rem;
  }
  
  /* Date and time pickers - native on mobile */
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"],
  input[type="month"],
  input[type="week"] {
    appearance: auto;
    -webkit-appearance: auto;
    cursor: pointer;
  }
  
  /* Custom dropdown containers (if any) - hide on mobile */
  .custom-select-dropdown,
  .select2-container,
  .choices,
  [class*="custom-dropdown"] {
    display: none !important;
  }
  
  /* Show native selects on mobile */
  select.custom-select,
  select[class*="custom"] {
    display: block !important;
    opacity: 1 !important;
    position: static !important;
  }
}

/* ========================================
   MOBILE BUTTON ENHANCEMENTS (Phase 5)
   ======================================== */

@media (max-width: 767px) {
  /* All buttons - ensure touch targets and mobile states */
  button,
  .btn,
  [type="button"],
  [type="submit"],
  [type="reset"],
  a.button,
  .button {
    min-height: 44px;
    min-width: 44px;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.9375rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }
  
  /* Button active state for mobile feedback */
  button:active,
  .btn:active,
  [type="button"]:active,
  [type="submit"]:active,
  [type="reset"]:active,
  a.button:active,
  .button:active {
    transform: scale(0.97);
    opacity: 0.9;
  }
  
  /* Disabled button states */
  button:disabled,
  .btn:disabled,
  [type="button"]:disabled,
  [type="submit"]:disabled,
  [type="reset"]:disabled,
  button[disabled],
  .btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
  }
  
  /* Loading button state */
  button.loading,
  .btn.loading,
  button[data-loading="true"],
  .btn[data-loading="true"] {
    position: relative;
    color: transparent;
    pointer-events: none;
  }
  
  button.loading::after,
  .btn.loading::after,
  button[data-loading="true"]::after,
  .btn[data-loading="true"]::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin-top: -10px;
    margin-left: -10px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: button-spin 0.6s linear infinite;
  }
  
  @keyframes button-spin {
    to { transform: rotate(360deg); }
  }
  
  /* Icon + text button alignment */
  button .material-symbols-outlined,
  .btn .material-symbols-outlined,
  button span[class*="icon"],
  .btn span[class*="icon"] {
    font-size: 1.125rem;
    line-height: 1;
  }
  
  /* Full width buttons on mobile */
  button.mobile-full,
  .btn.mobile-full,
  .modal-footer button:not(.btn-secondary),
  .modal-footer .btn:not(.btn-secondary) {
    width: 100%;
  }
  
  /* Button groups - stack vertically on mobile */
  .button-group,
  .btn-group,
  [class*="button-group"] {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
  }
  
  .button-group > button,
  .button-group > .btn,
  .btn-group > button,
  .btn-group > .btn {
    width: 100%;
    margin: 0;
  }
  
  /* Icon-only buttons - ensure square touch target */
  button:not(:has(span:not(.material-symbols-outlined))),
  .btn:not(:has(span:not(.material-symbols-outlined))),
  button.icon-only,
  .btn.icon-only,
  [class*="icon-btn"] {
    min-width: 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 0.75rem;
  }
  
  /* Close buttons */
  button[id*="close"],
  button[class*="close"],
  .close-button,
  [aria-label*="Fechar"],
  [aria-label*="Close"] {
    min-width: 44px;
    width: 44px;
    height: 44px;
    padding: 0;
  }
}

/* ========================================
   MOBILE ANIMATIONS
   ======================================== */

/* Slide in from bottom (common for mobile modals) */
@keyframes mobile-slide-in-bottom {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes mobile-slide-out-bottom {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(100%);
    opacity: 0;
  }
}

.mobile-slide-in {
  animation: mobile-slide-in-bottom 0.3s ease-out;
}

.mobile-slide-out {
  animation: mobile-slide-out-bottom 0.3s ease-out;
}

/* Press effect */
@media (max-width: 767px) {
  .mobile-press:active {
    transform: scale(0.98);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.1s ease-out;
  }
}

/* ========================================
   MOBILE VIRTUAL KEYBOARD SUPPORT
   ======================================== */

/* Adjust viewport when virtual keyboard is visible */
@supports (height: 100dvh) {
  .mobile-viewport-height {
    height: 100dvh;
  }
}

/* Fix for iOS Safari viewport height issue */
.mobile-min-viewport-height {
  min-height: 100vh;
  min-height: -webkit-fill-available;
}

/* ========================================
   MOBILE TABLES → CARDS (Phase 6)
   ======================================== */

/**
 * Enhanced mobile table to card transformation
 * Tables become compact, touch-friendly cards on mobile
 * Supports data-label attributes for field labels
 */

@media (max-width: 767px) {
  /* Hide table structure, convert to cards */
  .data-table,
  table.w-full {
    display: block;
    border: none;
    background: transparent;
  }
  
  .data-table thead,
  table.w-full thead {
    display: none;
  }
  
  .data-table tbody,
  table.w-full tbody {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  /* Transform each row into a card */
  .data-table tr,
  table.w-full tbody tr {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    background: white;
    border: 1px solid rgb(226 232 240);
    border-radius: 0.75rem;
    padding: 1rem;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  }
  
  /* Active/press effect for cards */
  .data-table tr:active,
  table.w-full tbody tr:active {
    transform: scale(0.98);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  }
  
  /* Hide loading rows properly */
  .data-table tr#table-loading,
  .data-table tr#cards-loading,
  .data-table tr#os-loading,
  table.w-full tbody tr#table-loading,
  table.w-full tbody tr#cards-loading,
  table.w-full tbody tr#os-loading {
    display: block;
    border-radius: 0.75rem;
    padding: 1.5rem;
  }
  
  /* Transform each cell into a row with label */
  .data-table td,
  table.w-full tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    border: none;
    font-size: 0.9375rem;
    line-height: 1.5;
  }
  
  /* Add label from data-label attribute */
  .data-table td[data-label]::before,
  table.w-full tbody td[data-label]::before {
    content: attr(data-label);
    font-weight: 600;
    color: rgb(100 116 139);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    flex-shrink: 0;
    margin-right: 1rem;
  }
  
  /* Value styling */
  .data-table td[data-label] > *,
  table.w-full tbody td[data-label] > * {
    text-align: right;
    flex-shrink: 0;
  }
  
  /* Actions cell - full width with top border */
  .data-table td:has(.actions),
  .data-table td:has(button),
  .data-table td:has(.flex.gap-2),
  table.w-full tbody td:has(.actions),
  table.w-full tbody td:has(button),
  table.w-full tbody td:has(.flex.gap-2) {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgb(241 245 249);
  }
  
  /* Hide "before" label for action cells */
  .data-table td:has(.actions)::before,
  .data-table td:has(button)::before,
  table.w-full tbody td:has(.actions)::before,
  table.w-full tbody td:has(button)::before {
    display: none;
  }
  
  /* Action buttons in cards */
  .data-table td button,
  .data-table td .btn,
  table.w-full tbody td button,
  table.w-full tbody td .btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }
  
  /* Status badges in cards */
  .data-table td .badge,
  .data-table td [class*="badge"],
  .data-table td [class*="status"],
  table.w-full tbody td .badge,
  table.w-full tbody td [class*="badge"],
  table.w-full tbody td [class*="status"] {
    font-size: 0.75rem;
    padding: 0.25rem 0.625rem;
    border-radius: 0.5rem;
    font-weight: 700;
    white-space: nowrap;
  }
  
  /* Ensure proper wrapping for long content */
  .data-table td[data-label],
  table.w-full tbody td[data-label] {
    word-break: break-word;
    min-height: auto;
  }
  
  /* First cell - highlight as title/main info */
  .data-table tr td:first-child,
  table.w-full tbody tr td:first-child {
    font-weight: 600;
    font-size: 1rem;
    color: rgb(15 23 42);
    padding-bottom: 0.25rem;
  }
  
  .data-table tr td:first-child::before,
  table.w-full tbody tr td:first-child::before {
    font-size: 0.75rem;
    font-weight: 700;
  }
  
  /* Empty state in cards */
  .data-table tr:has(.text-center),
  table.w-full tbody tr:has(.text-center) {
    display: block;
    padding: 2rem;
    text-align: center;
  }
  
  .data-table tr:has(.text-center) td,
  table.w-full tbody tr:has(.text-center) td {
    display: block;
  }
  
  .data-table tr:has(.text-center) td::before,
  table.w-full tbody tr:has(.text-center) td::before {
    display: none;
  }
  
  /* Skeleton loading in card format */
  .data-table tr.animate-pulse td,
  table.w-full tbody tr.animate-pulse td {
    display: block;
  }
  
  .data-table tr.animate-pulse td::before,
  table.w-full tbody tr.animate-pulse td::before {
    display: none;
  }
  
  /* Table container - remove overflow */
  .overflow-x-auto:has(table) {
    overflow-x: visible;
  }
  
  /* Table wrapper card styling on mobile */
  .bg-white.rounded-2xl:has(table) {
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
  }
  
  /* Keep pagination/footer visible */
  .data-table + div,
  table.w-full + div,
  .bg-white.rounded-2xl:has(table) > div:last-child {
    display: flex;
    background: white;
    border: 1px solid rgb(226 232 240);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-top: 0.75rem;
  }
}

/* ========================================
   MOBILE BOTTOM NAVIGATION (Phase 7)
   ======================================== */

/**
 * Bottom navigation bar for mobile
 * Fixed at bottom with safe area support
 * Active state styling and smooth transitions
 */
@media (max-width: 1023px) {
  #bottom-nav {
    /* Ensure it's above other content */
    box-shadow: 0 -1px 3px 0 rgb(0 0 0 / 0.1), 0 -1px 2px -1px rgb(0 0 0 / 0.1);
  }
  
  /* Bottom nav items */
  .bottom-nav-item {
    /* Touch target guaranteed */
    min-width: 64px;
    min-height: 48px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  
  /* Active state press effect */
  .bottom-nav-item:active {
    transform: scale(0.95);
  }
  
  /* Icon animation on active */
  .bottom-nav-item[aria-current="page"] .material-symbols-outlined {
    animation: bottomNavPulse 0.3s ease-out;
  }
  
  /* Add bottom padding to main content to prevent overlap */
  #main-content {
    padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px));
  }
}

/* Bottom nav pulse animation */
@keyframes bottomNavPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1.1);
  }
}

/* Ensure bottom nav is hidden on desktop */
@media (min-width: 1024px) {
  #bottom-nav {
    display: none;
  }
}

/* ========================================
   MOBILE ANIMATIONS & MICROINTERACTIONS (Phase 8)
   ======================================== */

/**
 * Mobile-specific animations optimized for touch devices
 * Focus: Tap feedback, press effects, and smooth microinteractions
 */

@media (max-width: 767px) {
  /* ====================================
     TAP & PRESS ANIMATIONS (Simplified)
     ==================================== */
  
  /* Subtle tap feedback - for buttons and interactive elements */
  .tap-scale:active {
    transform: scale(0.97);
    transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  /* Card press effect - minimal visual feedback */
  .card-press:active {
    opacity: 0.95;
    transition: opacity 0.1s ease;
  }
  
  /* ====================================
     RIPPLE EFFECT (Removed - causes element hiding)
     ==================================== */
  
  /* ====================================
     ATTENTION ANIMATIONS (Removed - too distracting)
     ==================================== */
  
  /* ====================================
     LOADING STATES & SPINNERS
     ==================================== */
  
  /* Mobile-optimized spinner */
  .spinner-mobile {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(59, 130, 246, 0.2);
    border-top-color: rgb(59, 130, 246);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
  
  .spinner-mobile-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
  }
  
  @keyframes spin {
    to { transform: rotate(360deg); }
  }
  
  /* Pulse animation for loading states */
  .pulse-mobile {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  }
  
  @keyframes pulse {
    0%, 100% {
      opacity: 1;
    }
    50% {
      opacity: 0.5;
    }
  }
  
  /* Skeleton shimmer - optimized for mobile */
  .skeleton-mobile {
    background: linear-gradient(
      90deg,
      #f1f5f9 0%,
      #e2e8f0 20%,
      #f1f5f9 40%,
      #f1f5f9 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
  }
  
  @keyframes shimmer {
    0% {
      background-position: -200% 0;
    }
    100% {
      background-position: 200% 0;
    }
  }
  
  /* Progress bar animation */
  .progress-mobile {
    position: relative;
    overflow: hidden;
    background: #e2e8f0;
    border-radius: 9999px;
    height: 4px;
  }
  
  .progress-mobile::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 40%;
    background: rgb(59, 130, 246);
    border-radius: 9999px;
    animation: progress 1.5s ease-in-out infinite;
  }
  
  @keyframes progress {
    0% {
      left: -40%;
    }
    100% {
      left: 100%;
    }
  }
  
  /* ====================================
     SLIDE & FADE ANIMATIONS
     ==================================== */
  
  /* Slide in from bottom (for mobile modals) - simplified */
  .slide-in-bottom {
    animation: slideInBottom 0.25s ease-out;
  }
  
  @keyframes slideInBottom {
    from {
      transform: translateY(20px);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }
  
  /* Slide out removed - not needed for clean mobile */
  
  /* Fade in up - for list items - simplified */
  .fade-in-up {
    animation: fadeInUp 0.3s ease-out;
  }
  
  @keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  /* ====================================
     SCALE ANIMATIONS (Removed - not needed)
     ==================================== */
  
  /* ====================================
     STAGGER ANIMATIONS (Removed - causes visual clutter)
     ==================================== */
  
  /* ====================================
     ATTENTION ANIMATIONS (Removed - too aggressive)
     ==================================== */
  
  /* ====================================
     HOVER STATES (Touch-friendly)
     ==================================== */
  
  /* Smooth color transition */
  .hover-transition {
    transition: opacity 0.2s ease, background-color 0.2s ease;
  }
  
  /* Subtle touch feedback - removed elevation */
  .hover-elevate:active {
    opacity: 0.9;
    transition: opacity 0.1s ease;
  }
  
  /* ====================================
     UTILITY CLASSES
     ==================================== */
  
  /* Disable animations for reduced motion preference */
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
  
  /* Hardware acceleration for smooth animations */
  .gpu-accelerate {
    transform: translateZ(0);
    will-change: transform;
  }
  
  /* Smooth opacity transition */
  .opacity-transition {
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

/* ========================================
   MOBILE MODAL ENHANCEMENTS
   ======================================== */

@media (max-width: 767px) {
  /* Category Modal - Mobile Full Height with Proper Scrolling */
  #modal-category-manage .modal-content {
    max-height: 95vh;
    height: 95vh;
    display: flex;
    flex-direction: column;
  }
  
  /* Split layout - stack on mobile */
  #modal-category-manage .modal-content > div:nth-child(2) {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  
  /* Left side (category list) - mobile 50% height */
  #modal-category-manage .modal-content > div:nth-child(2) > div:first-child {
    flex: 0 0 45%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid rgb(229 231 235);
  }
  
  /* Right side (form) - mobile 50% height */
  #modal-category-manage .modal-content > div:nth-child(2) > div:last-child {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  
  /* Ensure scrollable areas work properly */
  #category-list-container {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
  }
  
  /* Form container scrollable */
  #modal-category-manage .modal-content > div:nth-child(2) > div:last-child > div:nth-child(2) {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
  }
  
  /* Sticky form actions on mobile */
  #form-category > div:last-child {
    position: sticky;
    bottom: -1rem;
    margin-bottom: -1rem;
    z-index: 10;
    box-shadow: 0 -4px 6px -1px rgb(0 0 0 / 0.05);
  }
  
  /* Category list items - better spacing */
  #category-list-items > div {
    min-height: 60px;
  }
  
  /* Delete confirmation modal - better mobile layout */
  #modal-confirm-delete-category .modal-content {
    max-height: auto;
    border-radius: 1rem 1rem 0 0;
  }
}

/* ========================================
   MOBILE DEBUGGING (Development Only)
   ======================================== */

/* Uncomment to see touch target areas during development */
/*
.touch-target::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border: 1px dashed red;
  pointer-events: none;
  opacity: 0.3;
}
*/
