/* Mobile-specific styles for Cherami */

/* Touch feedback */
.touch-active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* Drag and drop indicator */
.drag-active {
    position: relative;
}

.drag-active::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(59, 130, 246, 0.1);
    border: 3px dashed #3B82F6;
    z-index: 30;
    pointer-events: none;
}

/* Improve tap targets on mobile */
@media (max-width: 768px) {
    /* Increase button sizes */
    button, .button, input[type="submit"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Improve form inputs */
    input[type="text"],
    input[type="password"],
    input[type="email"],
    textarea,
    select {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Better spacing for form elements */
    form > * + * {
        margin-top: 1.5rem;
    }
    
    /* File upload area */
    input[type="file"] {
        padding: 0.75rem;
    }
    
    /* Character counter visibility */
    #charCount, #charLimit {
        font-size: 0.875rem;
        font-weight: 500;
    }
    
    /* Navigation improvements */
    header nav {
        gap: 0.5rem;
    }
    
    header nav a {
        padding: 0.5rem;
    }
    
    /* Footer mobile layout */
    footer .grid {
        gap: 2rem;
    }
    
    /* Code blocks in API docs */
    pre, code {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }
    
    /* Pricing cards */
    .pricing-card {
        width: 100%;
        max-width: 100%;
    }
    
    /* Modal and overlay improvements */
    .modal {
        width: 90%;
        max-width: 90%;
        margin: 1rem;
    }
    
    /* Table responsiveness */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Improve readability */
    body {
        font-size: 16px;
        line-height: 1.6;
    }
    
    h1 { font-size: 1.875rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    
    /* How it works cards */
    .how-it-works-card {
        padding: 1.5rem;
    }
    
    /* Message creation form */
    .message-form, .secure-message-section {
        max-width: 100%;
        padding: 1rem;
    }
    
    .message-form textarea {
        width: 100%;
        box-sizing: border-box;
    }
    
    .message-form .form-group {
        margin-bottom: 1rem;
    }
    
    /* File upload section */
    .file-upload-area {
        max-width: 100%;
        word-break: break-word;
    }
    
    /* Button group */
    .button-group {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .button-group button {
        width: 100%;
    }
    
    /* Message display */
    .message-content {
        word-break: break-word;
        overflow-wrap: break-word;
    }
}

/* Landscape mobile adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    header {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    
    .hero-section {
        padding-top: 2rem;
        padding-bottom: 2rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    button, .button {
        border: 2px solid currentColor;
    }
    
    input, textarea, select {
        border-width: 2px;
    }
}

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

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles if needed in future */
}

/* CRITICAL FIX: Mobile form running off screen */
@media (max-width: 768px) {
  #create-form {
    max-width: 100%;
    margin: 0;
    padding: 1rem;
  }
  
  #secureForm {
    width: 100%;
  }
  
  #secureForm textarea,
  #secureForm input[type="text"],
  #secureForm input[type="password"],
  #secureForm select {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    -webkit-box-sizing: border-box !important;
    font-size: 16px !important;
  }
  
  #secureForm .grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
  
  #secureForm .grid > div {
    width: 100%;
  }
  
  #secureForm button[type="submit"] {
    width: 100%;
    margin-top: 1rem;
  }
  
  #secureForm .flex.gap-2 {
    flex-wrap: wrap;
  }
  
  #secureForm input[type="file"] {
    flex: 1;
    min-width: 0;
  }
  
  main {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    /* Fix for iOS input zoom */
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important;
    }
    
    /* Fix for iOS button appearance */
    button, input[type="submit"] {
        -webkit-appearance: none;
        appearance: none;
    }
}

/* Loading states */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #3B82F6;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Sticky footer on mobile */
@media (max-width: 768px) {
    body {
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }
    
    main {
        flex: 1;
    }
}

/* Improve accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid #3B82F6;
    outline-offset: 2px;
}

/* Mobile menu animations and iOS scrolling fix */
#mobile-menu-panel {
    box-shadow: -4px 0 6px -1px rgba(0, 0, 0, 0.1);
}

/* Fix iOS scrolling in mobile menu */
#mobile-menu-panel nav {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 80px); /* Account for header */
}

/* Prevent body scroll when menu is open */
.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Notification badge */
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #EF4444;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 0.125rem 0.375rem;
    border-radius: 9999px;
    min-width: 18px;
    text-align: center;
}

/* Session 12 Additional Fixes */

/* Fix navigation - add auth buttons to mobile */
@media (max-width: 768px) {
  header .max-w-6xl {
    position: relative;
  }
  
  /* Add this to show auth buttons in mobile menu */
  #mobile-menu-panel nav::after {
    content: '';
    display: block;
    height: 1px;
    background: #e5e7eb;
    margin: 1rem 0;
  }
  
  /* Style auth buttons in mobile menu */
  .mobile-auth-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
  }
  
  .mobile-auth-section a {
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 0.5rem;
    font-weight: 500;
  }
  
  .mobile-auth-section a.btn-secondary {
    background: #f3f4f6;
    color: #374151;
  }
  
  .mobile-auth-section a.btn-primary {
    background: #2563eb;
    color: white;
  }
}

/* Fix for redirect preview issue */
.redirect-warning {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 0.5rem;
  padding: 1rem;
  margin: 1rem 0;
  font-size: 0.875rem;
}

.redirect-warning strong {
  color: #d97706;
}

/* Dashboard link fix */
.dashboard-upsell {
  background: #dbeafe;
  border: 1px solid #3b82f6;
  border-radius: 0.5rem;
  padding: 1rem;
  text-align: center;
  margin: 1rem 0;
}

.dashboard-upsell a {
  color: #1d4ed8;
  font-weight: 600;
  text-decoration: underline;
}
