/* Carrinho CSS - Sistema Profissional de Carrinho de Compras 
 * Carrinho CSS - Sistema Profissional de Carrinho de Compras
 * Versão: 1.0.0
 * Autor: Sistema de Cardápio Online
 */

/* ===== CARRINHO FLUTUANTE FIXO ===== */
.carrinho-flutuante-fixo {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100vw;
    background: #fff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1040;
    /* Menor que modais (1060) para não cobrir botões */
    padding: 0;
    display: none;
    animation: slideUp 0.3s ease-out;
}

.btn-carrinho-flutuante {
    width: 100vw;
    max-width: 100vw;
    border: none;
    border-radius: 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: var(--primary-contrast);
    font-size: 1.2em;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    box-shadow: none;
    transition: all 0.3s ease;
}

.btn-carrinho-flutuante:hover {
    background: var(--primary-hover);
    color: var(--primary-contrast);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3);
}

.carrinho-qtd {
    color: #f1faee;
    font-weight: normal;
    margin: 0 10px;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.9em;
}

.carrinho-total {
    color: var(--primary-contrast);
    font-weight: bold;
    font-size: 1.1em;
}

/* ===== ANIMAÇÕES ===== */
@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }

    50% {
        transform: scale(1.1);
        box-shadow: 0 -4px 20px rgba(230, 57, 70, 0.4);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }
}

.pulse-animation {
    animation: pulse 0.6s ease-in-out;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-10px);
    }

    60% {
        transform: translateY(-5px);
    }
}

.bounce-animation {
    animation: bounce 0.8s ease-in-out;
}

/* ===== ANIMAÇÃO DE ADIÇÃO DE PRODUTO ===== */
/* O card clonado mantém seus estilos originais mas com position: fixed */

@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }

    100% {
        opacity: 0;
        transform: scale(1);
    }
}

/* ===== MODAL DE PRODUTO ===== */
#modalProduto {
    z-index: 1060;
    /* Maior que carrinho flutuante (1040) */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

#modalProduto .modal-dialog {
    margin: 1rem auto;
    max-width: 800px;
    width: 100%;
}

#modalProduto .modal-content {
    border-radius: 1rem;
    border: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-height: 85vh;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
}

#modalProduto .modal-body {
    max-height: 65vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
    padding-bottom: 2rem;
    /* Espaço extra para não ser coberto pelo carrinho */
    width: 100%;
    box-sizing: border-box;
}

#modalProduto .modal-footer {
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 1px solid #dee2e6;
    padding: 1rem;
    z-index: 1061;
    /* Maior que o modal para ficar sempre visível */
}

#modalProduto .modal-header {
    background: var(--header-color);
    color: var(--header-contrast);
    border-radius: 1rem 1rem 0 0;
    border: none;
}

#modalProduto .modal-title {
    font-weight: bold;
}

.grupo-complemento {
    background: #f8f9fa;
    border-radius: 0.8rem;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid #e9ecef;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.grupo-header {
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
}

.grupo-info {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    background: var(--primary-color);
    color: var(--primary-contrast);
    border-radius: 0.5rem;
}

.grupo-complementos {
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* Centralizar alerts no modal de complementos */
#listaComplementos .alert {
    text-align: center;
    margin: 0 auto 1rem auto;
    max-width: 100%;
    border-radius: 1rem;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 1rem 1.5rem;
}

#listaComplementos .alert strong {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

#listaComplementos .alert small {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

#listaComplementos .alert i {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    display: block;
}

/* Melhorar visual dos alerts específicos */
#listaComplementos .alert-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

#listaComplementos .alert-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border-left: 4px solid #28a745;
}

#listaComplementos .alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
    border-left: 4px solid #ffc107;
}

