/**
 * EventoChain - Mobile Optimization
 * Comprehensive mobile-first responsive design enhancements
 */

/* ========================================
   MOBILE FOUNDATION
   ======================================== */

/* Smooth scrolling for mobile */
html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

/* Prevent horizontal scroll */
body {
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   TOUCH TARGETS (44px minimum for iOS)
   ======================================== */

@media (max-width: 768px) {
  /* All interactive elements */
  a,
  button,
  input,
  select,
  textarea,
  .btn,
  .tab,
  .nav-link,
  .filter-select {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Button padding for touch */
  .btn {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
  }
  
  .btn-small {
    padding: 0.625rem 1rem;
    min-height: 38px;
  }
}

/* ========================================
   NAVIGATION MOBILE ENHANCEMENTS
   ======================================== */

@media (max-width: 768px) {
  .navbar {
    padding: 0.75rem 0;
    position: fixed;
    width: 100%;
    z-index: 1000;
  }
  
  .navbar .container {
    padding: 0 1rem;
  }
  
  .logo {
    font-size: 1.25rem;
    font-weight: 700;
  }
  
  .logo-icon {
    width: 32px;
    height: 32px;
  }
  
  /* Mobile menu improvements */
  .mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: var(--bg-card);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
    transition: right 0.3s ease;
    z-index: 1001;
    overflow-y: auto;
    padding: 5rem 0 2rem 0;
  }
  
  .mobile-menu.active {
    right: 0;
  }
  
  .mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    backdrop-filter: blur(2px);
  }
  
  .mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
  }
  
  /* Navigation links in mobile */
  .nav-links {
    flex-direction: column;
    padding: 0 1.5rem;
    gap: 0.5rem;
  }
  
  /* Only target direct nav links, NOT dropdown items */
  .nav-links > .nav-link,
  .nav-links > .nav-dropdown > .nav-link {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  
  /* User menu mobile */
  .user-menu {
    padding: 1rem 1.5rem;
    border-top: 2px solid var(--border-color);
    margin-top: 1rem;
  }
}

/* ========================================
   HERO SECTIONS MOBILE
   ======================================== */

@media (max-width: 768px) {
  .hero,
  .page-hero {
    padding: 7rem 1rem 3rem;
    min-height: auto;
  }
  
  .hero-content {
    text-align: center;
    padding: 0;
  }
  
  .hero-title,
  h1 {
    font-size: 2rem;
    line-height: 1.2;
    margin-bottom: 1rem;
  }
  
  .hero-subtitle,
  .page-hero p {
    font-size: 1.05rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
  }
  
  .hero-buttons {
    flex-direction: column;
    gap: 1rem;
    width: 100%;
  }
  
  .hero-buttons .btn {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
  }
}

@media (max-width: 480px) {
  .hero-title,
  h1 {
    font-size: 1.75rem;
  }
  
  .hero-subtitle,
  .page-hero p {
    font-size: 1rem;
  }
}

/* ========================================
   EVENTS GRID MOBILE
   ======================================== */

@media (max-width: 1024px) {
  .events-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

@media (max-width: 768px) {
  .events-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    padding: 0 1rem;
  }
  
  .event-card {
    padding: 0;
    border-radius: 1rem;
    overflow: hidden;
  }
  
  .event-image {
    height: 200px;
    object-fit: cover;
  }
  
  .event-content {
    padding: 1.25rem;
  }
  
  .event-title {
    font-size: 1.25rem;
    line-height: 1.4;
  }
  
  .event-date,
  .event-location {
    font-size: 0.9rem;
  }
  
  .event-price {
    font-size: 1.1rem;
  }
  
  .event-actions {
    flex-direction: column;
    gap: 0.75rem;
    padding-top: 1rem;
  }
  
  .event-actions .btn {
    width: 100%;
  }
  
  /* Event price badge */
  .event-price-badge {
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
  }
}

/* ========================================
   FILTERS BAR MOBILE
   ======================================== */

@media (max-width: 768px) {
  .filters-bar {
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
  }
  
  .search-wrapper,
  .filter-select {
    width: 100%;
  }
  
  .search-input {
    font-size: 16px; /* Prevents iOS zoom */
    padding: 0.875rem 1rem 0.875rem 2.75rem;
  }
  
  .filter-select {
    font-size: 16px; /* Prevents iOS zoom */
    padding: 0.875rem 2.5rem 0.875rem 1rem;
  }
}

