/**
 * Responsive CSS for NaMA Website
 * 
 * Enhanced responsive styles to ensure optimal display on all devices
 * including mobile phones, tablets, laptops, and desktop screens
 * 
 * Colors maintained: Purple (#6A0DAD), Gold (#FFD700), White (#FFFFFF)
 */

/* Base mobile-first styles - start with smallest device and scale up */
:root {
  --container-padding: 1rem;
  --mobile-menu-bg: rgba(106, 13, 173, 0.95);
  --mobile-menu-item-border: rgba(255, 215, 0, 0.3);
  --touch-target-size: 44px; /* Minimum size for touch targets */
  --mobile-font-scale: 0.9;
  --tablet-font-scale: 0.95;
  --desktop-font-scale: 1;
}

/* General responsive adjustments */
.container {
  width: 100%;
  padding-left: var(--container-padding);
  padding-right: var(--container-padding);
  margin-left: auto;
  margin-right: auto;
  overflow-x: hidden; /* Prevent horizontal scroll */
}

img {
  max-width: 100%;
  height: auto;
  display: block; /* Remove bottom spacing */
}

/* Better touch targets for mobile devices */
button, 
.btn,
a.nav-link,
input[type="submit"],
.clickable {
  min-height: var(--touch-target-size);
  min-width: var(--touch-target-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Accessible focus styles */
a:focus, button:focus, input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(106, 13, 173, 0.5);
  outline-offset: 3px;
  transition: outline-offset 0.1s ease;
}

/* Responsive typography */
html {
  font-size: calc(15px * var(--mobile-font-scale));
}

/* Hide scrollbar but keep functionality */
.scroll-container {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.scroll-container::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
  :root {
    --container-padding: 1.5rem;
  }
  
  .container {
    max-width: 540px;
  }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
  .container {
    max-width: 720px;
  }
  
  /* Improve spacing on medium screens */
  .py-md-6 {
    padding-top: 4rem !important;
    padding-bottom: 4rem !important;
  }
  
  .my-md-6 {
    margin-top: 4rem !important;
    margin-bottom: 4rem !important;
  }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
  .container {
    max-width: 960px;
  }
  
  /* Adjust navigation for desktop */
  .navbar .navbar-nav {
    display: flex;
    flex-direction: row;
  }
  
  .navbar .dropdown-menu {
    position: absolute;
  }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
  .container {
    max-width: 1140px;
  }
  
  html {
    font-size: calc(16px * var(--desktop-font-scale));
  }
}

/* Extra extra large devices (ultra wide screens, 1400px and up) */
@media (min-width: 1400px) {
  .container {
    max-width: 1320px;
  }
  
  /* More breathing room for large screens */
  .section-padding {
    padding: 6rem 0;
  }
}

/* Mobile navigation adjustments */
@media (max-width: 991px) {
  /* Mobile menu toggle - improved animations and accessibility */
  .navbar-collapse {
    max-height: 0;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    background: var(--mobile-menu-bg);
    border-radius: 0 0 16px 16px;
    margin-top: 0.5rem;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(-10px);
    /* Improve Safari support */
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    /* Safe area inset for notched phones */
    padding-bottom: env(safe-area-inset-bottom, 0.5rem);
  }
  
  .navbar-collapse.show {
    max-height: 80vh;
    overflow-y: auto;
    opacity: 1;
    transform: translateY(0);
    /* Improve scrolling */
    -webkit-overflow-scrolling: touch;
  }
  
  /* Mobile menu container - Enhanced visibility */
  #mobile-menu {
    display: none;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
  }
  
  #mobile-menu.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
  }
  
  /* Stack menu items vertically */
  .navbar-nav {
    flex-direction: column;
    width: 100%;
    padding: 0.75rem;
  }
  
  .navbar-nav .nav-item {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--mobile-menu-item-border);
    transition: background-color 0.3s ease, transform 0.2s ease;
  }
  
  .navbar-nav .nav-item:hover {
    background-color: rgba(255, 215, 0, 0.1);
    transform: translateX(5px);
  }
  
  .navbar-nav .nav-item:last-child {
    border-bottom: none;
  }
  
  .navbar-nav .nav-link {
    display: flex;
    align-items: center;
  }
  
  .navbar-nav .nav-link i {
    margin-right: 10px;
    font-size: 1.1em;
    color: rgba(255, 215, 0, 0.9);
  }
  
  /* Adjust dropdown menus for mobile */
  .dropdown-menu {
    border: none;
    padding-left: 1.5rem;
    background-color: rgba(255, 255, 255, 0.05);
    border-left: 2px solid var(--secondary-color);
    margin-left: 0.5rem;
    margin-top: 0.5rem;
    border-radius: 0 0 0 8px;
    transition: all 0.3s ease;
  }
  
  @media (max-width: 767px) { /* Apply these styles only on screens smaller than Tailwind's md breakpoint */
  /* Enhanced mobile menu toggle button with dramatic styling */
  #mobile-menu-button {
    border: 3px solid #FFD700;
    padding: 0.4rem;
    border-radius: 8px;
    width: 52px;
    height: 52px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    background-color: #6A0DAD;
    position: relative;
    z-index: 1000;
    cursor: pointer;
    outline: none;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
  }
}
  
  /* Hamburger icon lines with enhanced visibility and animations */
  #mobile-menu-button span.hamburger-line {
    display: block;
    width: 30px;
    height: 5px;
    margin: 0 auto;
    background-color: #FFD700;
    border-radius: 4px;
    transition: all 0.3s ease;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
  }
  
  /* Individual lines positioning with improved spacing */
  #mobile-menu-button span.line-1 {
    margin-top: 2px;
    margin-bottom: 4px;
  }
  
  #mobile-menu-button span.line-2 {
    margin-bottom: 4px;
  }
  
  #mobile-menu-button span.line-3 {
    margin-bottom: 2px;
  }
  
  /* Animation for active state (when menu is open) */
  #mobile-menu-button.active span.line-1 {
    transform: translateY(8px) rotate(45deg);
  }
  
  #mobile-menu-button.active span:nth-child(2) {
    opacity: 0;
  }
  
  #mobile-menu-button.active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
  }
  
  #mobile-menu-button:hover, #mobile-menu-button:focus {
    background-color: rgba(255, 215, 0, 0.2);
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.35);
  }
  
  /* Site name in header - three row styling */
  .navbar-brand .site-name {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
  }
  
  .navbar-brand .site-name .name-row-1 {
    font-size: 0.95rem;
    font-weight: 700;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
  }
  
  .navbar-brand .site-name .name-row-2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
  }
  
  .navbar-brand .site-name .name-row-3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: #FFD700;
    opacity: 0.9;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
  }
  
  /* Improve menu animations */
  .navbar-nav .nav-item {
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.3s ease;
  }
  
  .navbar-collapse.show .navbar-nav .nav-item {
    opacity: 1;
    transform: translateX(0);
  }
  
  /* Stagger animation for menu items */
  .navbar-collapse.show .navbar-nav .nav-item:nth-child(1) { transition-delay: 0.05s; }
  .navbar-collapse.show .navbar-nav .nav-item:nth-child(2) { transition-delay: 0.1s; }
  .navbar-collapse.show .navbar-nav .nav-item:nth-child(3) { transition-delay: 0.15s; }
  .navbar-collapse.show .navbar-nav .nav-item:nth-child(4) { transition-delay: 0.2s; }
  .navbar-collapse.show .navbar-nav .nav-item:nth-child(5) { transition-delay: 0.25s; }
  .navbar-collapse.show .navbar-nav .nav-item:nth-child(6) { transition-delay: 0.3s; }
  .navbar-collapse.show .navbar-nav .nav-item:nth-child(7) { transition-delay: 0.35s; }
  .navbar-collapse.show .navbar-nav .nav-item:nth-child(8) { transition-delay: 0.4s; }
  
  /* Special styles for Join button in mobile menu */
  .navbar-nav .nav-item .btn-join {
    background-color: var(--secondary-color);
    color: #000;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    display: inline-block;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }
  
  .navbar-nav .nav-item .btn-join:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  }
  
  /* Language switcher in mobile */
  .mobile-language-switcher {
    display: flex;
    align-items: center;
    padding: 0.75rem 0.5rem;
    border-top: 1px solid var(--mobile-menu-item-border);
    margin-top: 0.5rem;
  }
  
  /* Responsive forms */
  .form-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Responsive table adjustments */
