/**
 * GhostFax Mobile Responsive Styles
 * Mobile-first responsive design
 */

/* Base mobile styles */
.mobile-layout {
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height for mobile */
}

/* Touch-friendly interactions */
.touch-manipulation {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Minimum touch target size (44x44px for accessibility) */
.min-touch-target {
  min-width: 44px;
  min-height: 44px;
}

/* Mobile container */
.mobile-container {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

/* Responsive text sizes */
@media (max-width: 768px) {
  .font-pixel {
    font-size: clamp(10px, 2.5vw, 14px);
  }
  
  .font-lcd {
    font-size: clamp(12px, 3vw, 16px);
  }
}

/* Mobile navigation */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--retro-beige);
  border-top: 4px solid var(--retro-brown);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Mobile modal adjustments */
@media (max-width: 768px) {
  .mobile-modal {
    position: fixed;
    inset: 0;
    border-radius: 0;
    max-height: 100vh;
    max-height: 100dvh;
  }
  
  .mobile-modal-content {
    height: calc(100vh - 60px);
    height: calc(100dvh - 60px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Landscape mode adjustments */
@media (max-width: 768px) and (orientation: landscape) {
  .landscape-compact {
    padding: 0.5rem;
  }
  
  .landscape-hide {
    display: none;
  }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  .tablet-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Safe area insets for notched devices */
.safe-area-top {
  padding-top: env(safe-area-inset-top);
}

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

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

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

/* Scrollable areas with momentum */
.mobile-scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Prevent zoom on input focus (iOS) */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* Mobile-friendly buttons */
@media (max-width: 768px) {
  .mobile-button {
    padding: 0.75rem 1rem;
    min-height: 48px;
    font-size: 14px;
  }
  
  .mobile-button-large {
    padding: 1rem 1.5rem;
    min-height: 52px;
    font-size: 16px;
  }
}

/* Responsive grid layouts */
@media (max-width: 768px) {
  .responsive-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .responsive-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
}

@media (min-width: 1025px) {
  .responsive-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
  }
}

/* Mobile realm selector */
@media (max-width: 768px) {
  .realm-selector-mobile {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  
  .realm-selector-mobile::-webkit-scrollbar {
    display: none;
  }
  
  .realm-option-mobile {
    scroll-snap-align: center;
    flex-shrink: 0;
    width: 80px;
  }
}

/* Mobile recipient picker */
@media (max-width: 768px) {
  .recipient-picker-mobile {
    max-height: 50vh;
    overflow-y: auto;
  }
}

/* Mobile composer */
@media (max-width: 768px) {
  .ghostfax-composer-mobile {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 80vh;
    border-radius: 1rem 1rem 0 0;
  }
  
  .composer-textarea-mobile {
    min-height: 120px;
    max-height: 40vh;
  }
}

/* Mobile inbox */
@media (max-width: 768px) {
  .fax-inbox-mobile .fax-item {
    padding: 1rem;
    border-bottom: 2px solid var(--retro-brown);
  }
  
  .fax-inbox-mobile .fax-preview {
    display: none;
  }
}

/* Mobile settings panel */
@media (max-width: 768px) {
  .settings-panel-mobile {
    position: fixed;
    inset: 0;
    z-index: 200;
  }
  
  .settings-tabs-mobile {
    display: flex;
    overflow-x: auto;
    border-bottom: 2px solid var(--retro-brown);
  }
}

/* Mobile analytics dashboard */
@media (max-width: 768px) {
  .analytics-chart-mobile {
    height: 200px;
  }
  
  .analytics-stats-mobile {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .retro-button,
  .retro-panel,
  .retro-border {
    border-width: 3px;
  }
}

/* Dark mode adjustments (if needed) */
@media (prefers-color-scheme: dark) {
  .mobile-layout {
    /* Keep retro aesthetic, don't auto-adjust */
  }
}

/* Orientation change handling */
@media (orientation: portrait) {
  .portrait-stack {
    flex-direction: column;
  }
}

@media (orientation: landscape) {
  .landscape-row {
    flex-direction: row;
  }
}

/* Sticky headers on mobile */
@media (max-width: 768px) {
  .mobile-sticky-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--retro-beige);
    border-bottom: 2px solid var(--retro-brown);
  }
}

/* Mobile pull-to-refresh indicator */
.pull-to-refresh {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  transition: top 0.3s ease;
}

.pull-to-refresh.active {
  top: 10px;
}

/* Mobile loading states */
@media (max-width: 768px) {
  .mobile-loading {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Swipe gesture indicators */
.swipe-indicator {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.swipe-indicator.left {
  left: 10px;
}

.swipe-indicator.right {
  right: 10px;
}

.swipe-indicator.active {
  opacity: 1;
}

/* Mobile toast notifications */
@media (max-width: 768px) {
  .mobile-toast {
    position: fixed;
    bottom: 80px;
    left: 1rem;
    right: 1rem;
    z-index: 300;
  }
}

/* Responsive spacing utilities */
@media (max-width: 768px) {
  .mobile-spacing-sm { padding: 0.5rem; }
  .mobile-spacing-md { padding: 1rem; }
  .mobile-spacing-lg { padding: 1.5rem; }
}

/* Mobile-friendly tables */
@media (max-width: 768px) {
  .responsive-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .responsive-table thead {
    display: none;
  }
  
  .responsive-table tr {
    display: block;
    margin-bottom: 1rem;
    border: 2px solid var(--retro-brown);
  }
  
  .responsive-table td {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    border-bottom: 1px solid var(--retro-brown);
  }
  
  .responsive-table td:before {
    content: attr(data-label);
    font-weight: bold;
    margin-right: 1rem;
  }
}
