/* ============================================
   RESPONSIVE DESIGN - MOBILE FIRST
   Eventos GUAU VIP Platform
   ============================================ */

/* ===== TOUCH FEEDBACK GLOBAL ===== */
button:active,
a:active,
.btn:active,
.nav-link:active {
    transform: scale(0.97);
    opacity: 0.9;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

button,
.btn,
.nav-link {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

/* ===== UTILIDADES RESPONSIVE ===== */
.hide-mobile { display: block; }
.show-mobile { display: none; }
.hide-desktop { display: none; }

/* ============================================
   MOBILE (max-width: 768px)
   ============================================ */
@media screen and (max-width: 768px) {
    
    /* ===== UTILIDADES ===== */
    .hide-mobile { display: none !important; }
    .show-mobile { display: block !important; }
    .hide-desktop { display: block !important; }
    
    /* ===== LAYOUT GENERAL ===== */
    body {
        font-size: 14px;
        overflow-x: hidden;
    }
    
    .container {
        padding: 10px !important;
        max-width: 100% !important;
    }
    
    /* ===== MODAL DE CONSULTA EN MÓVIL ===== */
    .consultation-modal {
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        display: flex;
        flex-direction: column;
    }
    
    .consultation-modal .modal-header {
        padding: 18px 20px;
        flex-shrink: 0;
    }
    
    .consultation-modal .modal-header h3 {
        font-size: 16px;
    }
    
    .consultation-form {
        padding: 20px !important;
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    
    .consultation-form form {
        display: flex;
        flex-direction: column;
        flex: 1;
    }
    
    .consultation-form .form-group {
        margin-bottom: 15px;
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    
    .consultation-form label {
        font-size: 14px;
        margin-bottom: 8px;
    }
    
    .consultation-form textarea {
        padding: 14px;
        font-size: 16px; /* Evita zoom en iOS */
        min-height: 180px;
        flex: 1;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 10px;
        margin-top: 20px;
        flex-shrink: 0;
    }
    
    .form-actions .btn {
        width: 100%;
        padding: 16px;
        font-size: 15px;
    }
    
    /* ===== NAVEGACIÓN HAMBURGER MEJORADA ===== */
    .hamburger-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: var(--primary);
        color: var(--text);
        border: none;
        padding: 10px 15px;
        font-size: 20px;
        border-radius: 10px;
        cursor: pointer;
        min-height: 44px;
        min-width: 44px;
        z-index: 1001;
    }
    
    .nav-overlay-bg {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(0,0,0,0.5);
        z-index: 998;
        backdrop-filter: blur(2px);
    }
    
    .nav-overlay-bg.active {
        display: block;
    }
    
    .desktop-nav {
        position: fixed !important;
        top: 0 !important;
        right: -300px !important;
        width: 280px !important;
        height: 100vh !important;
        background: white !important;
        box-shadow: -5px 0 25px rgba(0,0,0,0.2) !important;
        z-index: 999 !important;
        padding: 80px 20px 20px !important;
        transition: right 0.3s ease !important;
        flex-direction: column !important;
        gap: 5px !important;
        overflow-y: auto !important;
    }
    
    .desktop-nav.mobile-open {
        right: 0 !important;
    }
    
    .desktop-nav .nav-link {
        display: block !important;
        width: 100% !important;
        padding: 15px 20px !important;
        margin: 3px 0 !important;
        border-radius: 12px !important;
        font-size: 0.85rem !important;
        text-align: left !important;
        background: #f8fafc !important;
        border: none !important;
    }
    
    .desktop-nav .nav-link.active {
        background: var(--primary) !important;
        color: var(--text) !important;
    }
    
    .desktop-nav .nav-link:hover {
        background: #f1f5f9 !important;
    }
    
    .menu-toggle {
        display: none !important;
    }
    
    /* ===== HEADER ===== */
    .app-header {
        height: 65px !important;
        padding: 8px 10px !important;
    }
    
    .header-container {
        padding: 0 10px !important;
    }
    
    .header-logo {
        height: 35px !important;
    }
    
    .header-actions {
        gap: 8px !important;
    }
    
    .user-pill span {
        display: none !important;
    }
    
    .btn-logout {
        font-size: 0.7rem !important;
        padding: 8px 12px !important;
        min-height: 36px !important;
    }
    
    /* ===== CONTENIDO PRINCIPAL ===== */
    .app-content {
        margin: 80px auto 80px !important;
        padding: 0 12px !important;
    }
    
    /* ===== TÍTULOS ===== */
    .premium-title {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
    }
    
    h1 { font-size: 1.5rem !important; }
    h2 { font-size: 1.25rem !important; }
    h3 { font-size: 1.1rem !important; }
    h4 { font-size: 1rem !important; }
    
    /* ===== BOTONES ===== */
    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-outline,
    .btn-warning,
    .btn-success,
    .btn-danger,
    button[type="submit"],
    button[type="button"] {
        padding: 14px 20px !important;
        font-size: 0.85rem !important;
        min-height: 48px !important;
        border-radius: 12px !important;
    }
    
    .btn-group,
    .button-group,
    .action-buttons {
        flex-direction: column !important;
        gap: 10px !important;
        width: 100% !important;
    }
    
    .btn-group > *,
    .button-group > *,
    .action-buttons > * {
        width: 100% !important;
    }
    
    /* ===== FORMULARIOS ===== */
    .form-group {
        margin-bottom: 15px !important;
    }
    
    input:not([type="checkbox"]):not([type="radio"]),
    textarea,
    select {
        font-size: 16px !important; /* Evita zoom en iOS */
        padding: 14px !important;
        width: 100% !important;
        min-height: 48px !important;
        border-radius: 12px !important;
    }
    
    label {
        font-size: 0.8rem !important;
        margin-bottom: 8px !important;
    }
    
    /* ===== MODALES RESPONSIVE ===== */
    .modal-overlay {
        padding: 0 !important;
        align-items: flex-end !important;
    }
    
    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 50vh !important;
        max-height: 95vh !important;
        margin: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        overflow: hidden !important;
        animation: slideUpModal 0.3s ease !important;
    }
    
    @keyframes slideUpModal {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    .modal-header {
        position: sticky !important;
        top: 0 !important;
        background: white !important;
        z-index: 10 !important;
        padding: 20px 15px !important;
        border-bottom: 1px solid #eee !important;
    }
    
    .modal-header h3 {
        font-size: 1.1rem !important;
        padding-right: 40px !important;
    }
    
    .modal-body {
        padding: 15px !important;
        overflow-y: auto !important;
        max-height: calc(95vh - 150px) !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .modal-footer {
        position: sticky !important;
        bottom: 0 !important;
        background: white !important;
        padding: 15px !important;
        border-top: 1px solid #eee !important;
    }
    
    .btn-close,
    .modal-close {
        position: absolute !important;
        top: 15px !important;
        right: 15px !important;
        width: 40px !important;
        height: 40px !important;
        font-size: 20px !important;
        background: #f1f5f9 !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* ===== MODAL DE EJERCICIOS - ESPACIO PARA BOTÓN ===== */
    .modal-body {
        padding-bottom: 100px !important; /* Espacio extra para botones */
    }
    
    /* Contenedor de ejercicios */
    .exercise-detail,
    .notes-exercise-card,
    .exercise-card {
        padding-bottom: 80px !important;
    }
    
    /* Asegurar que los botones de acción tengan espacio */
    .exercise-actions,
    .modal-footer {
        margin-bottom: 60px !important;
    }
    
    /* Modal de ejercicio específico */
    .exercise-modal .modal-body {
        padding-bottom: 120px !important;
    }
    
    /* Contenedor de contenido del ejercicio */
    .exercise-content {
        padding-bottom: 100px !important;
    }
    
    /* Botones de ejercicio */
    .exercise-actions {
        margin-bottom: 80px !important;
        padding-bottom: 20px !important;
    }
    
    /* Scroll suave en modales */
    .modal-content {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scroll-padding-bottom: 100px !important;
    }
    
    /* Pseudo-elemento para espacio extra al final del scroll */
    .modal-body:after {
        content: "";
        display: block;
        height: 100px;
        width: 100%;
    }
    
    /* ===== TABLAS RESPONSIVE ===== */
    .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        margin: 0 -12px !important;
        padding: 0 12px !important;
    }
    
    table {
        min-width: 500px !important;
        font-size: 0.75rem !important;
    }
    
    table th,
    table td {
        padding: 10px 8px !important;
        white-space: nowrap !important;
    }
    
    /* ===== GRIDS RESPONSIVE ===== */
    .grid,
    .stats-grid,
    .stats-grid-improved,
    .exercise-grid,
    .student-grid,
    .dashboard-grid,
    .forum-categories,
    .health-visual-container,
    .request-sliders-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    /* 2 columnas para stats */
    .stats-grid-improved {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* ===== CARDS ===== */
    .card,
    .exercise-card,
    .student-card,
    .stat-card,
    .consultation-card,
    .forum-post,
    .live-card {
        margin: 10px 0 !important;
        padding: 15px !important;
        border-radius: 16px !important;
    }
    
    .stat-card {
        padding: 12px !important;
        flex-direction: column !important;
        text-align: center !important;
        gap: 8px !important;
    }
    
    .stat-icon {
        font-size: 1.8rem !important;
    }
    
    .stat-value {
        font-size: 1.4rem !important;
    }
    
    .stat-label {
        font-size: 0.65rem !important;
    }
    
    /* ===== DASHBOARD ===== */
    .dashboard-card {
        padding: 15px !important;
    }
    
    /* ===== CALENDARIO ===== */
    .calendar-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    
    .calendar-day {
        min-height: auto !important;
        padding: 12px !important;
    }
    
    .day-header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }
    
    .days-row {
        gap: 6px !important;
        justify-content: center !important;
    }
    
    .day-selector label {
        width: 38px !important;
        height: 38px !important;
        font-size: 0.7rem !important;
    }
    
    /* ===== MIS APUNTES ===== */
    .notes-container {
        padding: 10px !important;
    }
    
    .notes-exercise-card {
        padding: 15px !important;
        margin: 10px 0 !important;
    }
    
    .exercise-media,
    .notes-exercise-card video,
    .notes-exercise-card iframe {
        max-height: 200px !important;
        width: 100% !important;
        border-radius: 12px !important;
    }
    
    .exercise-status-badge {
        font-size: 0.6rem !important;
        padding: 6px 10px !important;
    }
    
    /* ===== SALUD COMPORTAMENTAL ===== */
    .health-section {
        padding: 15px !important;
    }
    
    .health-main-grid {
        grid-template-columns: 1fr !important;
    }
    
    .traffic-light {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .traffic-light-item {
        width: 100% !important;
    }
    
    .health-form {
        padding: 15px !important;
    }
    
    .health-meter-box {
        padding: 12px !important;
    }
    
    .meter-track {
        height: 10px !important;
    }
    
    /* ===== CONSULTAS ===== */
    .consultation-card {
        padding: 15px !important;
        margin: 10px 0 !important;
    }
    
    .consultation-reply {
        margin-left: 0 !important;
        margin-top: 10px !important;
        padding: 12px !important;
        border-left: 3px solid var(--primary) !important;
    }
    
    /* ===== FORO ===== */
    .forum-post {
        padding: 15px !important;
        margin: 10px 0 !important;
    }
    
    .forum-comment {
        margin-left: 10px !important;
        padding: 12px !important;
    }
    
    /* ===== DIRECTOS ===== */
    .live-card {
        padding: 15px !important;
        margin: 10px 0 !important;
    }
    
    .live-video,
    .live-card video,
    .live-card iframe {
        height: 180px !important;
        border-radius: 12px !important;
    }
    
    /* ===== PERFIL ===== */
    .profile-section,
    .profile-field {
        padding: 15px !important;
    }
    
    .profile-avatar {
        width: 70px !important;
        height: 70px !important;
    }
    
    .profile-main-grid {
        grid-template-columns: 1fr !important;
    }
    
    .profile-grid {
        grid-template-columns: 1fr !important;
    }
    
    .subscription-card {
        padding: 15px !important;
    }
    
    .sub-actions {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .sub-actions button {
        width: 100% !important;
    }
    
    /* ===== ZONA DE PELIGRO ===== */
    .danger-zone {
        padding: 15px !important;
    }
    
    /* ===== ADMIN PANEL ===== */
    .admin-container {
        padding: 10px !important;
    }
    
    .admin-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 5px !important;
        padding-bottom: 10px !important;
        margin: 0 -12px !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    
    .admin-tabs button,
    .admin-tabs .tab-btn {
        flex-shrink: 0 !important;
        min-width: auto !important;
        padding: 10px 15px !important;
        font-size: 0.75rem !important;
        white-space: nowrap !important;
        border-radius: 20px !important;
    }
    
    .admin-content {
        padding: 15px !important;
    }
    
    /* Ficha de alumno */
    .student-file {
        padding: 15px !important;
    }
    
    .student-header {
        flex-direction: column !important;
        gap: 15px !important;
        text-align: center !important;
    }
    
    .student-actions {
        flex-direction: column !important;
        width: 100% !important;
        gap: 8px !important;
    }
    
    .student-actions button {
        width: 100% !important;
    }
    
    .student-tabs {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        flex-wrap: nowrap !important;
        gap: 5px !important;
        padding-bottom: 10px !important;
    }
    
    .student-tabs button {
        flex-shrink: 0 !important;
        min-width: 100px !important;
        font-size: 0.7rem !important;
        padding: 10px 12px !important;
        white-space: nowrap !important;
    }
    
    /* Calendario admin */
    .calendar-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* ===== ANALÍTICAS ===== */
    .analytics-container {
        padding: 10px !important;
    }
    
    .chart-container {
        height: 220px !important;
        overflow-x: auto !important;
    }
    
    /* ===== LANDING PAGE ===== */
    .hero {
        padding: 40px 15px !important;
        text-align: center !important;
    }
    
    .hero h1 {
        font-size: 1.8rem !important;
        line-height: 1.2 !important;
    }
    
    .hero p {
        font-size: 1rem !important;
    }
    
    .features-grid {
        grid-template-columns: 1fr !important;
    }
    
    .pricing-grid {
        grid-template-columns: 1fr !important;
    }
    
    .pricing-card {
        margin: 10px 0 !important;
    }
    
    /* ===== LOGIN/REGISTRO ===== */
    .auth-container {
        padding: 20px 15px !important;
    }
    
    .auth-form {
        padding: 20px !important;
    }
    
    .guest-container {
        padding: 10px !important;
    }
    
    /* ===== PROGRESS BAR ===== */
    .progress-bar-container {
        height: 24px !important;
        border-radius: 12px !important;
    }
    
    .progress-bar {
        font-size: 0.7rem !important;
        padding-right: 8px !important;
    }
    
    /* ===== VIDEOS Y MEDIA ===== */
    video,
    iframe {
        max-width: 100% !important;
        border-radius: 12px !important;
    }
    
    .video-container {
        position: relative !important;
        padding-bottom: 56.25% !important; /* 16:9 */
        height: 0 !important;
        overflow: hidden !important;
    }
    
    .video-container iframe,
    .video-container video {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
    }
    
    /* ===== SLIDERS ===== */
    input[type="range"] {
        width: 100% !important;
        height: 8px !important;
    }
    
    /* ===== TOAST NOTIFICATIONS ===== */
    #toast-container {
        bottom: 80px !important;
        right: 10px !important;
        left: 10px !important;
        max-width: none !important;
    }
    
    .toast {
        padding: 15px !important;
        font-size: 0.85rem !important;
        border-radius: 12px !important;
    }
    
    /* ===== LOADER ===== */
    .loader-overlay {
        padding: 20px !important;
    }
    
    .spinner {
        width: 40px !important;
        height: 40px !important;
    }
    
    /* ===== TEXTOS ===== */
    p {
        font-size: 0.9rem !important;
        line-height: 1.6 !important;
    }
    
    .text-muted {
        font-size: 0.8rem !important;
    }
    
    /* ===== ESPACIADO INFERIOR PARA NAVEGACIÓN FIJA ===== */
    .app-content::after {
        content: '';
        display: block;
        height: 60px;
    }
}

/* ============================================
   TABLET (768px - 1024px)
   ============================================ */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    
    .container {
        padding: 15px;
    }
    
    .grid,
    .stats-grid,
    .stats-grid-improved,
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .admin-tabs {
        flex-wrap: wrap;
    }
    
    .modal-content {
        width: 85% !important;
        max-width: 600px !important;
    }
    
    .calendar-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .hamburger-btn {
        display: none !important;
    }
    
    .desktop-nav {
        position: relative !important;
        right: auto !important;
        width: auto !important;
        height: auto !important;
        flex-direction: row !important;
        box-shadow: none !important;
        padding: 0 !important;
        background: transparent !important;
    }
}

/* ============================================
   SMALL MOBILE (max-width: 480px)
   ============================================ */
@media screen and (max-width: 480px) {
    
    .premium-title {
        font-size: 1.3rem !important;
    }
    
    h1 { font-size: 1.3rem !important; }
    h2 { font-size: 1.1rem !important; }
    h3 { font-size: 1rem !important; }
    
    .app-content {
        padding: 0 8px !important;
        margin-top: 75px !important;
    }
    
    .card,
    .stat-card {
        padding: 12px !important;
    }
    
    .stats-grid-improved {
        grid-template-columns: 1fr !important;
    }
    
    .stat-card {
        flex-direction: row !important;
        text-align: left !important;
    }
    
    .day-selector label {
        width: 32px !important;
        height: 32px !important;
        font-size: 0.6rem !important;
    }
    
    .ex-pill {
        font-size: 0.65rem !important;
        padding: 8px !important;
    }
    
    button,
    .btn {
        padding: 12px 16px !important;
        font-size: 0.8rem !important;
    }
    
    input:not([type="checkbox"]):not([type="radio"]),
    textarea,
    select {
        padding: 12px !important;
    }
    
    .modal-header h3 {
        font-size: 1rem !important;
    }
    
    .hero h1 {
        font-size: 1.5rem !important;
    }
    
    .header-logo {
        height: 30px !important;
    }
}

/* ============================================
   LANDSCAPE MOBILE
   ============================================ */
@media screen and (max-width: 900px) and (orientation: landscape) {
    
    .modal-content {
        max-height: 100vh !important;
        height: 100vh !important;
        border-radius: 0 !important;
    }
    
    .modal-body {
        max-height: calc(100vh - 120px) !important;
    }
    
    .app-header {
        height: 55px !important;
    }
    
    .app-content {
        margin-top: 70px !important;
    }
    
    .header-logo {
        height: 30px !important;
    }
}

/* ============================================
   SAFE AREA (Notch devices)
   ============================================ */
@supports (padding: max(0px)) {
    @media screen and (max-width: 768px) {
        .app-header {
            padding-top: max(8px, env(safe-area-inset-top)) !important;
            padding-left: max(10px, env(safe-area-inset-left)) !important;
            padding-right: max(10px, env(safe-area-inset-right)) !important;
        }
        
        .app-content {
            padding-left: max(12px, env(safe-area-inset-left)) !important;
            padding-right: max(12px, env(safe-area-inset-right)) !important;
            padding-bottom: max(20px, env(safe-area-inset-bottom)) !important;
        }
        
        .desktop-nav.mobile-open {
            padding-top: max(80px, calc(env(safe-area-inset-top) + 60px)) !important;
        }
        
        #toast-container {
            bottom: max(80px, calc(env(safe-area-inset-bottom) + 60px)) !important;
        }
        
        /* Safe area para modal de ejercicios en iOS */
        .modal-body {
            padding-bottom: calc(100px + env(safe-area-inset-bottom)) !important;
        }
        
        .exercise-actions {
            margin-bottom: calc(60px + env(safe-area-inset-bottom)) !important;
        }
        
        .modal-footer {
            padding-bottom: calc(15px + env(safe-area-inset-bottom)) !important;
        }
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .hamburger-btn,
    .nav-overlay-bg,
    .desktop-nav,
    .app-header,
    #toast-container {
        display: none !important;
    }
    
    .app-content {
        margin: 0 !important;
        padding: 20px !important;
    }
}



/* ============================================
   ADMIN PROFILE TAB - RESPONSIVE
   ============================================ */
@media screen and (max-width: 768px) {
    /* Tabs del modal de perfil */
    .modal-content .tab-btn {
        font-size: 0.7rem !important;
        padding: 0.6rem 0.5rem !important;
        flex: 1 !important;
        min-width: auto !important;
    }
    
    /* Grid de perfil del perro y dueño */
    #tab-profile > div > div:first-child {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Grid de carácter y objetivo */
    #tab-profile > div > div:nth-child(2) {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Cards en perfil */
    #tab-profile .card {
        padding: 1rem !important;
    }
    
    /* Filas de datos del perro/dueño */
    #tab-profile .card > div > div {
        padding: 0.6rem !important;
        font-size: 0.85rem !important;
    }
    
    /* Cabecera del modal en móvil */
    .modal-content > div:first-child {
        padding: 1rem !important;
        flex-direction: column !important;
        gap: 1rem !important;
    }
    
    .modal-content > div:first-child > div:last-child {
        flex-wrap: wrap !important;
        justify-content: center !important;
    }
    
    .modal-content > div:first-child .btn {
        font-size: 0.7rem !important;
        padding: 0.4rem 0.6rem !important;
    }
}

@media screen and (max-width: 480px) {
    /* Tabs más compactos */
    .modal-content .tab-btn {
        font-size: 0.6rem !important;
        padding: 0.5rem 0.3rem !important;
    }
    
    /* Título más pequeño */
    #tab-profile h3, #tab-profile h4 {
        font-size: 1rem !important;
    }
    
    /* Texto del carácter y objetivo */
    #tab-profile p {
        font-size: 0.9rem !important;
        min-height: 60px !important;
    }
}
