/* Estilos para el modal emergente del sorteo */
.modal-open {
    overflow: hidden;
}

/* Modal base - CRITICO para comportamiento emergente */
.raffle-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: rgba(0, 0, 0, 0.8) !important;
    z-index: 9999 !important;
    display: none !important; /* Inicialmente oculto */
    align-items: center !important;
    justify-content: center !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    opacity: 0 !important;
    transition: opacity 0.3s ease !important;
}

/* Modal visible */
.raffle-modal:not([style*="display: none"]) {
    display: flex !important;
    opacity: 1 !important;
}

/* Overlay del modal */
.raffle-modal-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    z-index: 1 !important;
}

/* Contenido del modal */
.raffle-modal-content {
    position: relative !important;
    background: white !important;
    border-radius: 12px !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3) !important;
    width: 90% !important;
    max-width: 800px !important;
    max-height: 90vh !important;
    overflow: hidden !important;
    z-index: 2 !important;
    margin: 20px !important;
    transform: scale(0.7) !important;
    transition: transform 0.3s ease !important;
}

/* Contenido visible */
.raffle-modal:not([style*="display: none"]) .raffle-modal-content {
    transform: scale(1) !important;
}

/* Header del modal */
.raffle-modal-header {
    background: linear-gradient(135deg, #007cba 0%, #005a8e 100%) !important;
    color: white !important;
    padding: 20px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    border-radius: 12px 12px 0 0 !important;
}

.raffle-modal-header h3 {
    margin: 0 !important;
    font-size: 18px !important;
    font-weight: 600 !important;
}

/* Botón cerrar */
.raffle-modal-close {
    background: none !important;
    border: none !important;
    color: white !important;
    font-size: 24px !important;
    cursor: pointer !important;
    padding: 0 !important;
    width: 30px !important;
    height: 30px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background-color 0.2s ease !important;
}

.raffle-modal-close:hover {
    background-color: rgba(255, 255, 255, 0.2) !important;
}

/* Body del modal */
.raffle-modal-body {
    padding: 20px !important;
    max-height: 60vh !important;
    overflow-y: auto !important;
}

/* Footer del modal */
.raffle-modal-footer {
    background: #f8f9fa !important;
    padding: 20px !important;
    border-top: 1px solid #dee2e6 !important;
    border-radius: 0 0 12px 12px !important;
    display: flex !important;
    justify-content: flex-end !important;
    gap: 10px !important;
}

/* Estilos específicos del contenido del modal */
.quantity-display {
    background: linear-gradient(135deg, #f0f8ff 0%, #e6f3ff 100%) !important;
    border: 1px solid #b8e0ff !important;
    border-radius: 8px !important;
    padding: 15px !important;
    margin-bottom: 20px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}

.quantity-info {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    font-size: 14px !important;
}

.total-price {
    text-align: right !important;
}

.total-price .amount {
    font-size: 18px !important;
    font-weight: bold !important;
    color: #007cba !important;
}

.selection-section {
    margin-bottom: 20px !important;
}

.selection-section h4 {
    margin: 0 0 10px 0 !important;
    color: #333 !important;
    font-size: 16px !important;
}

.selection-help {
    color: #666 !important;
    font-size: 14px !important;
    margin-bottom: 15px !important;
}

.auto-selection-notice {
    background: #f0f8ff !important;
    border: 1px solid #b8e0ff !important;
    border-radius: 6px !important;
    padding: 12px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

/* Grid container */
.numbers-grid-container {
    border: 1px solid #dee2e6 !important;
    border-radius: 8px !important;
    background: white !important;
    overflow: hidden !important;
}

.grid-header {
    background: #f8f9fa !important;
    padding: 10px 15px !important;
    border-bottom: 1px solid #dee2e6 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}

/* **NUEVO: Estilos para paginación** */
.grid-pagination {
    background: #f8f9fa !important;
    padding: 15px !important;
    border-top: 1px solid #dee2e6 !important;
    border-bottom: 1px solid #dee2e6 !important;
    text-align: center !important;
}

.pagination-info {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 10px !important;
    margin-bottom: 8px !important;
}

.pagination-summary {
    font-size: 12px !important;
    color: #666 !important;
    font-style: italic !important;
}

.page-btn {
    background: #007cba !important;
    color: white !important;
    border: 1px solid #005a8e !important;
    border-radius: 4px !important;
    padding: 6px 12px !important;
    font-size: 12px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

.page-btn:hover:not(:disabled) {
    background: #005a8e !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 4px rgba(0, 124, 186, 0.3) !important;
}

.page-btn:disabled {
    background: #6c757d !important;
    border-color: #6c757d !important;
    cursor: not-allowed !important;
    opacity: 0.6 !important;
    transform: none !important;
    box-shadow: none !important;
}

#page-info {
    font-weight: bold !important;
    color: #333 !important;
    padding: 0 15px !important;
    font-size: 14px !important;
}

#showing-range {
    font-size: 12px !important;
    color: #666 !important;
}

/* Responsive para paginación */
@media (max-width: 768px) {
    .pagination-info {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    
    .page-btn {
        padding: 4px 8px !important;
        font-size: 11px !important;
    }
    
    #page-info {
        padding: 0 10px !important;
        font-size: 12px !important;
    }
}

@media (max-width: 480px) {
    .pagination-info {
        flex-direction: column !important;
        gap: 5px !important;
    }
    
    .page-btn {
        min-width: 60px !important;
    }
}

.grid-legend {
    background: #f8f9fa !important;
    padding: 10px 15px !important;
    border-top: 1px solid #dee2e6 !important;
    display: flex !important;
    gap: 15px !important;
    font-size: 12px !important;
}

.legend-item {
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
}

.legend-color {
    width: 12px !important;
    height: 12px !important;
    border-radius: 2px !important;
    display: inline-block !important;
}

.legend-color.available {
    background: #28a745 !important;
}

.legend-color.selected {
    background: #007bff !important;
}

.legend-color.sold {
    background: #dc3545 !important;
}

.legend-color.reserved {
    background: #ffc107 !important;
}

.raffle-modal *,
.raffle-modal *::before,
.raffle-modal *::after {
    box-sizing: border-box;
}

/* Estilos para grilla de números */
.numbers-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)) !important;
    gap: 8px !important;
    padding: 20px !important;
    max-height: 400px !important;
    overflow-y: auto !important;
    background: #f8f9fa !important;
    border: 2px solid #dee2e6 !important;
    border-radius: 8px !important;
}

