/**
 * Mobile Responsive Enhancements
 * Version: 1.0
 * Improved mobile experience and touch interactions
 */

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

/* Touch-friendly tap targets */
button,
.btn,
a,
input[type="button"],
input[type="submit"],
select {
    min-height: 44px;
    min-width: 44px;
}

/* Improve touch scrolling */
.scrollable,
.mobile-menu,
.notification-dropdown .notif-list {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Prevent text selection on interactive elements */
button,
.btn,
.mobile-menu-toggle,
.nav-link {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ============================================
   RESPONSIVE TYPOGRAPHY
   ============================================ */

@media (max-width: 768px) {
    html {
        font-size: 15px;
    }

    h1 {
        font-size: 2rem;
        line-height: 1.2;
    }

    h2 {
        font-size: 1.75rem;
    }

    h3 {
        font-size: 1.5rem;
    }

    h4 {
        font-size: 1.25rem;
    }

    p {
        font-size: 1rem;
        line-height: 1.6;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }
}

/* ============================================
   MOBILE HEADER IMPROVEMENTS
   ============================================ */

@media (max-width: 992px) {
    .modern-header {
        height: 60px;
    }

    .header-wrapper {
        padding: 0 1rem;
        gap: 0.75rem;
    }

    .logo-text {
        font-size: 1.1rem;
    }

    .logo-icon {
        width: 34px;
        height: 34px;
    }

    .header-actions {
        gap: 0.5rem;
    }

    /* Hide less important header elements on mobile */
    .membership-badge-modern,
    .desktop-search {
        display: none;
    }
}

@media (max-width: 768px) {
    .modern-header {
        height: 56px;
    }

    .logo-icon svg {
        width: 24px;
        height: 24px;
    }

    .header-icon-btn {
        width: 40px;
        height: 40px;
    }

    .header-icon-btn svg {
        width: 18px;
        height: 18px;
    }

    .user-avatar {
        width: 40px;
        height: 40px;
    }

    .user-avatar img,
    .user-avatar .avatar-img {
        width: 36px !important;
        height: 36px !important;
    }
}

@media (max-width: 480px) {
    .modern-header {
        height: 52px;
    }

    .header-actions {
        gap: 0.375rem;
    }

    /* Keep only essential buttons */
    .header-icon-btn:not(#mobileMenuToggle):not(.cart-button) {
        display: none;
    }

    .logo-text {
        font-size: 1rem;
    }

    .btn-modern {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }
}

/* ============================================
   MOBILE NAVIGATION IMPROVEMENTS
   ============================================ */

.mobile-menu {
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

.mobile-nav-list > li > a {
    padding: 1rem 1.25rem;
    font-size: 1rem;
    min-height: 56px;
    display: flex;
    align-items: center;
}

.mobile-auth-buttons {
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

.btn-mobile-full {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    min-height: 52px;
}

/* ============================================
   MOBILE CARDS & GRIDS
   ============================================ */

@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    .grid {
        gap: 1rem;
    }

    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 1.25rem;
        border-radius: 1rem;
    }

    .card-title {
        font-size: 1.125rem;
    }
}

/* Two column grid for tablets */
@media (min-width: 481px) and (max-width: 768px) {
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   MOBILE BUTTONS
   ============================================ */

@media (max-width: 480px) {
    .btn {
        width: 100%;
        justify-content: center;
        padding: 0.875rem 1.5rem;
    }

    .btn-group {
        flex-direction: column;
        gap: 0.75rem;
    }

    .hero-buttons {
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
        padding: 0 1rem;
    }

    .hero-buttons .btn {
        width: 100%;
        max-width: none;
    }
}

/* ============================================
   MOBILE FORMS
   ============================================ */

@media (max-width: 768px) {
    .input,
    .textarea,
    .select {
        font-size: 16px; /* Prevents iOS zoom on focus */
        padding: 0.875rem 1rem;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    .form-row {
        flex-direction: column;
        gap: 1rem;
    }
}

/* ============================================
   MOBILE TABLES
   ============================================ */

@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    /* Stack table for better mobile reading */
    .table-stack {
        display: block;
    }

    .table-stack thead {
        display: none;
    }

    .table-stack tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--border-light);
        border-radius: 0.5rem;
        padding: 1rem;
    }

    .table-stack td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border: none;
        border-bottom: 1px solid var(--border-light);
    }

    .table-stack td:last-child {
        border-bottom: none;
    }

    .table-stack td::before {
        content: attr(data-label);
        font-weight: 600;
    }
}

/* ============================================
   MOBILE MODALS
   ============================================ */

@media (max-width: 768px) {
    .modal-content {
        width: 100%;
        max-width: none;
        min-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .modal-header {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--bg-primary);
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        position: sticky;
        bottom: 0;
        background: var(--bg-primary);
        padding: 1rem;
        border-top: 1px solid var(--border-light);
    }
}

