/* Módulo: modales (pedido, factura, comentario producto)
   Parcial asociado: resources/views/catalogo/partials/modales.blade.php
   Responsabilidad:
   - .modal-metodo (método entrega, caja cerrada)
   - .modal-overlay / .modal-content (datos cliente, factura, comentario)
   - formularios, preview mapa embebido, .modal-comentario-*
   Z-index: .modal-metodo 9999; .modal-overlay 10000 (encima del carrito 9998)
   SweetAlert2: 11000 (encima de carrito y modales de pedido)
*/

/* Alertas SweetAlert2 siempre por encima del carrito y modales del catálogo */
.swal2-container {
    z-index: 11000 !important;
}
.modal-metodo {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.7);
    z-index: 9999;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: backdropFade 0.4s ease;
    overscroll-behavior: contain;
}

@keyframes backdropFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-metodo.hidden {
    display: none;
}

.modal-contenido {
    background: #fff;
    padding: 2.5rem;
    border-radius: 16px;
    text-align: center;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    animation: modalEnter 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes modalEnter {
    0% {
        opacity: 0;
        transform: scale(0.92) translateY(10px);
        filter: blur(4px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0);
    }
}

.modal-contenido h2 {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    white-space: nowrap;
}

@media (max-width: 380px) {
    .modal-contenido h2 { font-size: 0.85rem; }
}

.modal-contenido p {
    color: #666;
    margin-bottom: 25px;
}

.botones-entrega {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn-entrega {
    padding: 15px 30px;
    font-size: 1.1rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s ease;
    font-weight: 500;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    position: relative;
    overflow: hidden;
}

.btn-entrega i {
    transition: transform 0.3s ease;
}

.btn-entrega[data-metodo="delivery"],
.btn-entrega[data-metodo="retiro"] {
    background: var(--rojo);
    color: white;
}

.btn-entrega[data-metodo="delivery"]:hover,
.btn-entrega[data-metodo="retiro"]:hover {
    background: var(--rojo-oscuro);
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 10px 25px rgba(0,0,0,0.25);
}

.btn-entrega[data-metodo="delivery"]:hover i,
.btn-entrega[data-metodo="retiro"]:hover i {
    transform: scale(1.1);
}

/* Feedback moderno al seleccionar un botón */
.btn-entrega.selected {
    background: var(--rojo-oscuro);
    animation: btnEntregaPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1;
}

.btn-entrega.selected i {
    animation: btnEntregaIcon 0.45s ease;
}

/* Onda expansiva (ripple) al seleccionar */
.btn-entrega.selected::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 2px solid rgba(255, 255, 255, 0.85);
    opacity: 0;
    animation: btnEntregaRipple 0.6s ease-out forwards;
    pointer-events: none;
}

@keyframes btnEntregaPop {
    0%   { transform: scale(1); }
    40%  { transform: scale(0.95); }
    70%  { transform: scale(1.04); }
    100% { transform: scale(1); }
}

@keyframes btnEntregaIcon {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.35) rotate(-6deg); }
    100% { transform: scale(1); }
}

@keyframes btnEntregaRipple {
    0%   { opacity: 0.9; transform: scale(1); }
    100% { opacity: 0;   transform: scale(1.12); }
}

@media (prefers-reduced-motion: reduce) {
    .btn-entrega.selected,
    .btn-entrega.selected i,
    .btn-entrega.selected::after {
        animation: none;
    }
}
/* MODAL CLIENTE PEDIDO */
.btn-ubicacion {
    background: #f0f0f0;
    border: 1px solid #ddd;
    height: 38px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    width: 100%;
    transition: all 0.3s ease;
}

.btn-ubicacion:hover {
    background: #e0e0e0;
    border-color: #c62828;
}

.btn-confirmar-ubicacion:hover {
    filter: brightness(0.95);
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    padding: 10px;
    z-index: 10000;
    overscroll-behavior: contain;
}

.modal-content {
    background: #fff;
    border-radius: 16px;
    padding: 14px 14px 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    width: min(92vw, 400px);
    max-height: 96dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    animation: aparecer 0.3s ease;
    scrollbar-width: thin;
}

#modalCliente .modal-content--con-cerrar {
    position: relative;
}

#modalCliente .cerrar-modal--esquina {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 10;
    transform: none;
    font-size: 1.4rem;
    min-width: 46px;
    min-height: 46px;
    padding: 10px;
    color: #6b7280;
    border-radius: 50%;
}

#modalCliente .cerrar-modal--esquina:hover {
    color: var(--rojo);
    background: rgba(205, 2, 32, 0.07);
}

#modalCliente .cerrar-modal--esquina i {
    line-height: 1;
}

#previewMapaBox {
    display: none;
    margin-top: 8px;
}

#previewMapa {
    width: 100%;
    height: 105px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #ddd;
}

#previewDireccion {
    font-size: 11px;
    margin-top: 4px;
    color: #333;
    line-height: 1.2;
}

#btnCambiarUbicacion {
    margin-top: 5px;
    width: 100%;
    height: 34px;
    padding: 6px 8px;
    border: none;
    border-radius: 8px;
    background: #eee;
    cursor: pointer;
    font-size: 12px;
}

