﻿/* 
|============================================================================
| MODAL PEDIDO - CSS OTIMIZADO COM RESPONSIVIDADE MELHORADA
|============================================================================
*/

/* 
|----------------------------------------------------------------------------
| 1. Reset e Controle Global do Modal
|----------------------------------------------------------------------------
*/
.modal, .modal-open {
    padding-right: 0 !important;
    overflow: hidden;
}

.modal {
    padding-top: 2rem;
    overflow-y: auto;
    backdrop-filter: blur(4px);
    background-color: rgba(0, 0, 0, 0.5);
}

    .modal.fade .modal-dialog {
        transform: none !important;
        transition: none !important;
    }

/* 
|----------------------------------------------------------------------------
| 2. Skeleton Loader Melhorado
|----------------------------------------------------------------------------
*/
.skeleton-loader {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    animation: fadeIn 0.3s ease-in-out;
    position: relative;
    z-index: 10;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 12px;
}

.skeleton {
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.8s infinite ease-in-out;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.skeleton-img {
    width: 100%;
    height: 200px;
    border-radius: 12px;
}

.skeleton-title {
    width: 75%;
    height: 28px;
    margin-bottom: 0.5rem;
}

.skeleton-text {
    width: 100%;
    height: 18px;
    margin-bottom: 0.25rem;
}

    .skeleton-text.small {
        width: 65%;
    }

.skeleton-price {
    width: 45%;
    height: 32px;
    margin-top: 0.75rem;
}

.skeleton-quantidade {
    width: 130px;
    height: 44px;
    margin-top: 0.75rem;
}

.skeleton-list {
    width: 100%;
    height: 88px;
    border-radius: 10px;
    margin-bottom: 0.5rem;
}

.skeleton-button {
    width: 100%;
    height: 52px;
    margin-top: 1.5rem;
    border-radius: 26px;
}

/* 
|----------------------------------------------------------------------------
| 3. Animações
|----------------------------------------------------------------------------
*/
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }

    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }

    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* 
|----------------------------------------------------------------------------
| 4. Estrutura do Modal
|----------------------------------------------------------------------------
*/
.modal-dialog {
    max-width: 650px;
    display: flex;
    height: fit-content;
    align-items: flex-start;
    margin: 1rem auto;
    overflow: hidden;
    animation: slideIn 0.4s ease-out;
}

