/* ===== COMPREHENSIVE RESPONSIVE FIX ===== */

/* ===== MOBILE-FIRST BASE STYLES ===== */

/* Ensure viewport is set correctly */
html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  overflow-x: hidden;
}

/* ===== PROFILE IMAGE FIX FOR ALL SCREEN SIZES ===== */
.profile-img {
  display: block !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* Ensure profile container is centered */
.text-center .relative.inline-block {
  display: block !important;
  margin: 0 auto !important;
}

/* ===== MODAL RESPONSIVE IMPROVEMENTS ===== */

/* Base modal styles */
.modal,
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-content {
  position: relative;
  margin: auto;
  width: 92%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Modal header responsive */
.modal-header {
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.modal-header h2 {
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
}

/* Modal body scrolling */
.modal-body {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ===== TABLET RESPONSIVE (max-width: 1024px) ===== */
@media (max-width: 1024px) {
  .modal-content {
    width: 90%;
    max-width: 650px;
  }
  
  .modal-header {
    padding: 1.75rem 1.5rem 1.25rem;
  }
  
  .modal-body {
    padding: 1.5rem;
  }
  
  /* Link cards */
  .modal-body .link-card {
    padding: 1rem;
    flex-direction: row;
    align-items: center;
  }
  
  /* Timeline adjustments */
  .timeline-item {
    gap: 1.25rem;
  }
  
  .date-badge {
    width: 3.5rem;
    height: 3.5rem;
    font-size: 1.35rem;
  }
}

/* ===== TABLET RESPONSIVE (max-width: 768px) ===== */
@media (max-width: 768px) {
  /* Modal adjustments */
  .modal-content {
    width: 95%;
    max-width: 100%;
    max-height: 95vh;
    border-radius: 1rem;
    margin: 0.5rem auto;
  }
  
  .modal-header {
    padding: 1.5rem 1.25rem 1rem;
    flex-direction: row;
    align-items: flex-start;
  }
  
  .modal-header h2 {
    font-size: 1.25rem;
    line-height: 1.4;
  }
  
  .modal-header h2::before {
    width: 3px;
    height: 1.5rem;
  }
  
  .close {
    width: 36px;
    height: 36px;
    font-size: 28px;
    flex-shrink: 0;
  }
  
  .modal-body {
    padding: 1.25rem;
    max-height: calc(95vh - 100px);
  }
  
  /* Link cards responsive */
  .modal-body .link-card {
    padding: 1rem;
    flex-direction: column;
    text-align: center;
    gap: 0.75rem;
  }
  
  .modal-body .link-card .bg-opacity-20 {
    width: 3rem;
    height: 3rem;
  }
  
  .modal-body .link-card .bg-opacity-20 i {
    font-size: 1.25rem;
  }
  
  .modal-body .link-card h3 {
    font-size: 0.95rem;
  }
  
  .modal-body .link-card p {
    font-size: 0.8125rem;
  }
  
  /* Timeline responsive */
  .timeline-item {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }
  
  .timeline-item:not(:last-child)::after {
    display: none;
  }
  
  .timeline-date {
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    min-width: auto;
  }
  
  .date-badge {
    width: 3rem;
    height: 3rem;
    font-size: 1.125rem;
  }
  
  .timeline-content {
    width: 100%;
    padding: 1rem;
  }
  
  .timeline-content h3 {
    font-size: 1rem;
  }
  
  .timeline-content p {
    font-size: 0.875rem;
  }
  
  /* FAQ responsive */
  .faq-question {
    padding: 1rem;
    flex-direction: row;
  }
  
  .faq-question h3 {
    font-size: 0.9375rem;
  }
  
  .faq-answer p {
    padding: 1rem;
    font-size: 0.875rem;
  }
  
  /* Folder structure */
  .folder-header {
    padding: 1rem;
    flex-wrap: wrap;
  }
  
  .folder-icon {
    width: 2.5rem;
    height: 2.5rem;
  }
  
  .folder-icon i {
    font-size: 1.25rem;
  }
  
  .folder-name {
    font-size: 0.95rem;
  }
  
  .folder-meta {
    font-size: 0.75rem;
    flex-wrap: wrap;
  }
  
  .file-item {
    padding: 0.875rem;
    flex-wrap: wrap;
  }
  
  .file-icon {
    width: 2rem;
    height: 2rem;
  }
  
  .file-name {
    font-size: 0.875rem;
  }
  
  /* Buttons */
  .btn-primary {
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
  }
}

/* ===== MOBILE RESPONSIVE (max-width: 480px) ===== */
@media (max-width: 480px) {
  /* Modal mobile */
  .modal-content {
    width: 98%;
    max-height: 98vh;
    border-radius: 0.75rem;
    margin: 0.25rem auto;
  }
  
  .modal-header {
    padding: 1.25rem 1rem 0.875rem;
  }
  
  .modal-header h2 {
    font-size: 1.125rem;
    gap: 0.5rem;
  }
  
  .modal-header h2::before {
    width: 2px;
    height: 1.25rem;
  }
  
  .close {
    width: 32px;
    height: 32px;
    font-size: 24px;
  }
  
  .modal-body {
    padding: 1rem;
    max-height: calc(98vh - 85px);
  }
  
  /* Link cards extra small */
  .modal-body .link-card {
    padding: 0.875rem;
  }
  
  .modal-body .link-card .bg-opacity-20 {
    width: 2.5rem;
    height: 2.5rem;
  }
  
  .modal-body .link-card .bg-opacity-20 i {
    font-size: 1rem;
  }
  
  .modal-body .link-card h3 {
    font-size: 0.875rem;
  }
  
  .modal-body .link-card p {
    font-size: 0.75rem;
  }
  
  /* Timeline mobile */
  .timeline-date {
    gap: 0.5rem;
  }
  
  .date-badge {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1rem;
    border-radius: 0.75rem;
  }
  
  .month {
    font-size: 0.75rem;
  }
  
  .timeline-content {
    padding: 0.875rem;
  }
  
  .timeline-content h3 {
    font-size: 0.9375rem;
  }
  
  .timeline-content p {
    font-size: 0.8125rem;
  }
  
  /* FAQ mobile */
  .faq-question {
    padding: 0.875rem 1rem;
  }
  
  .faq-question h3 {
    font-size: 0.875rem;
  }
  
  .faq-question i {
    font-size: 1rem;
  }
  
  .faq-answer p,
  .faq-answer ul,
  .faq-answer ol {
    padding: 0.875rem 1rem;
    font-size: 0.8125rem;
  }
  
  /* Folder structure mobile */
  .folder-header {
    padding: 0.875rem 1rem;
  }
  
  .folder-icon {
    width: 2.25rem;
    height: 2.25rem;
  }
  
  .folder-icon i {
    font-size: 1.125rem;
  }
  
  .folder-name {
    font-size: 0.875rem;
  }
  
  .folder-meta {
    font-size: 0.6875rem;
  }
  
  .folder-action-btn {
    width: 2rem;
    height: 2rem;
    font-size: 0.875rem;
  }
  
  .file-item {
    padding: 0.75rem;
  }
  
  .file-icon {
    width: 1.75rem;
    height: 1.75rem;
  }
  
  .file-icon i {
    font-size: 0.875rem;
  }
  
  .file-name {
    font-size: 0.8125rem;
  }
  
  .file-meta {
    font-size: 0.6875rem;
  }
  
  .file-action-btn {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.75rem;
  }
  
  /* Buttons mobile */
  .btn-primary {
    padding: 0.625rem 1.25rem;
    font-size: 0.8125rem;
  }
}

/* ===== EXTRA SMALL MOBILE (max-width: 360px) ===== */
@media (max-width: 360px) {
  .modal-content {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
  }
  
  .modal-header h2 {
    font-size: 1rem;
  }
  
  .modal-body {
    padding: 0.875rem;
  }
  
  .modal-body .link-card {
    padding: 0.75rem;
  }
  
  .date-badge {
    width: 2.25rem;
    height: 2.25rem;
    font-size: 0.875rem;
  }
}

/* ===== MARKETPLACE PAGE RESPONSIVE ===== */

/* Product cards */
@media (max-width: 768px) {
  .product-card {
    width: 100%;
    max-width: 100%;
  }
  
  .product-image-container {
    height: auto;
    min-height: 200px;
  }
  
  .product-img {
    width: 100%;
    height: auto;
    object-fit: cover;
  }
}

@media (max-width: 480px) {
  .product-image-container {
    min-height: 150px;
  }
}

/* Image modal responsive */
#imageModal .modal-content {
  width: 95%;
  max-width: 95%;
  padding: 0;
}

#imageModal img {
  max-width: 100%;
  max-height: 85vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

@media (max-width: 768px) {
  #imageModal img {
    max-height: 80vh;
  }
}

@media (max-width: 480px) {
  #imageModal img {
    max-height: 75vh;
  }
}

/* ===== PAYMENT MODAL RESPONSIVE ===== */

.modal-overlay .modal-content {
  width: 90%;
  max-width: 500px;
}

@media (max-width: 768px) {
  .modal-overlay .modal-content {
    width: 95%;
  }
  
  .modal-overlay form input,
  .modal-overlay form select {
    font-size: 16px !important; /* Prevent zoom on iOS */
  }
}

@media (max-width: 480px) {
  .modal-overlay .modal-content {
    width: 98%;
    max-width: 100%;
  }
}

/* ===== TOAST NOTIFICATIONS RESPONSIVE ===== */

.copy-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  max-width: calc(100% - 4rem);
}