@keyframes aparecer {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 20px;
    margin-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.modal-header--con-cerrar {
    display: block;
    padding: 10px 48px 12px 16px;
    margin-bottom: 8px;
    border-bottom: 1px solid #eee;
    text-align: center;
}

.modal-header--con-cerrar h4 {
    margin: 0;
    padding: 0;
    text-align: center;
}

.modal-header h4 {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.15;
    font-weight: 600;
    text-align: center;
    letter-spacing: -0.2px;
    color: var(--rojo);
}

.cerrar-modal {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    background: transparent;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 8px;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    pointer-events: auto;
}

.cerrar-modal:hover {
    color: var(--rojo);
}

.form-group {
    margin-bottom: 10px;
}

.form-group label {
    font-weight: 600;
    color: #333;
    font-size: 13px;
    display: block;
    margin-bottom: 4px;
}

.form-group input,
.form-group select {
    width: 100%;
    height: 40px;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    font-family: 'Poppins', sans-serif;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--rojo);
    box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.1);
}

/* iOS Safari: mínimo ~16px en controles enfocables evita zoom forzado (modal cliente / pizza) */
.modal-overlay .form-group input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.modal-overlay .form-group select,
.modal-overlay textarea.comentario-textarea {
    font-size: 16px;
}

.btn-confirmar-final {
    position: sticky;
    bottom: 0;
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 10px;
    z-index: 2;
}

.btn-confirmar-final:hover {
    background: var(--rojo-oscuro);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.btn-confirmar-final:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.pf-factura-box {
    min-height: 38px;
    padding: 8px 10px;
}

.pf-helper {
    display: block;
    margin-top: 6px;
    margin-bottom: 16px;
    color: #6b7280;
    font-size: 12px;
    line-height: 1.3;
    text-align: center;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
}

.pf-helper-one-line {
    font-size: 11px;
    line-height: 1.25;
}

#estadoUbicacion {
    display: block;
    margin-top: 4px;
    color: #666;
    font-size: 12px;
    line-height: 1.2;
}

.pf-helper span {
    display: block;
}

#infoRetiro {
    display: none;
}

.pf-factura-box .pf-factura-label {
    margin: 0;
    font-weight: 700;
    color: #111;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    line-height: 1;
}

.pf-factura-box input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--rojo);
    cursor: pointer;
}
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        padding: 20px;
    }
}
@media (max-width: 480px) {
    .modal-overlay {
        align-items: center;
        padding: 8px;
    }

    .modal-content {
        width: 100%;
        max-width: 360px;
        padding: 12px 12px 10px;
        border-radius: 14px;
        max-height: 95dvh;
    }

    .modal-header--con-cerrar {
        padding: 8px 44px 10px 12px;
    }

    #modalCliente .cerrar-modal--esquina {
        top: 2px;
        right: 2px;
        font-size: 1.3rem;
        min-width: 44px;
        min-height: 44px;
        padding: 9px;
    }

    .modal-header--con-cerrar h4 {
        font-size: 0.92rem;
        line-height: 1.2;
    }

    .modal-header h4 {
        font-size: 0.98rem;
    }

    .form-group {
        margin-bottom: 8px;
    }

    .form-group label {
        font-size: 12px;
        margin-bottom: 3px;
    }

    .form-group input,
    .form-group select {
        height: 36px;
        font-size: 16px;
        padding: 7px 9px;
    }

    .btn-ubicacion {
        height: 36px;
        font-size: 13px;
        padding: 7px 9px;
    }

    #previewMapa {
        height: 92px;
    }

    #previewDireccion {
        font-size: 10.5px;
    }

    #btnCambiarUbicacion {
        height: 32px;
        font-size: 11.5px;
    }

    .pf-helper-one-line,
    #estadoUbicacion {
        font-size: 10.5px;
    }

    .btn-confirmar-final {
        min-height: 40px;
        padding: 9px 10px;
        font-size: 14px;
    }
}

@media (max-height: 740px) {
    .modal-content {
        padding: 10px 10px 8px;
        max-height: 96dvh;
    }

    .form-group {
        margin-bottom: 7px;
    }

    .form-group input,
    .form-group select {
        height: 34px;
        font-size: 16px;
    }

    .btn-ubicacion {
        height: 34px;
        font-size: 12px;
    }

    #previewMapa {
        height: 80px;
    }

    #btnCambiarUbicacion {
        height: 30px;
        font-size: 11px;
    }

    .pf-helper-one-line,
    #estadoUbicacion,
    #previewDireccion {
        font-size: 10px;
    }

    .btn-confirmar-final {
        min-height: 38px;
        font-size: 13px;
    }
}

/* Pantallas de poca altura útil (teclado / entry Samsung, Redmi, etc.) */
@media (max-height: 700px) {
    #modalMitadPizza .modal-content {
        max-height: 92dvh;
        overflow-y: auto;
    }
}

.modal-comentario-producto {
    width: min(92vw, 420px);
    max-width: 420px;
    border-radius: 18px;
}

.comentario-textarea {
    width: 100%;
    min-height: 90px;
    resize: none;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 13px;
    outline: none;
    font-family: 'Poppins', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.comentario-textarea:focus {
    border-color: var(--rojo);
    box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.1);
}

.modal-comentario-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 4px;
}

.btn-cancelar-modal-producto {
    min-height: 44px;
    border-radius: 12px;
    font-weight: 600;
}

.btn-confirmar-modal-producto {
    min-height: 44px;
    border-radius: 12px;
    margin-top: 0;
}

@media (max-width: 480px) {
    .modal-comentario-producto {
        width: 100%;
        max-width: 360px;
    }

    .modal-comentario-actions {
        grid-template-columns: 1fr;
    }
}
