/* Responsive Styles */
@media (max-width: 768px) {
  header h1 {
    font-size: 2.5rem;
  }
  
  header p {
    font-size: 1.2rem;
  }
  
  .nav-container {
    flex-direction: column;
    position: relative;
  }
  
  .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    margin-top: 1rem;
  }
  
  .nav-links.active {
    display: flex;
  }
  
  .nav-links li {
    margin: 0.5rem 0;
  }
  
  .hamburger {
    display: block;
    position: absolute;
    top: 0.5rem;
    right: -0.7rem;
  }
  
  .section-header h2 {
    font-size: 2rem;
  }
  
  .books-tabs {
    flex-direction: column;
  }
  
  .tab-btn {
    width: 100%;
    text-align: left;
    border-bottom: 1px solid #eee;
  }
  
  .modal-content {
    padding: 2rem 1rem;
    margin: 1rem;
    width: calc(100% - 2rem);
  }
  
  .contact-icon {
    width: 120px;
    height: 120px;
  }
  
  .card-image {
    height: 150px;
  }
  
  .video-link-item {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .watch-btn {
    margin-top: 0.5rem;
    align-self: flex-end;
  }
  
  .dark-mode-toggle {
    position: relative;
    margin: 0.5rem;
  }
  
  .scroll-btn {
    display: none;
  }
  
  
  .auth-container {
    margin-top: 0.5rem;
    width: 100%;
    justify-content: center;
  }
  
  .auth-buttons, .user-menu {
    width: 100%;
    justify-content: center;
  }
  
  .user-menu {
    flex-direction: column;
    text-align: center;
    padding: 1rem;
    gap: 10px;
  }
  
  .user-name {
    max-width: 200px;
  }
  
  .auth-modal-content {
    margin: 1rem;
    width: calc(100% - 2rem);
  }
  
  .auth-form {
    padding: 1.5rem;
  }
  
  .auth-tab {
    padding: 1rem 0.5rem;
    font-size: 0.9rem;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .back-to-top {
    bottom: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 2rem;
  }
  
  header p {
    font-size: 1rem;
  }
  
  section {
    padding: 3rem 1rem;
  }
  
  .section-header h2 {
    font-size: 1.8rem;
  }
  
  .card-content {
    padding: 1rem;
  }
  
  .contact-form {
    padding: 1.5rem;
  }
  
  .modal-content {
    padding: 1.5rem 1rem;
  }
}
/* ===========================================
   MOBILE FULL REDESIGN OVERRIDES
   =========================================== */

@media (max-width: 768px) {
  /* Mobile Modal Foundation */
  .modal {
    padding: 0;
    backdrop-filter: blur(8px);
  }

  .modal-content {
    margin: 0;
    width: 100vw;
    min-height: 100vh;
    max-width: none;
    border-radius: 0;
    box-shadow: none;
    animation: mobileModalIn 0.4s var(--elevate-bezier);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  @keyframes mobileModalIn {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .close-modal {
    top: calc(1rem + env(safe-area-inset-top));
    right: 1rem;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #ff4757, #dc3545);
  }

  /* Auth Modal Mobile */
  .auth-modal-content {
    max-width: none;
    min-height: 100vh;
    border-radius: 0;
  }

  .auth-tabs {
    padding: 1.5rem 1rem 0;
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 10;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
  }

  .auth-tab {
    padding: 1rem;
    font-size: 1rem;
    min-height: 52px;
  }

  .auth-form {
    padding: 2rem 1.5rem;
  }

  .auth-form h3 {
    font-size: 1.8rem;
  }

  .form-group input,
  .form-group select {
    font-size: 16px !important; /* Prevent iOS zoom */
    min-height: 52px;
  }

  .submit-btn {
    min-height: 56px;
    font-size: 1.1rem;
  }

  /* Payment Modal Mobile */
  .payment-modal .modal-content {
    min-height: 100vh;
  }

  .payment-modal .modal-header {
    padding: 2rem 1.5rem 1.5rem;
  }

  .payment-modal .modal-header h2 {
    font-size: 2.2rem;
  }

  .payment-plans {
    grid-template-columns: 1fr;
    gap: 1.2rem;
    padding: 0 1.5rem 2rem;
  }

  .payment-plan {
    padding: 2rem 1.5rem;
    min-height: auto;
    transform: none !important;
  }

  .payment-plan.popular {
    transform: none !important;
    animation: none;
  }

  .price {
    font-size: 3rem;
  }

  .select-plan-btn {
    min-height: 56px;
  }

  .payment-security {
    margin: 1.5rem;
    padding: 1.2rem;
  }

  /* Profile Modal Mobile */
  #profileModal .modal-content {
    min-height: 100vh;
  }

  .profile-fields-grid {
    grid-template-columns: 1fr;
    padding: 0 1.5rem;
  }

  .profile-fields-grid .form-group:nth-child(1),
  .profile-fields-grid .form-group:nth-child(2) {
    grid-column: span 1;
  }

  .avatar-upload {
    margin: 1.5rem;
    padding: 1.5rem;
  }

  .avatar-preview {
    width: 100px;
    height: 100px;
    font-size: 2rem;
  }

  .profile-actions {
    flex-direction: column;
    margin: 2rem 1.5rem;
    gap: 1rem;
  }

  .profile-actions .submit-btn,
  .profile-actions .cancel-btn {
    min-height: 56px;
  }

  #deleteProfile {
    margin: 1rem 1.5rem 2rem;
    min-height: 52px;
  }
}

@media (max-width: 480px) {
  .modal-content {
    padding-top: max(1rem, env(safe-area-inset-top));
  }

  .close-modal {
    top: max(1rem, env(safe-area-inset-top));
    width: 40px;
    height: 40px;
  }

  .auth-tab {
    font-size: 0.95rem;
    padding: 0.9rem 0.5rem;
  }

  .auth-form {
    padding: 1.5rem 1rem;
  }

  .payment-plan {
    padding: 1.8rem 1.2rem;
  }

  .price {
    font-size: 2.5rem;
  }
}
/* === MOBILE AVATAR FIXES === */
@media (max-width: 768px) {
  .avatar-section {
    padding: 0 1.5rem;
  }
  
  .avatar-upload {
    padding: 1.5rem;
  }
  
  .avatar-preview {
    width: 100px;
    height: 100px;
  }
  
  .avatar-controls {
    flex-direction: column;
    align-items: center;
  }
  
  .avatar-upload-btn,
  .avatar-remove-btn {
    width: 100%;
    justify-content: center;
  }
  
  .profile-danger-zone {
    margin: 2rem 1.5rem 1.5rem;
    padding: 1rem;
  }
}
@media (max-width: 768px) {
  /* HTML viewer mobile optimization */
  #htmlViewerContainer {
    height: calc(50vh - 28px);
    min-height: 140px;
    overflow: hidden !important;
  }
 
  .html-content-container {
    height: 100%;
    overflow: scroll !important;
    -webkit-overflow-scrolling: touch !important;
  }
 
  .html-content {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: auto !important;
    -webkit-overflow-scrolling: touch !important;
    pointer-events: auto !important;
    touch-action: pan-y !important;
  }
}
@media (max-width: 768px) {
  .html-content-container {
    padding: 1rem;
    font-size: 14px;
  }
  
  .html-content {
    font-size: 14px;
    line-height: 1.5;
  }
  
  .html-content h1 { font-size: 1.5rem; }
  .html-content h2 { font-size: 1.3rem; }
  .html-content h3 { font-size: 1.2rem; }
  
  .html-content table {
    font-size: 12px;
  }
  
  .html-content table, .html-content th, .html-content td {
    padding: 0.5rem;
  }
}
