/* Mobile-specific optimizations for SweetNet Vendor Portal */

/* Critical CSS for mobile - inline for faster loading */
:root {
  --mobile-padding: 16px;
  --mobile-font-size: 14px;
  --mobile-line-height: 1.5;
  --mobile-touch-target: 44px;
}

/* Mobile-first responsive design */
@media (max-width: 768px) {
  /* Ensure minimum touch target size */
  button, 
  [role="button"], 
  input[type="button"], 
  input[type="submit"], 
  input[type="reset"],
  a {
    min-height: var(--mobile-touch-target);
    min-width: var(--mobile-touch-target);
  }
  
  /* Optimize text for mobile reading */
  body {
    font-size: var(--mobile-font-size);
    line-height: var(--mobile-line-height);
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
  }
  
  /* Improve mobile scrolling */
  html {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
  
  /* Optimize images for mobile */
  img {
    max-width: 100%;
    height: auto;
    display: block;
  }
  
  /* Mobile-friendly form elements */
  input, 
  textarea, 
  select {
    font-size: 16px; /* Prevents zoom on iOS */
    border-radius: 4px;
    padding: 12px;
    border: 1px solid #d1d5db;
  }
  
  /* Mobile navigation optimizations */
  .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    z-index: 1000;
  }
  
  /* Mobile card layouts */
  .mobile-card {
    margin: var(--mobile-padding);
    padding: var(--mobile-padding);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  }
  
  /* Mobile table optimizations */
  .mobile-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Mobile button optimizations */
  .mobile-btn {
    display: block;
    width: 100%;
    padding: 12px;
    margin: 8px 0;
    text-align: center;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
  }
  
  .mobile-btn:active {
    transform: scale(0.98);
  }
  
  /* Mobile loading states */
  .mobile-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
  }
  
  .mobile-loading-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: var(--mobile-padding);
    min-height: 200px;
  }
  
  .mobile-loading-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
  }
  
  .mobile-loading-small {
    min-height: 100px;
  }
  
  .mobile-loading-medium {
    min-height: 200px;
  }
  
  .mobile-loading-large {
    min-height: 300px;
  }
  
  .mobile-loading-spinner {
    position: relative;
    width: 40px;
    height: 40px;
    margin-bottom: 16px;
  }
  
  .mobile-spinner-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: mobile-spin 1s linear infinite;
  }
  
  .mobile-spinner-ring:nth-child(2) {
    animation-delay: -0.3s;
    border-top-color: #60a5fa;
  }
  
  .mobile-spinner-ring:nth-child(3) {
    animation-delay: -0.6s;
    border-top-color: #93c5fd;
  }
  
  @keyframes mobile-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }
  
  .mobile-loading-message {
    color: #6b7280;
    font-size: 14px;
    text-align: center;
    margin: 0;
  }
  
  /* Mobile error states */
  .mobile-error {
    padding: var(--mobile-padding);
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #dc2626;
    margin: var(--mobile-padding);
  }
  
  .mobile-error-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: var(--mobile-padding);
  }
  
  .mobile-error-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 400px;
    width: 100%;
  }
  
  .mobile-error-icon {
    font-size: 48px;
    margin-bottom: 16px;
  }
  
  .mobile-error-title {
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 12px 0;
  }
  
  .mobile-error-message {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 24px 0;
  }
  
  .mobile-error-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  
  .mobile-btn-primary {
    background: #3b82f6;
    color: white;
  }
  
  .mobile-btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
  }
  
  .mobile-error-details {
    margin-top: 24px;
    text-align: left;
  }
  
  .mobile-error-details summary {
    cursor: pointer;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 8px;
  }
  
  .mobile-error-stack {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px;
    font-family: monospace;
    font-size: 12px;
    color: #374151;
    white-space: pre-wrap;
    overflow-x: auto;
    max-height: 200px;
    overflow-y: auto;
  }
  
  /* Mobile success states */
  .mobile-success {
    padding: var(--mobile-padding);
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    color: #16a34a;
    margin: var(--mobile-padding);
  }
}

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Optimize for retina displays */
  img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Dark mode support for mobile */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
  :root {
    --mobile-bg: #1f2937;
    --mobile-text: #f9fafb;
    --mobile-border: #374151;
  }
  
  body {
    background-color: var(--mobile-bg);
    color: var(--mobile-text);
  }
  
  .mobile-card {
    background: var(--mobile-bg);
    border: 1px solid var(--mobile-border);
  }
}

/* Mobile performance optimizations */
@media (max-width: 768px) {
  /* Reduce animations on mobile for better performance */
  * {
    animation-duration: 0.2s !important;
    transition-duration: 0.2s !important;
  }
  
  /* Optimize for mobile scrolling */
  .scroll-container {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
  }
  
  /* Mobile-specific layout adjustments */
  .mobile-stack {
    display: flex;
    flex-direction: column;
    gap: var(--mobile-padding);
  }
  
  .mobile-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--mobile-padding);
  }
  
  /* Mobile typography */
  h1 { font-size: 24px; }
  h2 { font-size: 20px; }
  h3 { font-size: 18px; }
  h4 { font-size: 16px; }
  h5 { font-size: 14px; }
  h6 { font-size: 12px; }
}