.ticket-number {
    width: 50px !important;
    height: 50px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 2px solid transparent !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    font-weight: bold !important;
    font-size: 14px !important;
    transition: all 0.2s ease !important;
    user-select: none !important;
    background: #28a745 !important;
    color: white !important;
}

.ticket-number:hover {
    transform: scale(1.05) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
}

.ticket-number.available {
    background: #28a745 !important;
    color: white !important;
}

.ticket-number.available:hover {
    background: #218838 !important;
}

.ticket-number.selected {
    background: #007bff !important;
    color: white !important;
    border-color: #0056b3 !important;
    transform: scale(1.1) !important;
    box-shadow: 0 4px 12px rgba(0,123,255,0.3) !important;
}

.ticket-number.sold {
    background: #dc3545 !important;
    color: white !important;
    cursor: not-allowed !important;
    opacity: 0.7 !important;
}

.ticket-number.reserved {
    background: #ffc107 !important;
    color: #212529 !important;
    cursor: not-allowed !important;
    opacity: 0.8 !important;
}

.loading-grid {
    opacity: 0.5 !important;
    pointer-events: none !important;
}

/* Animaciones */
.raffle-modal {
    animation: fadeIn 0.3s ease-out;
}

.raffle-modal-content {
    animation: slideUp 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(50px) scale(0.95);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Botones mejorados */
.raffle-modal .btn {
    font-family: inherit;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    user-select: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.raffle-modal .btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
}

.raffle-modal .btn-primary {
    background: linear-gradient(135deg, #007cba 0%, #005a8e 100%);
    border: 1px solid #005a8e;
}

.raffle-modal .btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #005a8e 0%, #004570 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.3);
}

.raffle-modal .btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    border: 1px solid #5a6268;
}

.raffle-modal .btn-secondary:hover {
    background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
}

.raffle-modal .btn-outline {
    background: white;
    border: 2px solid #007cba;
    color: #007cba;
}

.raffle-modal .btn-outline:hover {
    background: #007cba;
    color: white;
}

/* Mejoras en los inputs */
.raffle-modal .form-control,
.raffle-modal .form-group input {
    border: 2px solid #e9ecef;
    transition: all 0.2s ease;
    font-size: 14px;
}

.raffle-modal .form-control:focus,
.raffle-modal .form-group input:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
    outline: none;
}

/* Estados de validación */
.validation-message {
    border-radius: 6px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.validation-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-color: #b8dabc;
    color: #155724;
}

.validation-error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border-color: #f1b0b7;
    color: #721c24;
}

.validation-success::before {
    content: "✅";
}

.validation-error::before {
    content: "❌";
}

/* Mejoras en las estadísticas */
.raffle-stats {
    background: linear-gradient(135deg, #f0f8ff 0%, #e6f3ff 100%);
    border: 1px solid #b8e0ff;
}

.stat-item.available .number {
    color: #28a746d4;
}

.stat-item.sold .number {
    color: #dc3545;
}

/* Progress bar mejorado */
.progress-bar {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

.progress-fill {
    background: linear-gradient(90deg, #28a745 0%, #20c997 50%, #007cba 100%);
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%
    );
    animation: shine 2s infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Scrollbar personalizado */
.raffle-modal-body::-webkit-scrollbar {
    width: 8px;
}

.raffle-modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.raffle-modal-body::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #007cba 0%, #005a8e 100%);
    border-radius: 4px;
}

.raffle-modal-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #005a8e 0%, #004570 100%);
}

/* Efectos hover mejorados */
.detail-item {
    transition: all 0.2s ease;
    cursor: default;
}

.detail-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-left-color: #005a8e;
    background: #ffffff;
}

