/* Mobile-specific styles for Mailgate */

/* Mobile breakpoints */
@media (max-width: 1023px) {
  /* Prevent horizontal scroll */
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }
  
  /* Improve touch interactions */
  a, button, .btn, [role="button"] {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  
  /* Better mobile scrolling */
  .custom-scrollbar {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  
  /* Adjust glass effects for performance */
  .glass,
  .glass-darker {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  
  /* Mobile sidebar overlay */
  [data-email-filter-sidebar-target="sidebar"] {
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  }
  
  /* Email list adjustments */
  .email-item {
    min-height: 80px;
    position: relative;
  }
  
  /* Ensure dropdowns are visible */
  [data-dropdown-target="menu"] {
    position: fixed !important;
    right: 1rem !important;
    max-width: calc(100vw - 2rem);
  }
  
  /* Mobile-friendly modals */
  .modal {
    margin: 1rem;
    max-height: calc(100vh - 2rem);
  }
  
  /* Improve form inputs on mobile */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  textarea,
  select {
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 44px;
  }
  
  /* Email content adjustments */
  .email-content-wrapper {
    word-break: break-word;
    overflow-wrap: break-word;
  }
  
  /* Better spacing for touch */
  .space-y-2 > * + * {
    margin-top: 0.75rem;
  }
  
  .space-x-2 > * + * {
    margin-left: 0.75rem;
  }
}

/* Small mobile devices */
@media (max-width: 640px) {
  /* Compact header */
  .text-xl {
    font-size: 1.125rem;
  }
  
  .text-lg {
    font-size: 1rem;
  }
  
  /* Reduce padding on cards */
  .p-6 {
    padding: 1rem;
  }
  
  .p-4 {
    padding: 0.875rem;
  }
  
  /* Compact email header to maximize content area */
  #email_content .border-b {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }
  
  /* Line clamp for long subjects */
  .line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  
  /* Stack buttons vertically when needed */
  .btn-group-mobile-stack {
    flex-direction: column;
    width: 100%;
  }
  
  .btn-group-mobile-stack .btn {
    width: 100%;
  }
  
  /* Email thread adjustments */
  .email-thread-item [data-email-thread-target="threadContent"] {
    margin-left: 0;
    padding-left: 1rem;
    border-left-width: 2px;
  }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
  /* Fix for iOS rubber band scrolling */
  .fixed {
    -webkit-transform: translateZ(0);
  }
  
  /* Improve performance */
  .glass,
  .glass-darker {
    -webkit-transform: translateZ(0);
    will-change: transform;
  }
}

/* Landscape orientation adjustments */
@media (max-height: 500px) and (orientation: landscape) {
  /* Reduce vertical spacing */
  .py-6 {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }
  
  .my-4 {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
  }
  
  /* Compact email list items */
  .email-item {
    min-height: 60px;
    padding: 0.5rem;
  }
}