.complemento-item {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.complemento-item:hover {
    border-color: #e63946;
    box-shadow: 0 2px 8px rgba(230, 57, 70, 0.1);
}

.complemento-nome {
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
}

.complemento-preco {
    font-size: 0.85rem;
    font-weight: bold;
}

.complemento-controle .input-group {
    box-shadow: none;
}

.complemento-controle .btn {
    border-color: #e63946;
    color: #e63946;
    transition: all 0.2s ease;
}

.complemento-controle .btn:hover {
    background: #e63946;
    color: #fff;
    border-color: #e63946;
}

.complemento-controle input {
    border-color: #e63946;
    text-align: center;
    font-weight: bold;
}

.grid-complemento {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 0.5rem 1rem;
}

.grid-complemento>.complemento-info {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
}

.grid-complemento>.complemento-controle {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
}

.grid-complemento>.linha-checkbox-embalagem {
    grid-column: 1 / 3;
    grid-row: 2 / 3;
    width: 100%;
}

/* ===== MODAL DO CARRINHO ===== */
#modalCarrinho .modal-content {
    border-radius: 1rem;
    border: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
}

#modalCarrinho .modal-body {
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
}

#modalCarrinho .modal-header {
    background: var(--header-color);
    color: var(--header-contrast);
    border-radius: 1rem 1rem 0 0;
    border: none;
}

.item-carrinho {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 0.8rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}

.item-carrinho:hover {
    border-color: #e63946;
    box-shadow: 0 2px 8px rgba(230, 57, 70, 0.1);
}

.item-imagem img {
    border-radius: 0.5rem;
    object-fit: cover;
}

.item-nome {
    font-size: 1rem;
    margin-bottom: 0.3rem;
}

.item-complementos {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 0.3rem;
}

.item-preco {
    font-size: 1.1rem;
    font-weight: bold;
}

.item-controles .input-group {
    box-shadow: none;
}

.item-controles .btn {
    border-color: #e63946;
    color: #e63946;
    transition: all 0.2s ease;
}

.item-controles .btn:hover {
    background: var(--primary-color);
    color: var(--primary-contrast);
    border-color: var(--primary-color);
}

.item-controles input {
    border-color: #e63946;
    text-align: center;
    font-weight: bold;
}

/* ===== FORMAS DE PAGAMENTO ===== */
.forma-pagamento {
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 0.8rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.forma-pagamento:hover {
    border-color: #e63946;
    background: #fff5f5;
}

.forma-pagamento input[type="radio"]:checked+.forma-info {
    background: #fff5f5;
}

.forma-pagamento input[type="radio"]:checked~.forma-icone {
    color: #e63946;
}

.forma-nome {
    font-size: 1rem;
    margin-bottom: 0.2rem;
}

.forma-descricao {
    font-size: 0.8rem;
    color: #6c757d;
}

.forma-icone {
    color: #6c757d;
    transition: color 0.2s ease;
}

/* ===== RESUMO DO PEDIDO ===== */
.resumo-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid #f1f3f4;
}

.resumo-item:last-child {
    border-bottom: none;
    font-weight: bold;
    font-size: 1.1rem;
}

/* ===== CUPOM DE DESCONTO ===== */
#cupomMensagem {
    font-size: 0.9rem;
    font-weight: bold;
}

#cupomMensagem .text-success {
    color: #28a745 !important;
}

#cupomMensagem .text-danger {
    color: #dc3545 !important;
}

/* ===== NOTIFICAÇÕES ===== */
.alert {
    border: none;
    border-radius: 0.8rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.alert-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: #fff;
}