/* Responsive mejorado */
@media (max-width: 768px) {
    .raffle-modal-content {
        margin: 10px;
        border-radius: 16px;
    }
    
    .raffle-modal-header {
        padding: 16px;
    }
    
    .raffle-modal-header h3 {
        font-size: 16px;
    }
    
    .raffle-modal-body {
        padding: 16px;
    }
    
    .raffle-modal-footer {
        padding: 12px 16px;
        flex-direction: column;
    }
    
    .raffle-modal-footer .btn {
        width: 100%;
        margin-bottom: 8px;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .raffle-modal-content {
        margin: 5px;
        max-height: 98vh;
    }
    
    .quantity-display {
        padding: 12px;
    }
    
    .total-price .amount {
        font-size: 16px;
    }
}

/* Estados de carga */
.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Efectos de focus mejorados */
.raffle-modal .btn:focus,
.raffle-modal .form-control:focus,
.raffle-modal .form-group input:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Toast notifications */
.toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 16px 20px;
    z-index: 10001;
    animation: slideInRight 0.3s ease-out;
    max-width: 400px;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-notification.success {
    border-left: 4px solid #28a745;
}

.toast-notification.error {
    border-left: 4px solid #dc3545;
}

/* =====================================
   MEJORAS PARA MÓVILES - MODAL
   ===================================== */

/* Tablet y móviles grandes */
@media (max-width: 768px) {
    .raffle-modal-content {
        width: 95% !important;
        max-width: none !important;
        margin: 10px !important;
        border-radius: 8px !important;
    }
    
    .raffle-modal-header h3 {
        font-size: 18px !important;
        margin: 0 !important;
    }
    
    .grid-header {
        flex-direction: column !important;
        gap: 10px !important;
        align-items: stretch !important;
    }
    
    .grid-info {
        text-align: center !important;
    }
    
    .grid-actions {
        display: flex !important;
        justify-content: center !important;
        gap: 10px !important;
    }
    
    .quantity-display {
        flex-direction: column !important;
        gap: 10px !important;
        text-align: center !important;
    }
    
    .raffle-modal-footer {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .raffle-modal-footer .btn {
        width: 100% !important;
        padding: 12px !important;
    }
}

/* Móviles pequeños */
@media (max-width: 480px) {
    .raffle-modal-content {
        width: 98% !important;
        margin: 5px !important;
        max-height: 95vh !important;
    }
    
    .raffle-modal-header {
        padding: 15px !important;
    }
    
    .raffle-modal-body {
        padding: 15px !important;
    }
    
    .raffle-modal-footer {
        padding: 15px !important;
    }
    
    .quantity-info .text {
        font-size: 14px !important;
    }
    
    .total-price {
        font-size: 16px !important;
    }
    
    .selection-help {
        font-size: 14px !important;
    }
    
    /* Grid de números más grande en móvil */
    .numbers-grid {
        grid-template-columns: repeat(auto-fill, minmax(45px, 1fr)) !important;
        gap: 8px !important;
    }
    
    .ticket-number {
        height: 45px !important;
        font-size: 14px !important;
        min-width: 45px !important;
    }
    
    /* Botones más grandes para touch */
    .btn-sm {
        padding: 8px 12px !important;
        font-size: 14px !important;
    }
    
    .grid-legend {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 8px !important;
    }
    
    .legend-item {
        flex-basis: calc(50% - 4px) !important;
        justify-content: center !important;
    }
}

/* Muy pequeños - Teléfonos en vertical */
@media (max-width: 360px) {
    .raffle-modal-header h3 {
        font-size: 16px !important;
    }
    
    .numbers-grid {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)) !important;
        gap: 6px !important;
    }
    
    .ticket-number {
        height: 40px !important;
        font-size: 12px !important;
        min-width: 40px !important;
    }
    
    .quantity-info .text {
        font-size: 13px !important;
    }
}

/* Estilo para número encontrado en búsqueda */
.ticket-number.highlight-found {
    background: linear-gradient(45deg, #ff6b6b, #feca57) !important;
    color: white !important;
    animation: pulse-found 1s ease-in-out 2 !important;
    box-shadow: 0 0 15px rgba(255, 107, 107, 0.6) !important;
    transform: scale(1.1) !important;
    z-index: 10 !important;
    position: relative !important;
}

@keyframes pulse-found {
    0% { transform: scale(1.1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1.1); }
}