/* ========================================
   MODALS MOBILE
   ======================================== */

@media (max-width: 768px) {
  .modal,
  .pricing-modal,
  .payment-modal,
  #crypto-payment-modal {
    padding: 0.75rem;
    align-items: flex-start;
    padding-top: 4rem;
  }
  
  .modal-content,
  .pricing-modal-content,
  .payment-modal-content,
  .crypto-payment-content {
    max-width: 100%;
    width: 100%;
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
    margin: 0;
    border-radius: 1rem;
  }
  
  .modal-header,
  .crypto-payment-header {
    padding: 1.25rem 1rem;
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 10;
    border-bottom: 1px solid var(--border-color);
  }
  
  .modal-header h2,
  .crypto-payment-header h2 {
    font-size: 1.35rem;
  }
  
  .modal-body,
  .crypto-payment-body {
    padding: 1.25rem 1rem;
  }
  
  .close-btn {
    width: 44px;
    height: 44px;
    font-size: 1.75rem;
  }
}

/* ========================================
   CRYPTO PAYMENT MODAL MOBILE
   ======================================== */

@media (max-width: 768px) {
  .crypto-modal {
    width: 100%;
    max-width: 100%;
  }
  
  .payment-summary {
    padding: 1.25rem;
    margin-bottom: 1.25rem;
  }
  
  .token-selector {
    margin: 1.25rem 0;
  }
  
  .token-select {
    font-size: 16px; /* Prevents iOS zoom */
    padding: 1rem 3rem 1rem 1rem;
  }
  
  .crypto-price-info {
    padding: 1.75rem 1.25rem;
    margin: 1.25rem 0;
  }
  
  .crypto-amount .amount {
    font-size: 2.25rem;
  }
  
  .crypto-amount .token {
    font-size: 1.35rem;
  }
  
  .usd-equivalent {
    font-size: 1rem;
  }
  
  .rate-info {
    font-size: 0.875rem;
  }
  
  .wallet-section {
    margin: 1.25rem 0;
  }
  
  .btn-connect-wallet {
    padding: 1.125rem 1.5rem;
    font-size: 1.05rem;
    width: 100%;
  }
  
  .btn-connect-wallet span {
    font-size: 1.75rem;
  }
  
  .payment-actions {
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.25rem;
  }
  
  .payment-actions button {
    width: 100%;
    padding: 1.125rem 1.5rem;
    font-size: 1.05rem;
  }
  
  .payment-info {
    margin-top: 1.25rem;
    padding: 1.125rem;
  }
  
  .payment-info p {
    font-size: 0.875rem;
    line-height: 1.5;
  }
}

@media (max-width: 480px) {
  #crypto-payment-modal {
    padding: 0.5rem;
  }
  
  .crypto-amount .amount {
    font-size: 2rem;
  }
  
  .crypto-amount .token {
    font-size: 1.25rem;
  }
}

/* ========================================
   WALLET SELECTOR MODAL MOBILE
   ======================================== */

@media (max-width: 768px) {
  #wallet-selector-modal > div {
    max-width: 90%;
    width: 100%;
    padding: 1.75rem;
  }
  
  #wallet-selector-modal h2 {
    font-size: 1.5rem;
  }
  
  #connect-metamask,
  #connect-walletconnect {
    padding: 1.25rem;
    font-size: 1.05rem;
  }
  
  #connect-metamask span:first-child,
  #connect-walletconnect span:first-child {
    font-size: 2.25rem;
  }
}

/* ========================================
   FORMS MOBILE
   ======================================== */

@media (max-width: 768px) {
  .form-container {
    padding: 1.25rem 1rem;
    margin: 1rem;
  }
  
  .form-group {
    margin-bottom: 1.25rem;
  }
  
  label {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
  }
  
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  textarea,
  select {
    font-size: 16px; /* Prevents iOS zoom */
    padding: 0.875rem 1rem;
    border-radius: 0.5rem;
  }
  
  textarea {
    min-height: 120px;
  }
  
  .form-actions {
    flex-direction: column-reverse;
    gap: 0.75rem;
  }
  
  .form-actions button {
    width: 100%;
  }
}