.modal-content {
    display: flex;
    max-height: calc(100vh - 10rem);
    height: fit-content;
    overflow: auto;
    position: relative;
    user-select: none;
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.compact-modal {
    max-height: calc(100vh - 10rem);
    height: fit-content;
}

.modal-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: linear-gradient(135deg, #f7654b 0%, #e74c3c 100%);
    color: white;
    border-bottom: none;
    padding: 1rem 1.25rem;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 2px 10px rgba(247, 101, 75, 0.3);
    flex-shrink: 0;
}

    .modal-header h5 {
        margin: 0;
        font-weight: 600;
        font-size: 1.25rem;
    }

/* 
|----------------------------------------------------------------------------
| 5. MODAL BODY - RESPONSIVIDADE MELHORADA
|----------------------------------------------------------------------------
*/
.modal-body {
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    gap: 1.5rem;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    min-height: 0;
}

/* Container principal do produto */
.produto-container {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

/* Área da imagem */
.produto-imagem {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .produto-imagem img {
        width: 280px;
        height: 280px;
        border-radius: 16px;
        object-fit: contain;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
        transition: transform 0.3s ease;
    }

/* Container das informações do produto */
.produto-info-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0; /* Permite que o conteúdo quebre corretamente */
}

/* Informações básicas do produto */
.produto-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

    .produto-info h4 {
        margin: 0;
        font-size: 1.75rem;
        font-weight: 700;
        color: #2c3e50;
        line-height: 1.3;
        word-wrap: break-word;
    }

    .produto-info p {
        margin: 0;
        font-size: 1.05rem;
        color: #64748b;
        line-height: 1.5;
    }

/* Área de preço e quantidade */
.produto-preco-quantidade {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.produto-preco {
    font-size: 1.75rem;
    font-weight: 800;
    color: #27ae60;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(39, 174, 96, 0.2);
}

/* Estilo base da descrição – até 4 linhas */
#mercadoriaInfo {
    display: -webkit-box;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    line-height: 1.4;
    max-height: 5.6em;
}

.modal-footer {
    position: sticky;
    bottom: 0;
    z-index: 20;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    padding 0.6rem !important;
}

.container-footer {
    justify-content: space-between;
}

/* Botão de fechar moderno */
.btn-fechar-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 30;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

    .btn-fechar-modal:hover {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(1.1);
    }

/* 
|----------------------------------------------------------------------------
| 6. Containers e Seletores
|----------------------------------------------------------------------------
*/
.box-container {
    background: white;
    border-radius: 12px;
    padding: 0.5rem;
    margin-bottom: 0.1rem !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

    .box-container label {
        font-weight: 700;
        font-size: 1.15rem;
        color: #2c3e50;
        margin-bottom: 0.75rem;
        display: block;
    }

.adicional-item, .sabor-item, .observacao-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    margin: 0.5rem 0;
    gap: 0.75rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

    .adicional-item:hover, .sabor-item:hover, .observacao-item:hover {
        border-color: #f7654b;
        background: linear-gradient(135deg, #fff8f6 0%, #ffffff 100%);
    }

.adicional-info, .sabor-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

/* OBSERVAÇÕES - LAYOUT CORRIGIDO */
.observacao-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    padding-right: 0.5rem;
}

.adicional-nome, .sabor-nome, .observacao-nome {
    font-weight: 600;
    color: #2c3e50;
    font-size: 1rem;
    line-height: 1.4;
}

.preco-adicional, .preco-sabor {
    font-size: 0.9rem;
    color: #64748b;
    font-weight: 500;
}

.preco-proporcional {
    color: #f7654b;
    font-weight: 600;
}

/* 
|----------------------------------------------------------------------------
| 7. Controles de Quantidade
|----------------------------------------------------------------------------
*/
.quantidade-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    min-width: 110px;
    flex-shrink: 0;
}

.quantidade-valor, .produto-quantidade-valor {
    font-size: 1.1rem;
    font-weight: 700;
    width: 35px;
    text-align: center;
    color: #2c3e50;
}

.btn-menos, .btn-mais, .produto-btn-menos, .produto-btn-mais {
    background: linear-gradient(135deg, #f7654b 0%, #e74c3c 100%);
    color: white;
    border: none;
    padding: 0.375rem;
    border-radius: 6px;
    font-size: 0.875rem;
    width: 32px;
    height: 32px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

    .btn-menos:hover, .btn-mais:hover, .produto-btn-menos:hover, .produto-btn-mais:hover {
        transform: scale(1.05);
    }

    .btn-menos:disabled, .produto-btn-menos:disabled {
        background: #cbd5e1;
        cursor: not-allowed;
        transform: none;
    }

.quantidade-preco, .produto-quantidade-preco, .quantidade {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-left: auto;
    flex-shrink: 0;
    flex-wrap: nowrap;
}

.produto-quantidade {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-outline-secondary {
    padding: 0.75rem 1rem !important;
    margin: 0.5rem !important;
}
/* 
|----------------------------------------------------------------------------
| 8. Grupos e Validação
|----------------------------------------------------------------------------
*/
.grupo-adicional, .grupo-sabor {
    margin-bottom: 0.5rem;
}

    .grupo-adicional h5 {
        font-weight: 700;
        color: #2c3e50;
        margin-bottom: 0.75rem;
    }

.grupo-header {
    padding: 0.75rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
}

    .grupo-header:hover {
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    }

    .grupo-header h6 {
        font-weight: 600;
        margin: 0;
        color: #2c3e50;
    }

.btn-toggle-group {
    transition: all 0.3s ease;
    color: #64748b;
    font-size: 1.25rem;
}

    .btn-toggle-group:hover {
        color: #f7654b;
    }

.grupo-invalido {
    border: 2px solid #e74c3c;
    background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%);
    border-radius: 8px;
    padding: 0.5rem;
    animation: shake 0.5s ease-in-out;
}

/* 
|----------------------------------------------------------------------------
| 9. Botões Principais
|----------------------------------------------------------------------------
*/
.btn-adicionar {
    background: linear-gradient(135deg, #f7654b 0%, #e74c3c 100%);
    color: white;
    font-size: 1.15rem;
    font-weight: 600;
    padding: 0.875rem 1.5rem;
    border-radius: 12px;
    width: 100%;
    text-align: center;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

    .btn-adicionar:hover {
        background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    }

/* 
|----------------------------------------------------------------------------
| 10. Campos Especiais
|----------------------------------------------------------------------------
*/
.produto-quantidade.fracionado {
    min-width: 160px;
    position: relative;
}

.produto-quantidade-input {
    width: 80px;
    text-align: center;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0.5rem;
    transition: all 0.3s ease;
    background: white;
}

    .produto-quantidade-input:focus {
        border-color: #f7654b;
        outline: none;
        box-shadow: 0 0 0 3px rgba(247, 101, 75, 0.2);
    }

.produto-quantidade.fracionado::after {
    content: 'kg';
    font-size: 0.9rem;
    font-weight: 600;
    color: #64748b;
    margin-left: 0.25rem;
}

/* 
|----------------------------------------------------------------------------
| 11. OBSERVAÇÕES COM CHECKBOX
|----------------------------------------------------------------------------
*/
.observacao-item {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 0.875rem;
    gap: 0.75rem;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    flex-direction: row;
    text-align: left;
}

    .observacao-item[data-observacao-check="true"] {
        background: linear-gradient(135deg, #f0fff4 0%, #ffffff 100%);
        border-color: #27ae60;
    }

        .observacao-item[data-observacao-check="true"] .observacao-nome {
            color: #27ae60;
            font-weight: 700;
        }

    .observacao-item .form-check {
        margin: 0;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        min-width: 24px;
        height: 24px;
        margin-top: 0.125rem;
    }

    .observacao-item .form-check-input {
        width: 20px;
        height: 20px;
        margin: 0;
        cursor: pointer;
        accent-color: #27ae60;
        flex-shrink: 0;
    }

/* 
|----------------------------------------------------------------------------
| 12. RESPONSIVIDADE MELHORADA
|----------------------------------------------------------------------------
*/

/* Tablets - 768px até 1024px */
@media (max-width: 1024px) {
    .modal-dialog {
        max-width: 600px;
        margin: 0.75rem auto;
    }

    .produto-imagem img {
        width: 240px;
        height: 240px;
    }

    .produto-info h4 {
        font-size: 1.5rem;
    }

    .produto-preco {
        font-size: 1.5rem;
    }
}

/* Tablets pequenos - 640px até 768px */
@media (max-width: 768px) {
    .modal {
        padding: 0.5rem !important;
    }

    .modal-dialog {
        margin: 0.5rem auto;
        max-width: 95%;
    }

    .modal-content {
        border-radius: 12px;
        max-height: calc(100vh - 8rem);
    }

    @supports (-webkit-appearance: none) and (not (-ms-ime-align: auto)) {
        .modal-content {
            max-height: calc(100vh - 6rem);
        }
    }
    .modal-body {
        padding: 1rem;
        gap: 1rem;
    }

    /* Manter layout lado a lado em tablets */
    .produto-container {
        flex-direction: row;
        gap: 1rem;
    }

    .produto-imagem img {
        width: 200px;
        height: 200px;
    }

    .produto-info h4 {
        font-size: 1.4rem;
    }

    .produto-preco {
        font-size: 1.4rem;
    }
}

/* Mobile - 480px até 640px */
@media (max-width: 640px) {
    .modal-dialog {
        max-width: 100%;
        margin: 0.25rem auto;
    }

    .modal-body {
        padding: 0.75rem;
    }

    /* Mudar para layout vertical em mobile */
    .produto-container {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }

    .produto-imagem {
        order: 1;
        width: 100%;
        justify-content: center;
    }

        .produto-imagem img {
            width: 220px;
            height: 220px;
        }

    .produto-info-container {
        order: 2;
        width: 100%;
    }

    .produto-info h4 {
        font-size: 1.3rem;
        text-align: center;
    }

    .produto-preco-quantidade {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .produto-preco {
        font-size: 1.4rem;
    }

    .box-container {
        padding: 0.5rem 0.2rem;
    }

    .adicional-item, .sabor-item, .observacao-item {
        padding: 0.75rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .quantidade-preco, .produto-quantidade-preco, .quantidade {
        margin-left: 0;
        margin-top: 0.5rem;
        justify-content: flex-end;
    }
}

/* Mobile pequeno - 360px até 480px */
@media (max-width: 480px) {
    .modal {
        padding: 0.25rem !important;
    }

    .modal-content {
        border-radius: 8px;
        max-height: calc(100vh - 8rem);
    }

    @supports (-webkit-appearance: none) and (not (-ms-ime-align: auto)) {
        .modal-content {
            max-height: calc(100vh - 6rem);
        }
    }

    .modal-header {
        padding: 0.75rem 1rem;
        border-radius: 8px 8px 0 0;
    }

    .modal-body {
        padding: 0.5rem;
    }

    .produto-imagem img {
        width: 180px;
        height: 180px;
    }

    .produto-info h4 {
        font-size: 1.2rem;
    }

    .produto-preco {
        font-size: 1.3rem;
    }

    .btn-adicionar {
        font-size: 1rem;
        padding: 0.75rem 1rem;
    }

    .observacao-item {
        padding: 0.625rem;
        gap: 0.5rem;
    }

    .observacao-nome {
        font-size: 0.9rem;
        line-height: 1.3;
    }

    .observacao-item .form-check-input {
        width: 16px;
        height: 16px;
    }
}

/* Mobile muito pequeno - até 360px */
@media (max-width: 360px) {
    .modal {
        padding: 0.125rem !important;
    }

    .produto-imagem img {
        width: 160px;
        height: 160px;
    }

    .modal-header {
        padding: 0.5rem 0.75rem;
    }

    .produto-info h4 {
        font-size: 1.1rem;
    }

    .produto-preco {
        font-size: 1.2rem;
    }

    .observacao-item {
        padding: 0.5rem;
    }

    .observacao-nome {
        font-size: 0.85rem;
    }

    .observacao-item .form-check-input {
        width: 14px;
        height: 14px;
    }
}

/* 
|----------------------------------------------------------------------------
| 13. Melhorias de Acessibilidade e Scroll
|----------------------------------------------------------------------------
*/
.modal-content:focus {
    outline: 2px solid #f7654b;
    outline-offset: 2px;
}

.btn-menos:focus, .btn-mais:focus,
.produto-btn-menos:focus, .produto-btn-mais:focus,
.btn-adicionar:focus {
    outline: 2px solid #f7654b;
    outline-offset: 2px;
}

/* Esconder elementos vazios */
#saboresContainer:empty,
#adicionaisContainer:empty {
    display: none !important;
}

/* Scroll personalizado */
.modal-body {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

    .modal-body::-webkit-scrollbar {
        width: 6px;
    }

    .modal-body::-webkit-scrollbar-track {
        background: #f1f5f9;
        border-radius: 3px;
    }

    .modal-body::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 3px;
    }

        .modal-body::-webkit-scrollbar-thumb:hover {
            background: #94a3b8;
        }



/* Classes de utilidade */
.skeleton-hidden {
    display: none !important;
}

.content-hidden {
    display: none !important;
}

.content-visible {
    display: block !important;
}

.skeleton-visible {
    display: flex !important;
}
