/**
 * Mobile Fixes CSS - DEV2-09
 * Common responsive fixes for all pages
 * Include this file in all HTML pages
 */

/* ============================================
   BASE MOBILE FIXES
   ============================================ */

/* Prevent horizontal scroll */
html, body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

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

/* ============================================
   RESPONSIVE TABLES
   ============================================ */

.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: -ms-autohiding-scrollbar;
}

/* Auto-wrap tables */
table {
    width: 100%;
    border-collapse: collapse;
}

@media (max-width: 768px) {
    /* Horizontal scroll hint */
    .table-responsive::after {
        content: '← Scroll →';
        display: block;
        text-align: center;
        font-size: 12px;
        color: #7f8c8d;
        padding: 5px;
        opacity: 0.7;
    }

    .table-responsive::-webkit-scrollbar {
        height: 6px;
    }

    .table-responsive::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 3px;
    }

    .table-responsive::-webkit-scrollbar-thumb {
        background: #3498db;
        border-radius: 3px;
    }
}

/* ============================================
   MOBILE MODALS (Fullscreen)
   ============================================ */

@media (max-width: 576px) {
    .modal-content,
    .modal-dialog,
    [class*="modal"] > div:not(.modal-backdrop) {
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        min-height: 100vh;
        border-radius: 0 !important;
    }

    /* Modal close button always visible */
    .modal .close-btn,
    .modal [class*="close"] {
        position: fixed;
        top: 10px;
        right: 10px;
        z-index: 1001;
        background: rgba(0,0,0,0.5);
        color: white;
        border-radius: 50%;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ============================================
   FORM FIXES
   ============================================ */

@media (max-width: 576px) {
    /* Stack form groups */
    .form-group,
    .form-row,
    [class*="form-grid"] {
        display: block !important;
    }

    .form-group > *,
    .form-row > * {
        width: 100% !important;
        margin-bottom: 10px;
    }

    /* Full width inputs */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="tel"],
    input[type="url"],
    input[type="search"],
    select,
    textarea {
        width: 100% !important;
        max-width: 100% !important;
        font-size: 16px !important; /* Prevents iOS zoom */
    }

    /* Stack buttons */
    .btn-group,
    .button-group,
    [class*="actions"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px;
    }

    .btn-group > button,
    .button-group > button,
    [class*="actions"] > button,
    [class*="actions"] > .btn {
        width: 100% !important;
    }
}

/* ============================================
   TOUCH GESTURES SUPPORT
   ============================================ */

/* Swipe indicator for carousels/sliders */
.swipeable {
    touch-action: pan-x;
    cursor: grab;
}

.swipeable:active {
    cursor: grabbing;
}

/* Pull to refresh indicator */
.pull-to-refresh {
    display: none;
    text-align: center;
    padding: 20px;
    color: #3498db;
}

.pull-to-refresh.active {
    display: block;
}

/* ============================================
   NAVIGATION FIXES
   ============================================ */

@media (max-width: 768px) {
    /* Bottom navigation bar support */
    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        display: flex;
        justify-content: space-around;
        padding: 10px 0;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 999;
    }

    .bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-decoration: none;
        color: #7f8c8d;
        font-size: 12px;
        padding: 5px 10px;
    }

    .bottom-nav a.active {
        color: #3498db;
    }

    .bottom-nav i {
        font-size: 20px;
        margin-bottom: 4px;
    }

    /* Add padding for bottom nav */
    body.has-bottom-nav {
        padding-bottom: 70px;
    }
}

/* ============================================
   CARD FIXES
   ============================================ */

@media (max-width: 480px) {
    .card,
    [class*="card"] {
        margin: 0 -10px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    /* Stats cards in single column */
    .stats-grid,
    .stat-grid,
    [class*="stats"] {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================
   FLOATING ACTION BUTTON (FAB)
   ============================================ */

.fab {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3498db, #2ecc71);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 998;
    transition: transform 0.3s ease;
}

.fab:hover {
    transform: scale(1.1);
}

.fab:active {
    transform: scale(0.95);
}

@media (min-width: 769px) {
    .fab {
        display: none;
    }
}

/* ============================================
   LOADING STATES
   ============================================ */

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   SAFE AREA (iPhone X+)
   ============================================ */

@supports (padding: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }

    body.has-bottom-nav {
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }
}

/* ============================================
   PRINT STYLES (Hide mobile elements)
   ============================================ */

@media print {
    .mobile-header,
    .hamburger,
    .bottom-nav,
    .fab {
        display: none !important;
    }
}

/* ============================================
   DEV4 - MEJORAS MOBILE DE UX Y CONTRASTE
   ============================================ */

/* Boton X de cerrar modal - siempre visible en mobile */
@media (max-width: 576px) {
    .modal-close-btn,
    .fd-modal-close,
    [class*="modal"] .close,
    [class*="modal"] [class*="close"],
    button[onclick*="close"]:not(.nav-button) {
        position: fixed !important;
        top: 15px !important;
        right: 15px !important;
        z-index: 1002 !important;
        background: #dc2626 !important;
        color: #ffffff !important;
        width: 48px !important;
        height: 48px !important;
        border-radius: 50% !important;
        font-size: 28px !important;
        border: 3px solid #ffffff !important;
        box-shadow: 0 4px 12px rgba(0,0,0,0.4) !important;
    }
}

/* Botones con mejor contraste en mobile */
@media (max-width: 768px) {
    button[style*="gradient"] {
        color: #ffffff !important;
        font-weight: 600 !important;
    }

    /* Stat cards clickeables */
    .stat-card {
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(37, 99, 235, 0.2);
    }

    .stat-card:active {
        transform: scale(0.98);
        opacity: 0.9;
    }

    /* Mejor contraste en badges */
    .badge,
    [class*="badge"],
    [class*="status"] {
        font-weight: 600;
    }
}

/* Accesibilidad - focus visible en mobile */
@media (max-width: 768px) {
    button:focus,
    a:focus,
    input:focus,
    select:focus {
        outline: 3px solid #2563eb !important;
        outline-offset: 2px !important;
    }
}

/* ============================================
   FIN DEV4 - MEJORAS MOBILE
   ============================================ */
