/* Shared styles for RomaneioEntrega and Devolucao modules */

/* â”€â”€â”€ Layout grid with optional drawer â”€â”€â”€ */
.operacao-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    height: 100%;
    position: relative;
}

@media (min-width: 1200px) {
    .operacao-layout.drawer-open {
        grid-template-columns: 1fr 480px;
    }
}

/* â”€â”€â”€ Left column â”€â”€â”€ */
.operacao-lista {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow: hidden;
    height: 100%;
}

.operacao-grid-scroll {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    overflow-y: auto;
    max-height: 600px;
    padding-right: 0.5rem;
}

    .operacao-grid-scroll::-webkit-scrollbar {
        width: 7px;
    }

    .operacao-grid-scroll::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }

    .operacao-grid-scroll::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 4px;
    }

/* â”€â”€â”€ Cards â”€â”€â”€ */
.operacao-card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.55rem 0.75rem;
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

    .operacao-card:hover {
        background: #e8f4f8;
        border-color: #3498db;
    }

    .operacao-card.selecionado {
        background: #e3f2fd;
        border-color: #2196F3;
        box-shadow: 0 2px 8px rgba(33,150,243,0.3);
    }

.operacao-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.operacao-card-body {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #555;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

    .info-row i {
        color: #3498db;
        font-size: 0.78rem;
    }

/* â”€â”€â”€ Drawer â”€â”€â”€ */
.operacao-drawer {
    position: fixed;
    top: 0;
    right: -520px;
    width: 480px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0,0,0,0.2);
    transition: right 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

    .operacao-drawer.aberto {
        right: 0;
    }

@media (min-width: 1200px) {
    .operacao-drawer {
        position: static;
        right: auto;
        width: 100%;
        height: 100%;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        border-radius: 8px;
        transition: none;
        z-index: auto;
    }

        .operacao-drawer.aberto {
            right: auto;
        }
}

.drawer-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

@media (max-width: 1199px) {
    .drawer-overlay {
        display: block;
    }
}

/* â”€â”€â”€ Cliente sections inside drawer â”€â”€â”€ */
.cliente-section {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
}

.cliente-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid #e0e0e0;
    font-size: 0.9rem;
}

.operacao-item-card {
    padding: 0.35rem 0.5rem;
    background: white;
    border: 1px solid #e8e8e8;
    border-radius: 4px;
    margin-bottom: 0.2rem;
    font-size: 0.82rem;
}

.item-nome {
    font-weight: 600;
    color: #2c3e50;
}

.item-info {
    display: flex;
    gap: 0.75rem;
    color: #666;
    font-size: 0.78rem;
    margin-top: 0.15rem;
}

.loading-mini {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    color: #666;
    font-size: 0.9rem;
}

/* â”€â”€â”€ Status badges â”€â”€â”€ */
.badge-programado {
    background: #17a2b8;
    color: white;
}

.badge-fechado {
    background: #fd7e14;
    color: white;
}

.badge-faturado {
    background: #007bff;
    color: white;
}

.badge-emtransito {
    background: #6f42c1;
    color: white;
}

.badge-finalizado {
    background: #28a745;
    color: white;
}

.badge-pendente {
    background: #ffc107;
    color: #333;
}

.badge-cancelado {
    background: #dc3545;
    color: white;
}

/* â”€â”€â”€ Totalizadores â”€â”€â”€ */
.totalizadores {
    display: flex;
    gap: 2rem;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-top: auto;
    flex-shrink: 0;
}