.alert-danger {
    background: linear-gradient(135deg, #dc3545 0%, #e63946 100%);
    color: #fff;
}

.alert-warning {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
    color: #fff;
}

.alert-info {
    background: linear-gradient(135deg, #17a2b8 0%, #6f42c1 100%);
    color: #fff;
}

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 768px) {
    .btn-carrinho-flutuante {
        font-size: 1em;
        padding: 15px 20px;
    }

    .carrinho-qtd {
        font-size: 0.8em;
        padding: 3px 6px;
    }

    .carrinho-total {
        font-size: 1em;
    }

    #modalProduto .modal-dialog,
    #modalCarrinho .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
        width: calc(100vw - 1rem);
        margin-top: env(safe-area-inset-top, 0.5rem);
        margin-bottom: env(safe-area-inset-bottom, 0.5rem);
    }

    #modalCarrinho .modal-content {
        max-height: 85vh;
        overflow-y: auto;
        overflow-x: hidden;
    }

    #modalCarrinho .modal-body {
        max-height: 60vh;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 1rem;
        padding-bottom: 3rem;
        /* Mais espaço no mobile */
    }

    #modalProduto .modal-content {
        max-height: 90vh;
        margin: 0;
        width: 100%;
    }

    #modalProduto .modal-body {
        max-height: 70vh;
        padding: 1rem;
        padding-bottom: 3rem;
        /* Mais espaço no mobile */
        overflow-x: hidden;
    }

    #modalProduto .modal-footer {
        padding: 0.75rem 1rem;
    }

    .complemento-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .complemento-controle {
        width: 100%;
    }

    .grid-complemento {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .grid-complemento>.linha-checkbox-embalagem {
        width: 100%;
    }

    .label-separar-embalagem {
        font-size: 2.3vh !important;
    }

    .item-carrinho {
        flex-direction: row;
        align-items: flex-start;
        gap: 1rem;
    }

    .item-controles {
        position: absolute;
        top: 85%;
        width: 100%;
        right: 0%;
    }

    .forma-pagamento {
        padding: 0.75rem;
    }

    .forma-icone {
        font-size: 1.2rem;
    }
}

@media (min-width: 769px) {
    .carrinho-flutuante-fixo {
        max-width: 100vw;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 1rem 1rem 0 0;
    }

    .btn-carrinho-flutuante {
        border-radius: 1rem 1rem 0 0;
    }
}

/* ===== ESTADOS DE LOADING ===== */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #e63946;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ===== MELHORIAS VISUAIS ===== */
.modal-backdrop {
    backdrop-filter: blur(5px);
}

.modal-content {
    backdrop-filter: blur(10px);
}

.btn {
    border-radius: 0.5rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.form-control {
    border-radius: 0.5rem;
    border: 1px solid #dee2e6;
    transition: all 0.2s ease;
}

.form-control:focus {
    border-color: #e63946;
    box-shadow: 0 0 0 0.2rem rgba(230, 57, 70, 0.25);
}

.card {
    border-radius: 0.8rem;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

/* ===== ANIMAÇÕES DE ENTRADA ===== */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== ESTILOS PARA CARRINHO VAZIO ===== */
#carrinhoVazio {
    padding: 3rem 1rem;
}

#carrinhoVazio i {
    color: #6c757d;
    margin-bottom: 1rem;
}

#carrinhoVazio h5 {
    color: #495057;
    margin-bottom: 0.5rem;
}

#carrinhoVazio p {
    color: #6c757d;
    font-size: 0.9rem;
}

