﻿/* 
   MOBILE OPTIMIZATION - Perfect Mobile Experience
   Load this AFTER styles.css and dashboard.css
*/

/* Base Mobile Optimizations */
@media (max-width: 768px) {

    /* Typography */
    html {
        font-size: 14px;
    }

    h1 {
        font-size: 2.2rem !important;
        line-height: 1.2;
    }

    h2 {
        font-size: 1.8rem !important;
        line-height: 1.3;
    }

    h3 {
        font-size: 1.4rem !important;
        line-height: 1.4;
    }

    /* Container & Spacing */
    .container {
        width: 95%;
        padding: 0 15px;
    }

    .section-padding {
        padding: 60px 0;
    }

    /* Buttons */
    .btn-primary,
    .btn-secondary {
        padding: 16px 30px;
        font-size: 0.85rem;
        width: 100%;
        justify-content: center;
    }

    .btn-primary i,
    .btn-secondary i {
        margin-right: 8px;
    }

    /* Prettier Navigation (App-like Scrollable Tabs) */
    nav {
        padding: 15px 0 5px 0;
        background: rgba(10, 10, 10, 0.95);
        -webkit-backdrop-filter: blur(20px);
        backdrop-filter: blur(20px);
        border-radius: 0;
        border-bottom: 1px solid rgba(255,255,255,0.05);
        top: 0;
        width: 100%;
    }

    .logo {
        font-size: 1.3rem;
        padding-left: 10px;
    }

    .nav-links {
        flex-direction: row;
        gap: 12px;
        width: 100%;
        margin-top: 15px;
        overflow-x: auto;
        padding-bottom: 15px;
        padding-left: 10px;
        padding-right: 10px;
        scrollbar-width: none; /* Hide scrollbar Firefox */
        -webkit-overflow-scrolling: touch;
    }
    
    .nav-links::-webkit-scrollbar {
        display: none; /* Hide scrollbar webkit */
    }

    .nav-links a {
        width: max-content;
        flex: 0 0 auto;
        text-align: center;
        padding: 8px 18px;
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 30px;
        font-size: 0.85rem;
        font-weight: 500;
        white-space: nowrap;
        transition: all 0.2s;
    }

    .nav-links a:hover, .nav-links a.active {
        background: rgba(198, 168, 124, 0.15);
        border-color: rgba(198, 168, 124, 0.4);
        color: #fff;
    }

    /* Cards Grid (App-Style Cards) */
    .courses-grid,
    .bookings-grid {
        grid-template-columns: 1fr !important;
        gap: 20px;
        padding: 0 5px;
    }

    .course-card, .booking-card {
        margin-bottom: 15px;
        border-radius: 20px;
        background: linear-gradient(135deg, #161618 0%, #111112 100%);
        border: 1px solid rgba(255,255,255,0.06);
        box-shadow: 0 10px 30px rgba(0,0,0,0.6);
        overflow: hidden;
    }

    .course-image {
        height: 200px;
        border-radius: 20px 20px 0 0;
    }

    .course-content {
        padding: 20px;
    }

    .course-meta {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
        justify-content: flex-start;
        border-bottom: 1px solid rgba(255,255,255,0.05);
        padding-bottom: 15px;
        margin-bottom: 15px;
    }

    .course-footer {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
    }

    .price {
        text-align: left;
        font-size: 1.6rem;
        font-weight: 700;
    }
    
    .course-footer .btn-primary {
        width: max-content;
        padding: 12px 25px;
        border-radius: 30px;
    }

    /* Course Detail Page */
    .detail-hero {
        min-height: 45vh;
        padding: 120px 20px 40px;
    }

    .detail-hero h1 {
        font-size: 2rem !important;
        margin-bottom: 15px;
        letter-spacing: -0.5px;
    }

    .hero-subtitle {
        font-size: 0.95rem;
        opacity: 0.9;
    }

    .breadcrumb {
        margin-bottom: 20px;
        font-size: 0.85rem;
        background: rgba(0,0,0,0.5);
        display: inline-block;
        padding: 5px 15px;
        border-radius: 20px;
    }

    .detail-grid {
        grid-template-columns: 1fr !important;
        gap: 20px;
        margin-top: -30px;
    }

    .detail-block {
        padding: 25px;
        border-radius: 20px;
        background: #111;
        border: 1px solid rgba(255,255,255,0.05);
    }

    .detail-block h2 {
        font-size: 1.4rem !important;
        margin-bottom: 20px;
        padding-bottom: 15px;
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }

    .curriculum-list,
    .requirements-list {
        padding-left: 0;
    }

    .curriculum-list li,
    .requirements-list li {
        padding: 15px 0;
        font-size: 0.95rem;
        border-bottom: 1px solid rgba(255,255,255,0.02);
    }

    .includes-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px;
    }

    .include-item {
        padding: 15px 10px;
        border-radius: 12px;
        background: #18181a;
        text-align: center;
    }
    .include-item i {
        font-size: 1.5rem;
        margin-bottom: 8px;
    }

    /* Booking Card Sidebar (App CTA sticky simulation) */
    .detail-right {
        position: static !important;
        top: auto !important;
        order: -1; /* Pushes the buy card to the top on mobile! */
        margin-bottom: 20px;
    }

    .booking-card {
        padding: 25px;
        text-align: center;
        border-top: 4px solid var(--secondary-gold);
        background: #161618;
    }

    .booking-price {
        font-size: 2.2rem !important;
        margin: 15px 0;
    }

    .booking-card .btn-primary {
        border-radius: 30px;
        padding: 18px;
        font-size: 1rem;
        letter-spacing: 1px;
    }

    .booking-info .info-row {
        padding: 12px 0;
        justify-content: space-between;
    }

    .booking-note {
        font-size: 0.85rem;
        padding: 10px;
        background: rgba(255,255,255,0.03);
        border-radius: 8px;
    }

    /* Checkout Page */
    .checkout-container {
        flex-direction: column;
        gap: 30px;
    }

    .checkout-left,
    .checkout-right {
        width: 100%;
    }

    .form-row {
        grid-template-columns: 1fr !important;
    }

    .bank-details {
        padding: 20px;
    }

    .bank-account {
        padding: 15px;
        margin-bottom: 12px;
    }

    .account-number {
        font-size: 1.3rem;
    }

    .file-upload-area {
        padding: 30px 20px;
    }

    .file-preview img {
        max-height: 200px;
    }

    /* Dashboard / Mi Cuenta */
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding: 25px 20px;
        border-radius: 20px;
        margin-top: 20px;
        background: linear-gradient(135deg, rgba(20,20,20,0.9), rgba(10,10,10,0.9));
    }

    .dashboard-header h1 {
        font-size: 2.2rem !important;
    }

    .booking-card .booking-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        background: transparent;
    }

    .booking-details {
        grid-template-columns: 1fr 1fr !important; /* Side by side on mobile */
        gap: 10px;
    }

    .detail-item {
        padding: 10px;
        font-size: 0.85rem;
        border-radius: 10px;
        background: rgba(255,255,255,0.03);
    }

    .booking-actions {
        flex-direction: row; /* Horizontal actions */
        gap: 10px;
    }
    
    .booking-actions .btn-secondary {
        border-radius: 30px;
        font-size: 0.8rem;
        padding: 12px;
    }

    .status-badge {
        align-self: flex-start;
    }

    /* Admin Panel */
    .admin-form {
        padding: 25px 20px;
    }

    .admin-form h2 {
        font-size: 1.6rem !important;
    }

    .filter-tabs {
        flex-direction: column;
        gap: 10px;
    }

    .filter-tab {
        width: 100%;
        justify-content: center;
        padding: 14px;
    }

    /* Empty States */
    .empty-state,
    .error-state,
    .loader-container {
        padding: 60px 20px !important;
    }

    .empty-state i,
    .error-state i {
        font-size: 3rem !important;
    }

    .empty-state h3,
    .error-state h3 {
        font-size: 1.3rem !important;
    }

    /* Auth Modals */
    .auth-modal-content {
        width: 95% !important;
        padding: 25px 20px !important;
        max-height: 95vh;
    }

    .auth-modal h2 {
        font-size: 1.6rem !important;
    }

    .auth-modal-close {
        top: 15px;
        right: 15px;
        font-size: 1.8rem;
    }

    /* Tables */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Touch Improvements */
    a,
    button,
    input,
    select,
    textarea {
        -webkit-tap-highlight-color: rgba(198, 168, 124, 0.2);
    }

    /* Prevent text size adjustment on orientation change */
    html {
        -webkit-text-size-adjust: 100%;
        -más-text-size-adjust: 100%;
    }

    /* Form inputs - minimum 16px to prevent iOS zoom */
    input,
    select,
    textarea {
        font-size: 16px !important;
    }

    /* Better touch targets (minimum 44x44px) */
    button,
    .btn-primary,
    .btn-secondary,
    a.btn-primary,
    a.btn-secondary {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Small Mobile (< 480px) */
@media (max-width: 480px) {
    h1 {
        font-size: 1.8rem !important;
    }

    h2 {
        font-size: 1.5rem !important;
    }

    .container {
        width: 100%;
        padding: 0 12px;
    }

    .section-padding {
        padding: 40px 0;
    }

    .btn-primary,
    .btn-secondary {
        padding: 14px 20px;
        font-size: 0.8rem;
    }

    .course-card,
    .booking-card {
        padding: 15px;
    }

    .detail-block {
        padding: 20px 15px;
    }

    .booking-price {
        font-size: 1.8rem !important;
    }

    .auth-modal-content {
        padding: 20px 15px !important;
    }

    /* Smaller badges */
    .status-badge,
    .badge-warning,
    .badge-sold {
        font-size: 0.7rem;
        padding: 6px 10px;
    }

    /* Compact navigation */
    .logo {
        font-size: 1.1rem;
    }

    .nav-links a {
        padding: 10px;
        font-size: 0.85rem;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .detail-hero {
        min-height: 60vh;
    }

    .section-padding {
        padding: 50px 0;
    }

    .auth-modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* Safe Area Insets for iOS */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }

    nav {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }

    .auth-modal-content {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
        padding-bottom: max(25px, env(safe-area-inset-bottom));
    }
}

/* Prevent rubber band scrolling on iOS */
body {
    overscroll-behavior-y: none;
}

/* Smooth scrolling for mobile */
* {
    -webkit-overflow-scrolling: touch;
}

/* Optimize images for mobile */
img {
    max-width: 100%;
    height: auto;
}

/* Better select dropdowns on mobile */
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c6a87c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
    padding-right: 40px;
}