@media (max-width: 768px) {
  .copy-toast {
    bottom: 1.5rem;
    right: 1.5rem;
    left: 1.5rem;
    max-width: calc(100% - 3rem);
  }
}

@media (max-width: 480px) {
  .copy-toast {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
    padding: 0.875rem 1.25rem;
    font-size: 0.875rem;
  }
}

/* ===== LANDSCAPE ORIENTATION FIX ===== */

@media (max-height: 500px) and (orientation: landscape) {
  .modal-content {
    max-height: 95vh;
    margin: 0.5rem auto;
  }
  
  .modal-header {
    padding: 0.875rem 1rem;
  }
  
  .modal-header h2 {
    font-size: 1rem;
  }
  
  .modal-body {
    padding: 1rem;
    max-height: calc(95vh - 70px);
  }
}

/* ===== TOUCH IMPROVEMENTS ===== */

/* Larger touch targets for mobile */
@media (max-width: 768px) {
  .close,
  .close-modal,
  .folder-action-btn,
  .file-action-btn {
    min-width: 44px;
    min-height: 44px;
  }
  
  .link-card,
  .faq-question,
  .folder-header {
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  }
}

/* Smooth scrolling for touch devices */
.modal-body,
.modal-content {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */

/* Focus visible for keyboard navigation */
.close:focus,
.link-card:focus,
.btn-primary:focus,
.faq-question:focus {
  outline: 2px solid #4F46E5;
  outline-offset: 2px;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