/* Melhorias para o modal de complementos no mobile */
@media (max-width: 600px) {
    #modalProduto .modal-dialog {
        margin: 0.25rem;
        max-width: calc(100vw - 0.5rem);
        width: calc(100vw - 0.5rem);
    }

    #modalProduto .modal-content {
        padding: 0;
        margin: 0;
        width: 100%;
        border-radius: 0.8rem;
    }

    #modalProduto .modal-body {
        padding: 0.75rem;
        overflow-x: hidden;
        max-height: 100vh;
    }

    .grupo-complemento,
    .complemento-item {
        margin-bottom: 10px !important;
        border-radius: 10px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    }

    .grid-complemento {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .grid-complemento>.linha-checkbox-embalagem {
        width: 100%;
    }

    .label-separar-embalagem {
        font-size: 2.3vh !important;
    }

    .complemento-item {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 10px 8px !important;
        margin: 0 2px;
    }

    .complemento-info {
        margin-bottom: 6px;
        text-align: center;
    }

    .complemento-controle {
        width: 100%;
        display: flex;
        justify-content: center;
    }

    .input-group {
        width: 100% !important;
        max-width: 180px;
        margin: 0 auto;
    }

    .input-group .btn {
        min-width: 38px;
        font-size: 1.2rem;
        padding: 6px 0;
    }

    .input-group input[type="number"] {
        font-size: 1.1rem;
        height: 38px;
        padding: 0 6px;
    }

    #modalProduto .modal-header,
    #modalProduto .modal-footer {
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* Ajustes específicos para telas muito pequenas (iPhone SE, etc.) */
@media (max-width: 375px) {
    #modalProduto .modal-dialog {
        margin: 0.15rem;
        max-width: calc(100vw - 0.3rem);
        width: calc(100vw - 0.3rem);
        margin-top: env(safe-area-inset-top, 0.15rem);
        margin-bottom: env(safe-area-inset-bottom, 0.15rem);
    }

    #modalProduto .modal-content {
        max-height: 85vh;
    }

    #modalProduto .modal-body {
        max-height: 60vh;
        padding: 0.5rem;
    }

    #modalProduto .modal-header,
    #modalProduto .modal-footer {
        padding: 0.5rem 8px;
    }

    .grupo-complemento {
        padding: 0.75rem;
        margin-bottom: 8px;
    }

    .label-separar-embalagem {
        font-size: 2.3vh !important;
    }

    .complemento-item {
        padding: 8px 6px !important;
    }
}

/* Ajustes gerais para desktop também */
#modalProduto {
    overflow-x: hidden;
    /* Garantir que o modal não seja cortado pelos controles do celular */
    padding-top: max(env(safe-area-inset-top), 0.5rem);
    padding-bottom: max(env(safe-area-inset-bottom), 0.5rem);
}

#modalProduto .modal-dialog {
    overflow-x: hidden;
    /* Ajustar margens para dispositivos com notch */
    margin-top: max(env(safe-area-inset-top), 0.5rem);
    margin-bottom: max(env(safe-area-inset-bottom), 0.5rem);
}

.complemento-item .input-group .btn {
    min-width: 32px;
    font-size: 1.1rem;
}

.complemento-item .input-group input[type="number"] {
    text-align: center;
    font-weight: bold;
}

.complemento-nome {
    font-size: 1.08rem;
}

.complemento-preco {
    font-size: 0.98rem;
    font-weight: 500;
}

/* Botão Remover do Carrinho - Destaque Exclusivo */
.btn-remover-carrinho {
    background: linear-gradient(135deg, #e63946 0%, #dc3545 100%);
    color: #fff !important;
    border: none;
    opacity: 1;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.08);
    transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
}

.btn-remover-carrinho:hover,
.btn-remover-carrinho:focus {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: #fff !important;
    opacity: 1;
    box-shadow: 0 4px 16px rgba(220, 53, 69, 0.18);
    transform: translateY(-2px) scale(1.04);
}

.btn-remover-carrinho:active {
    background: #b71c1c;
    color: #fff !important;
    opacity: 1;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.12);
    transform: scale(0.98);
}

.btn-remover-carrinho:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== CORREÇÃO DE ROLAGEM DO MODAL CARRINHO ===== */
/* Garantir que o modal do carrinho tenha rolagem vertical adequada */
#modalCarrinho .modal-content {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    max-height: 90vh !important;
}

#modalCarrinho .modal-body {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    max-height: 70vh !important;
    padding: 1.5rem !important;
}

/* Para dispositivos móveis */
@media (max-width: 768px) {
    #modalCarrinho .modal-content {
        max-height: 85vh !important;
        overflow-y: auto !important;
    }

    #modalCarrinho .modal-body {
        max-height: 60vh !important;
        overflow-y: auto !important;
        padding: 1rem !important;
        padding-bottom: 3rem !important;
    }
}