/* Loading States - Optimized for mobile */
@media (max-width: 768px) {
    .spinner-large {
        width: 50px !important;
        height: 50px !important;
        border-width: 3px !important;
    }

    .spinner {
        width: 14px !important;
        height: 14px !important;
    }
}

/* Notification Positioning for Mobile */
@media (max-width: 768px) {
    .admin-notification {
        top: 10px !important;
        right: 10px !important;
        left: 10px !important;
        padding: 12px 18px !important;
        font-size: 0.85rem !important;
    }
}

/* Success Messages Mobile */
@media (max-width: 768px) {
    .success-notification {
        width: calc(100% - 20px);
        margin: 0 10px;
    }
}

/* ==============================================================
   ADMIN PANEL MOBILE ENHANCEMENTS & ANALYTICS
   ============================================================== */
@media (max-width: 768px) {
    /* 1. Dashboard Metrics (Reservas & Facturas) */
    /* Force 2 columns on mobile so it looks like an App Dashboard */
    div[style*="minmax(180px"] {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
    }
    
    .stats-cards {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
    }

    .stat-card {
        padding: 15px 10px !important;
    }
    .stat-card i { font-size: 1.4rem !important; margin-bottom: 8px !important; }
    .stat-value { font-size: 1.4rem !important; margin: 4px 0 !important; }
    .stat-label { font-size: 0.65rem !important; }

    /* 2. Facturas - Table Scroll & Filters */
    .invoices-filters {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
        padding: 15px !important;
    }
    
    .search-box, .filter-select, .export-btn {
        width: 100% !important;
    }

    .invoices-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 12px;
        scrollbar-width: none; /* Hide scrollbar */
    }
    .invoices-table-container::-webkit-scrollbar {
        display: none;
    }
    
    .invoices-table {
        min-width: 800px; /* Enforce width to keep table readable while scrolling */
    }

    /* 3. Reservas Admin Cards Override */
    .dashboard-page .booking-card {
        grid-template-columns: 1fr !important; /* Stack rows */
        gap: 12px !important;
        background: linear-gradient(135deg, rgba(30, 30, 30, 0.95), rgba(20, 20, 20, 0.95)) !important;
        border-radius: 20px !important;
        padding: 20px !important;
        box-shadow: 0 10px 20px rgba(0,0,0,0.4) !important;
    }
    
    .booking-actions {
        width: 100%;
        justify-content: flex-start !important;
        border-top: 1px solid rgba(255,255,255,0.05);
        padding-top: 15px;
        margin-top: 5px;
    }
    
    .btn-icon {
        flex: 1; /* Stretch action buttons */
        border-radius: 12px !important;
    }
}