@media (max-width: 767px) {
  /* Custom header styles for mobile */
  header .navbar-brand {
    font-size: 1.2rem;
  }
  
  /* Hero section text adjustments */
  .hero-content h1 {
    font-size: 2rem;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
  }
  
  /* Adjust buttons on small screens */
  .btn {
    width: 100%;
    margin-bottom: 0.5rem;
    padding: 0.75rem 1rem;
  }
  /* Make tables scrollable on small screens */
  .table-responsive-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -ms-overflow-style: -ms-autohiding-scrollbar;
  }
  
  /* Adjust card layouts */
  .card-deck {
    display: block;
  }
  
  .card-deck .card {
    margin-bottom: 1.5rem;
    border-left: 3px solid var(--primary-color);
    border-right: 3px solid var(--secondary-color);
  }
  
  /* Responsive grid for membership form */
  .grid-cols-1, 
  .md\:grid-cols-2, 
  .md\:grid-cols-3 {
    grid-template-columns: 1fr !important;
  }
}

/* Dark mode styles */
@media (prefers-color-scheme: dark) {
  :root {
    --dark-bg: #121212;
    --dark-surface: #1e1e1e;
    --dark-text: #f5f5f5;
  }
  
  body.dark-mode-enabled {
    background-color: var(--dark-bg);
    color: var(--dark-text);
  }
  
  body.dark-mode-enabled .card,
  body.dark-mode-enabled .navbar {
    background-color: var(--dark-surface);
  }
  
  body.dark-mode-enabled .text-dark {
    color: var(--dark-text) !important;
  }
  
  body.dark-mode-enabled .border {
    border-color: rgba(255, 215, 0, 0.2) !important;
} /* Closes @media (prefers-color-scheme: dark) */
}

/* Force hide mobile menu button on desktop if Tailwind's md:hidden is not working */
@media (min-width: 768px) {
  #mobile-menu-button {
    display: none !important;
  }
}

/* Print styles */
@media print {
  .no-print {
    display: none !important;
  }
  
  a[href]:after {
    content: " (" attr(href) ")";
  }
  
  .container {
    max-width: none;
    width: 100%;
  }
}
