/**
 * CAPA Encuestas v2.0 - Estilos Mobile
 * Mobile-First Responsive Design
 */

/* =====================================
   MOBILE BASE (< 576px)
   ===================================== */
@media (max-width: 575.98px) {
    /* Typography */
    body {
        font-size: 0.9375rem;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    /* Buttons */
    .btn {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .btn-group .btn {
        display: inline-block;
        width: auto;
    }
    
    /* Forms */
    .form-control,
    .form-select {
        font-size: 16px; /* Evita zoom en iOS */
    }
    
    /* Cards */
    .card {
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Tables - Convertir a cards */
    .table-responsive-mobile {
        display: block;
    }
    
    .table-responsive-mobile table {
        display: none;
    }
    
    .mobile-card-list .mobile-card {
        background: #fff;
        border-radius: 0.5rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .mobile-card-list .mobile-card-title {
        font-weight: 600;
        font-size: 1.1rem;
        color: var(--capa-azul-oscuro);
        margin-bottom: 0.75rem;
        padding-bottom: 0.5rem;
        border-bottom: 2px solid var(--capa-purpura);
    }
    
    .mobile-card-list .mobile-card-row {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .mobile-card-list .mobile-card-row:last-child {
        border-bottom: none;
    }
    
    .mobile-card-list .mobile-card-label {
        font-weight: 500;
        color: var(--gris-medio);
        font-size: 0.875rem;
    }
    
    .mobile-card-list .mobile-card-value {
        font-weight: 600;
        text-align: right;
    }
    
    /* Modal */
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-content {
        border-radius: 0.5rem;
    }
}

/* =====================================
   TABLET (576px - 991.98px)
   ===================================== */
@media (min-width: 576px) and (max-width: 991.98px) {
    /* Container */
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Tables */
    .table {
        font-size: 0.9rem;
    }
    
    .table th,
    .table td {
        padding: 0.625rem;
    }
}

/* =====================================
   DESKTOP (>= 992px)
   ===================================== */
@media (min-width: 992px) {
    /* Ocultar elementos solo mobile */
    .mobile-only {
        display: none !important;
    }
    
    /* Mostrar tabla normal */
    .table-responsive-mobile table {
        display: table !important;
    }
    
    .mobile-card-list {
        display: none;
    }
    
    /* Dropdowns en desktop - comportamiento normal de Bootstrap */
    .navbar .dropdown-menu {
        position: absolute !important;
        transform: none !important;
        inset: auto !important;
        background: white !important;
        border: 1px solid rgba(0,0,0,0.15) !important;
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
        margin: 0 !important;
        padding: 0.5rem 0 !important;
        border-radius: 0.375rem !important;
    }
    
    .navbar .dropdown-item {
        color: #212529 !important;
        background: transparent !important;
        padding: 0.5rem 1rem !important;
        border-radius: 0 !important;
        margin: 0 !important;
        font-weight: 400 !important;
    }
    
    .navbar .dropdown-item:hover {
        background-color: #f8f9fa !important;
        color: #001A4D !important;
        transform: none !important;
    }
    
    .navbar .dropdown-item:active {
        background-color: #e9ecef !important;
    }
    
    .navbar .dropdown-divider {
        border-color: #e9ecef !important;
        margin: 0.5rem 0 !important;
    }
    
    .navbar .dropdown-header {
        color: #6c757d !important;
        padding: 0.5rem 1rem !important;
        font-weight: 600 !important;
    }
}

/* =====================================
   TABLET Y MOBILE
   ===================================== */
@media (max-width: 991.98px) {
    /* Navbar */
    .navbar-collapse {
        background-color: var(--capa-azul-oscuro);
        padding: 1rem;
        margin-top: 0.5rem;
        border-radius: 0.5rem;
    }
    
    .navbar-nav {
        gap: 0.5rem;
    }
    
    .nav-item {
        width: 100%;
    }
    
    .nav-link {
        padding: 0.75rem 1rem !important;
        border-radius: 0.375rem;
    }
    
    /* Dropdowns en mobile */
    .navbar .dropdown-menu {
        position: static !important;
        transform: none !important;
        inset: auto !important;
        width: 100% !important;
        background: linear-gradient(135deg, rgba(157, 78, 221, 0.2), rgba(192, 132, 252, 0.2)) !important;
        border: 2px solid rgba(192, 132, 252, 0.3) !important;
        box-shadow: none !important;
        margin: 0.75rem 0 !important;
        padding: 0.75rem !important;
        border-radius: 0.5rem !important;
        display: none !important;
        max-height: none !important;
        overflow: visible !important;
    }
    
    .navbar .dropdown-menu.show {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        animation: slideDown 0.2s ease-out !important;
    }
    
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    .navbar .dropdown-item {
        color: #fff !important;
        background-color: rgba(255, 255, 255, 0.05) !important;
        padding: 0.875rem 1rem !important;
        border-radius: 0.375rem !important;
        margin-bottom: 0.5rem !important;
        font-weight: 500 !important;
        transition: all 0.2s ease !important;
    }
    
    .navbar .dropdown-item:last-child {
        margin-bottom: 0 !important;
    }
    
    .navbar .dropdown-item:hover,
    .navbar .dropdown-item:focus,
    .navbar .dropdown-item:active {
        background-color: rgba(192, 132, 252, 0.3) !important;
        color: #fff !important;
        transform: translateX(5px) !important;
    }
    
    .navbar .dropdown-divider {
        border-color: rgba(255, 255, 255, 0.3) !important;
        margin: 0.5rem 0 !important;
    }
    
    .navbar .dropdown-header {
        color: rgba(255, 255, 255, 0.9) !important;
        padding: 0.5rem 1rem !important;
        font-weight: 600 !important;
    }
    
    /* Ocultar elementos desktop */
    .desktop-only {
        display: none !important;
    }
}

/* =====================================
   LANDSCAPE MOBILE
   ===================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .navbar-brand img {
        height: 30px;
    }
    
    .footer-capa {
        padding: 1rem 0;
        font-size: 0.875rem;
    }
}

/* =====================================
   TOUCH DEVICES
   ===================================== */
@media (hover: none) and (pointer: coarse) {
    /* Aumentar área de click */
    .btn,
    .nav-link,
    a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Remover hover effects en touch */
    .table tbody tr:hover {
        background-color: inherit;
    }
    
    /* Agregar active state */
    .table tbody tr:active {
        background-color: rgba(157, 78, 221, 0.1);
    }
    
    .btn:active {
        transform: scale(0.98);
    }
}

/* =====================================
   UTILIDADES RESPONSIVE
   ===================================== */

/* Scroll horizontal para tablas grandes */
.table-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

.table-scroll-wrapper::-webkit-scrollbar {
    height: 8px;
}

.table-scroll-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb {
    background: var(--capa-purpura);
    border-radius: 10px;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--capa-purpura-oscuro);
}

/* Stack vertical en mobile */
@media (max-width: 575.98px) {
    .stack-mobile {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .stack-mobile > * {
        width: 100% !important;
    }
}

/* Text truncate responsive */
.text-truncate-mobile {
    @media (max-width: 575.98px) {
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