.totalizador {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

    .totalizador .label {
        font-size: 0.82rem;
        color: #666;
    }

    .totalizador .valor {
        font-size: 1.3rem;
        font-weight: bold;
        color: #455A64;
    }

/* â”€â”€â”€ Filtros â”€â”€â”€ */
.filtros-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (max-width: 576px) {
    .filtros-grid {
        grid-template-columns: 1fr;
    }
}

/* Filtros em coluna (um abaixo do outro) */
.filtros-coluna {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

/* Linha de dois campos lado a lado dentro da coluna */
.filtros-linha {
    display: flex;
    gap: 1rem;
}

    .filtros-linha .form-group {
        flex: 1;
        margin-bottom: 0;
    }

@media (max-width: 576px) {
    .filtros-linha {
        flex-direction: column;
    }
}

/* â”€â”€â”€ Grade de itens: versÃ£o mobile (cards) â”€â”€â”€ */
.itens-mobile {
    display: none;
}

.item-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.item-card-info {
    flex: 1;
    min-width: 0;
}

.item-card-nome {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #212529;
}

.item-card-detalhe {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 0.15rem;
}

.item-card-total {
    font-weight: bold;
    color: #1a6e2e;
    font-size: 1rem;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .itens-desktop {
        display: none !important;
    }

    .itens-mobile {
        display: block;
    }
}

.filtros-checkbox {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 8px;
}

/* â”€â”€â”€ Cadastro page â”€â”€â”€ */
.cadastro-secao {
    background: white;
    padding: 1.25rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.secao-titulo {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e0e0e0;
}

    .secao-titulo h3 {
        margin: 0;
        font-size: 1.05rem;
        color: #455A64;
    }

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 768px) {
    .form-row-2 {
        grid-template-columns: 1fr;
    }
}

/* â”€â”€â”€ Items table â”€â”€â”€ */
.itens-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

    .itens-table th {
        background: #f8f9fa;
        padding: 0.45rem 0.75rem;
        text-align: left;
        border-bottom: 2px solid #dee2e6;
        font-weight: 600;
        color: #495057;
        white-space: nowrap;
    }

    .itens-table td {
        padding: 0.35rem 0.75rem;
        border-bottom: 1px solid #dee2e6;
        vertical-align: middle;
    }

    .itens-table tr:hover td {
        background: #f8f9fa;
    }

    .itens-table input[type="number"] {
        width: 100px;
        padding: 0.2rem 0.4rem;
        font-size: 0.85rem;
    }

.btn-remove-item {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

    .btn-remove-item:hover {
        background: rgba(220,53,69,0.1);
    }

/* â”€â”€â”€ Typeahead search â”€â”€â”€ */
.search-select-container {
    position: relative;
}

.dropdown-list-search {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 2000;
    max-height: 220px;
    overflow-y: auto;
}

.dropdown-list-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    font-size: 0.88rem;
    color: #212529;
}

    .dropdown-list-item:hover {
        background: #f8f9fa;
    }

.selected-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.3rem;
    padding: 0.3rem 0.6rem;
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 6px;
    font-size: 0.85rem;
}

.btn-clear-tag {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0;
    font-size: 0.75rem;
    line-height: 1;
}

    .btn-clear-tag:hover {
        color: #dc3545;
    }

/* â”€â”€â”€ VendaItems result list â”€â”€â”€ */
.vendaitens-lista {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.vendaitem-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
}

    .vendaitem-row:last-child {
        border-bottom: none;
    }

    .vendaitem-row:hover {
        background: #f8f9fa;
    }

    .vendaitem-row.selecionado {
        background: #e3f2fd;
    }

.vendaitem-nome {
    flex: 1;
    font-weight: 500;
    color: #2c3e50;
}

.vendaitem-qtd {
    color: #555;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* â”€â”€â”€ Devolucao items section â”€â”€â”€ */
.lancamento-form {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 0.75rem;
}

.valor-total-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2c3e50;
}

/* --- Analise de Venda - Cards Mobile --- */
.analise-cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.analise-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 0.875rem 1rem;
    cursor: pointer;
    transition: box-shadow 0.2s, border-color 0.2s;
}

    .analise-card:active {
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
        border-color: #4D6470;
    }

.analise-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.analise-card-produto {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.95rem;
    flex: 1;
    margin-right: 0.5rem;
}

.analise-card-edit-icon {
    color: #4D6470;
    font-size: 0.85rem;
    margin-top: 2px;
}

.analise-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.analise-card-row {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr;
    gap: 0.25rem 0.5rem;
    font-size: 0.85rem;
    align-items: baseline;
}

.analise-card-label {
    color: #6c757d;
    white-space: nowrap;
}

/* --- Modal edição item (mobile) --- */
.modal-item-edicao {
    max-width: 520px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
}

.item-edicao-produto {
    font-weight: 600;
    color: #2c3e50;
    font-size: 1rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #dee2e6;
}

.item-edicao-readonly {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 1rem;
}

.item-edicao-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    font-size: 0.85rem;
    color: #555;
}

.item-edicao-totais .form-group input {
    font-weight: bold;
}

/* --- Cards de Venda (modal seleção - mobile) --- */
.venda-cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.venda-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 0.875rem 1rem;
    cursor: pointer;
    transition: box-shadow 0.2s, border-color 0.2s;
}

    .venda-card:active {
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
        border-color: #3498db;
    }

.venda-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.venda-card-id {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 1rem;
}

.venda-card-empresa {
    font-size: 0.8rem;
    color: #6c757d;
    background: #f0f0f0;
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
}

.venda-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.6rem;
}

.venda-card-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    color: #444;
}

.venda-card-icon {
    color: #6c757d;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}

.venda-card-total {
    margin-left: auto;
    font-weight: 700;
    color: #2c6fad;
}

.venda-card-footer {
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid #f0f0f0;
    padding-top: 0.5rem;
}

/* --- Utilitários responsivos --- */
.d-none {
    display: none !important;
}

/* --- Variantes de tamanho do modal --- */
.modal-xl {
    max-width: 1140px;
}

.modal-lg {
    max-width: 800px;
}

@media (min-width: 768px) {
    .d-md-block {
        display: block !important;
    }

    .d-md-none {
        display: none !important;
    }
}

@media (max-width: 767px) {
    .d-md-none {
        display: block !important;
    }

    .d-md-block {
        display: none !important;
    }

    .analise-card:hover {
        box-shadow: 0 2px 8px rgba(0,0,0,0.12);
        border-color: #4D6470;
    }
}