/* ============================================
   MOBILE HERO SECTION
   ============================================ */

@media (max-width: 768px) {
    .hero-section {
        padding: 3rem 1rem;
        min-height: auto;
    }

    .hero-content {
        max-width: 100%;
    }

    .hero-title {
        font-size: 2rem;
        margin-bottom: 1rem;
    }

    .hero-description {
        font-size: 1rem;
        margin-bottom: 2rem;
    }
}

/* ============================================
   MOBILE FEATURES SECTION
   ============================================ */

@media (max-width: 768px) {
    .features-section {
        padding: 3rem 1rem;
        margin: 0;
        border-radius: 0;
    }

    .features-section .grid {
        padding: 0;
    }

    .features-section .card {
        padding: 1.5rem;
    }

    .features-section .card-icon {
        font-size: 2rem;
    }

    .features-section .card-title {
        font-size: 1.25rem;
    }
}

/* ============================================
   MOBILE STATS SECTION
   ============================================ */

@media (max-width: 768px) {
    .stats-section {
        padding: 2rem 1rem;
        margin: 0;
        border-radius: 0;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        padding: 0;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .stat-value {
        font-size: 2rem;
    }

    .stat-label {
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   MOBILE COMMUNITY SECTION
   ============================================ */

@media (max-width: 768px) {
    .community-section {
        padding: 2rem 1rem;
        margin: 0;
        border-radius: 0;
    }

    .community-header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
        padding: 0;
    }

    .community-title {
        font-size: 1.5rem;
    }

    .community-grid {
        padding: 0;
    }

    .member-card {
        padding: 1rem;
    }

    .member-avatar {
        width: 48px;
        height: 48px;
    }

    .member-name {
        font-size: 1rem;
    }
}

/* ============================================
   MOBILE WEEKLY SCHEDULE
   ============================================ */

@media (max-width: 768px) {
    .weekly-schedule {
        padding: 1rem;
    }

    .schedule-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .schedule-title {
        font-size: 1.25rem;
    }

    .schedule-nav {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .schedule-nav .btn {
        width: 100%;
    }

    .schedule-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .day-card {
        min-height: 80px;
        padding: 0.75rem;
    }

    .day-name {
        font-size: 0.875rem;
    }

    .day-content {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .schedule-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   MOBILE COURSE CARDS
   ============================================ */

@media (max-width: 768px) {
    .course-card {
        padding: 1.25rem;
    }

    .course-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .course-title {
        font-size: 1.125rem;
    }

    .course-duration {
        font-size: 0.875rem;
    }

    .card-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .card-actions .btn {
        width: 100%;
    }
}

/* ============================================
   MOBILE NOTIFICATION DROPDOWN
   ============================================ */

@media (max-width: 768px) {
    .notification-dropdown {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        width: 100%;
        max-width: none;
        max-height: calc(100vh - 60px);
        border-radius: 0;
        transform: translateY(-100%);
    }

    .notification-dropdown.show {
        transform: translateY(0);
    }

    .notification-dropdown::before {
        display: none;
    }

    .notif-list {
        max-height: calc(100vh - 180px);
    }

    .notif-item {
        padding: 1rem;
    }
}

/* ============================================
   MOBILE USER DROPDOWN
   ============================================ */

@media (max-width: 768px) {
    .user-dropdown {
        position: fixed;
        top: 60px;
        left: 1rem;
        right: 1rem;
        width: auto;
        max-width: none;
        border-radius: 1rem;
    }

    .user-dropdown::before {
        display: none;
    }
}

/* ============================================
   MOBILE FOOTER
   ============================================ */

@media (max-width: 768px) {
    .site-footer {
        padding: 2rem 1rem;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .footer-nav {
        text-align: center;
    }

    .footer-nav ul {
        justify-content: center;
        flex-wrap: wrap;
    }

    .footer-copyright {
        text-align: center;
        margin-top: 2rem;
    }
}

/* ============================================
   LANDSCAPE ORIENTATION FIXES
   ============================================ */

@media (max-height: 500px) and (orientation: landscape) {
    .modern-header {
        height: 48px;
    }

    .mobile-menu {
        top: 48px;
    }

    .hero-section {
        min-height: auto;
        padding: 2rem 1rem;
    }
}

/* ============================================
   iOS SAFE AREA INSETS
   ============================================ */

@supports (padding: max(0px)) {
    .modern-header {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    .mobile-menu {
        padding-left: max(1.5rem, env(safe-area-inset-left));
        padding-right: max(1.5rem, env(safe-area-inset-right));
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    }

    .site-footer {
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .modern-header,
    .site-footer,
    .mobile-menu,
    .mobile-menu-toggle,
    .notification-dropdown,
    .user-dropdown,
    .btn,
    button {
        display: none !important;
    }

    body {
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }

    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }

    img {
        max-width: 100%;
        page-break-inside: avoid;
    }

    a {
        text-decoration: underline;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
}