/* ========================================
   TABLES MOBILE
   ======================================== */

@media (max-width: 768px) {
  .table-responsive {
    margin: 0 -1rem;
    padding: 0 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  table {
    min-width: 600px;
    font-size: 0.875rem;
  }
  
  th,
  td {
    padding: 0.75rem 0.5rem;
  }
  
  /* Card-style table for mobile */
  .mobile-table-card {
    display: block;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
  }
  
  .mobile-table-card .table-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
  }
  
  .mobile-table-card .table-row:last-child {
    border-bottom: none;
  }
}

/* ========================================
   DASHBOARD MOBILE
   ======================================== */

@media (max-width: 768px) {
  .dashboard-layout {
    flex-direction: column;
  }
  
  .dashboard-sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    z-index: 1001;
    transition: left 0.3s ease;
    overflow-y: auto;
  }
  
  .dashboard-sidebar.active {
    left: 0;
  }
  
  .dashboard-main {
    width: 100%;
    padding: 6.5rem 1rem 2rem;
  }
  
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
  }
  
  .dashboard-stats {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0 1rem;
  }
  
  .stat-card {
    padding: 1.25rem;
  }
  
  .stat-value {
    font-size: 2rem;
  }
}

/* ========================================
   FOOTER MOBILE
   ======================================== */

@media (max-width: 768px) {
  .footer {
    padding: 2.5rem 1rem;
  }
  
  .footer-content {
    flex-direction: column;
    gap: 1.5rem;
    text-align: center;
  }
  
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
  }
  
  .footer-column h4 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
  }
  
  .footer-links {
    gap: 0.5rem;
  }
  
  .footer-links a {
    font-size: 0.9rem;
    padding: 0.5rem 0;
  }
  
  .footer-bottom {
    flex-direction: column;
    gap: 1rem;
    padding-top: 1.5rem;
    text-align: center;
  }
  
  .footer-social {
    justify-content: center;
    gap: 1.25rem;
  }
}

@media (max-width: 480px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .footer-column {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
  }
  
  .footer-column:last-child {
    border-bottom: none;
  }
}

/* ========================================
   STATS GRID MOBILE
   ======================================== */

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    padding: 0 1rem;
  }
  
  .stat-card {
    padding: 1.75rem 1.5rem;
  }
  
  .stat-value {
    font-size: 2.25rem;
  }
  
  .stat-label {
    font-size: 1rem;
  }
}

/* ========================================
   FEATURES GRID MOBILE
   ======================================== */

@media (max-width: 1024px) {
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
}

@media (max-width: 640px) {
  .features-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    padding: 0 1rem;
  }
  
  .feature-card {
    padding: 1.75rem 1.5rem;
  }
  
  .feature-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
  }
  
  .feature-card h3 {
    font-size: 1.25rem;
  }
}

/* ========================================
   SECTION SPACING MOBILE
   ======================================== */

@media (max-width: 768px) {
  section {
    padding: 3rem 0;
  }
  
  .container {
    padding: 0 1rem;
  }
  
  .section-title {
    font-size: 1.75rem;
    margin-bottom: 1rem;
  }
  
  .section-subtitle {
    font-size: 1rem;
    margin-bottom: 2rem;
  }
}

/* ========================================
   IMAGES & MEDIA MOBILE
   ======================================== */

@media (max-width: 768px) {
  img {
    max-width: 100%;
    height: auto;
  }
  
  .event-image,
  .photo-item img {
    width: 100%;
    object-fit: cover;
  }
  
  .photo-gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
}

@media (max-width: 480px) {
  .photo-gallery {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* ========================================
   UTILITY CLASSES MOBILE
   ======================================== */

@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }
  
  .show-mobile {
    display: block !important;
  }
  
  .text-center-mobile {
    text-align: center !important;
  }
  
  .full-width-mobile {
    width: 100% !important;
  }
  
  .no-padding-mobile {
    padding: 0 !important;
  }
  
  .no-margin-mobile {
    margin: 0 !important;
  }
}

/* ========================================
   SCROLL IMPROVEMENTS
   ======================================== */

@media (max-width: 768px) {
  /* Smooth momentum scrolling */
  .modal-content,
  .crypto-payment-content,
  .dashboard-sidebar,
  .mobile-menu {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Hide scrollbar but keep functionality */
  .modal-content::-webkit-scrollbar,
  .crypto-payment-content::-webkit-scrollbar {
    width: 4px;
  }
  
  .modal-content::-webkit-scrollbar-track,
  .crypto-payment-content::-webkit-scrollbar-track {
    background: transparent;
  }
  
  .modal-content::-webkit-scrollbar-thumb,
  .crypto-payment-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
  }
}

/* ========================================
   LANDSCAPE ORIENTATION
   ======================================== */

@media (max-width: 768px) and (orientation: landscape) {
  .hero,
  .page-hero {
    padding: 6rem 1rem 2rem;
    min-height: auto;
  }
  
  .modal,
  #crypto-payment-modal {
    padding-top: 2rem;
  }
  
  .modal-content,
  .crypto-payment-content {
    max-height: calc(100vh - 2.5rem);
  }
}

/* ========================================
   SMALL PHONES (380px and below)
   ======================================== */

@media (max-width: 380px) {
  .navbar .container {
    padding: 0 0.75rem;
  }
  
  .logo {
    font-size: 1.1rem;
  }
  
  .logo-icon {
    width: 28px;
    height: 28px;
  }
  
  .hero-title,
  h1 {
    font-size: 1.5rem;
  }
  
  .hero-subtitle {
    font-size: 0.95rem;
  }
  
  .btn {
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
  }
  
  .event-card {
    margin: 0 0.5rem;
  }
  
  .crypto-amount .amount {
    font-size: 1.75rem;
  }
  
  .crypto-amount .token {
    font-size: 1.1rem;
  }
}

/* ========================================
   ANIMATIONS (Reduced motion)
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================================
   DARK MODE ADJUSTMENTS FOR MOBILE
   ======================================== */

@media (max-width: 768px) {
  /* Increase contrast for better readability */
  .event-card,
  .modal-content,
  .crypto-payment-content {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  }
  
  /* Better text contrast */
  .text-secondary {
    color: #b3b3b3;
  }
  
  /* Input focus states */
  input:focus,
  select:focus,
  textarea:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
  }
}

/* ========================================
   ADMIN SIDEBAR MOBILE TOGGLE
   ======================================== */

@media (max-width: 768px) {
  /* Admin sidebar - hidden by default on mobile, revealed with toggle */
  .admin-sidebar,
  .dashboard-sidebar,
  .dashboard-layout .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    width: 280px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease;
    background: var(--bg-secondary, #1a1a2e);
    overflow-y: auto;
  }
  
  .admin-sidebar.mobile-open,
  .dashboard-sidebar.mobile-open,
  .dashboard-layout .sidebar.mobile-open {
    left: 0;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
  }
  
  /* Mobile sidebar toggle button */
  .mobile-sidebar-toggle {
    display: flex !important;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 999;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    font-size: 1.3rem;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  
  /* Sidebar overlay */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 998;
  }
  
  .sidebar-overlay.active {
    display: block;
  }
  
  /* Admin main content - no margin on mobile */
  .admin-main,
  .dashboard-main,
  .dashboard-layout .main-content {
    margin-left: 0 !important;
    padding-top: 60px;
  }
}

@media (min-width: 769px) {
  .mobile-sidebar-toggle {
    display: none !important;
  }
  .sidebar-overlay {
    display: none !important;
  }
}

/* ========================================
   COMMUNITY PAGE iOS SAFE AREA
   ======================================== */

@media (max-width: 768px) {
  .chat-input-area,
  .community-input-area,
  .message-input-wrapper {
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
  }
}

/* ========================================
   INDEX PAGE - PILLAR ARROWS ON MOBILE
   ======================================== */

@media (max-width: 768px) {
  .pillar-arrow {
    display: none !important;
  }
  
  .solution-pillars {
    flex-direction: column !important;
    gap: 1.5rem !important;
  }
  
  .pillar-card,
  .pillar {
    width: 100% !important;
    max-width: 100% !important;
  }
}
