html, body {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

body {
    display: flex;
    flex-direction: column;
    padding-bottom: 80px; /* Espaço para o footer fixo */
}

/* Force full width containers */
.container-fluid {
    width: 100%;
    max-width: 100%;
    padding-left: 15px;
    padding-right: 15px;
}

/* Prevent overflow and overlapping */
.row {
    margin-left: 0;
    margin-right: 0;
}

.row > [class*="col-"] {
    padding-left: 15px;
    padding-right: 15px;
}

/* Ensure cards don't overflow */
.card {
    overflow: visible;
}

/* Table responsive improvements */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Prevent body overflow */
body {
    max-width: 100vw;
    overflow-x: hidden;
}

.navbar {
    padding: .8rem 1rem;
}

footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    margin-top: 0;
}

/* Autocomplete Styles - Google-like */
.autocomplete-input {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dadce0;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 6px rgba(32, 33, 36, 0.28);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1060; /* Acima do modal do Bootstrap (z-index 1055) */
    display: none;
    margin-top: -1px;
}

.autocomplete-dropdown.show {
    display: block;
}

.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #f1f3f4;
    transition: background-color 0.1s;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.highlighted {
    background-color: #f1f3f4;
}

.autocomplete-item-icon {
    margin-right: 12px;
    color: #5f6368;
    font-size: 18px;
}

.autocomplete-item-text {
    flex: 1;
    color: #202124;
    font-size: 14px;
}

.autocomplete-item-empty {
    padding: 12px 16px;
    color: #5f6368;
    font-size: 14px;
    text-align: center;
    font-style: italic;
}

/* Multi-select Styles */
.multiselect-container {
    min-height: 38px;
    padding: 2px 4px;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    background: white;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    position: relative;
}

.multiselect-container:focus-within {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.multiselect-container .form-control {
    border: none;
    box-shadow: none;
    padding: 0;
    height: auto;
}

.multiselect-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.multiselect-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background-color: #0d6efd;
    color: white;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    gap: 4px;
}

.multiselect-chip-remove {
    cursor: pointer;
    padding: 0 2px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    transition: background-color 0.2s;
}

.multiselect-chip-remove:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.multiselect-input {
    border: none;
    outline: none;
    flex: 1;
    min-width: 120px;
    padding: 4px 8px;
    background: transparent;
}

.multiselect-input:focus {
    box-shadow: none;
    border: none;
}

.card {
    margin-bottom: 20px;
}

.auth-required {
    display: none;
}

/* Dropdown menu styles */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    display: none;
    min-width: 10rem;
    padding: 0.5rem 0;
    margin: 0;
    font-size: 1rem;
    color: #212529;
    text-align: left;
    list-style: none;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid rgba(0,0,0,.15);
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.175);
}

/* Navbar dropdown improvements */
.navbar .dropdown-menu {
    margin-top: 0.5rem;
}

.navbar .dropdown-item {
    padding: 0.5rem 1rem;
    transition: background-color 0.2s ease;
}

.navbar .dropdown-item:hover {
    background-color: #f8f9fa;
}

.navbar .dropdown-item.active {
    background-color: #0d6efd;
    color: white;
}

.navbar .dropdown-item i {
    margin-right: 0.5rem;
    width: 20px;
    text-align: center;
}

/* User dropdown special styling */
#userDropdown .dropdown-menu {
    min-width: 220px;
}

/* Admin section in user dropdown */
#userDropdown .dropdown-divider {
    margin: 0.5rem 0;
}

/* Dropdown toggle hover effect */
.navbar .dropdown-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.25rem;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 0.25rem 1rem;
    clear: both;
    font-weight: 400;
    color: #212529;
    text-align: inherit;
    text-decoration: none;
    white-space: nowrap;
    background-color: transparent;
    border: 0;
}

.dropdown-item:hover,
.dropdown-item:focus {
    color: #1e2125;
    background-color: #e9ecef;
}

.dropdown-item.active,
.dropdown-item:active {
    color: #fff;
    text-decoration: none;
    background-color: #0d6efd;
}

.auth-required.authenticated {
    display: block;
}

/* Estilos específicos para página de produtos */
.produto-card {
    transition: all 0.3s ease;
}

.produto-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

/* Estilos para caixa */
.saldo-display {
    font-size: 1.5rem;
    font-weight: bold;
}

.positive-value {
    color: #198754;
}

.negative-value {
    color: #dc3545;
}

/* Estilos para checkout com divisão */
.produto-draggable {
    cursor: grab;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.produto-draggable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    border-color: #007bff;
}

.produto-draggable.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
    cursor: grabbing;
}

.cliente-drop-zone {
    min-height: 200px;
    transition: all 0.3s ease;
    border: 2px dashed transparent;
}

.cliente-drop-zone.drag-over {
    border-color: #28a745;
    background-color: rgba(40, 167, 69, 0.1);
    transform: scale(1.02);
}

.cliente-drop-zone:hover {
    border-color: #007bff;
    background-color: rgba(0, 123, 255, 0.05);
}

/* Estilos para badges de status */
.badge-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* Animações para transições suaves */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Estilos para cards de clientes no checkout */
.cliente-card {
    transition: all 0.3s ease;
}

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

/* Estilos para produtos na lista de disponíveis */
.produto-disponivel {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
}

.produto-disponivel:hover {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-color: #2196f3;
}

/* Modal mais largo */
.modal-xxl {
    max-width: 95vw;
}

@media (min-width: 1200px) {
    .modal-xxl {
        max-width: 90vw;
    }
}

/* Melhor layout para checkout */
#areaClientesCheckout .col-md-4 {
    flex: 0 0 33.333333%;
    max-width: 33.333333%;
}

@media (max-width: 768px) {
    #areaClientesCheckout .col-md-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Produtos em grid mais compacto */
#produtosDisponiveis .col-md-4 {
    flex: 0 0 25%;
    max-width: 25%;
}

@media (max-width: 992px) {
    #produtosDisponiveis .col-md-4 {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }
}

@media (max-width: 768px) {
    #produtosDisponiveis .col-md-4 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* Searchable Select Component Styles */
.select-with-search {
    cursor: pointer;
}

.select-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    z-index: 1060;
    margin-top: 2px;
    padding: 8px;
    width: 100%;
    min-width: 200px;
}

.select-options-container {
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
}

.select-option-item {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 0.25rem;
    transition: background-color 0.15s ease-in-out;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.select-option-item:hover {
    background-color: #f8f9fa;
}

.select-option-item.selected {
    background-color: #0d6efd;
    color: white;
}

.select-option-item.selected:hover {
    background-color: #0b5ed7;
}

/* Scrollbar styling for options container */
.select-options-container::-webkit-scrollbar {
    width: 8px;
}

.select-options-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.select-options-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.select-options-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Ensure wrapper has relative positioning */
.position-relative .select-search-dropdown {
    position: absolute;
}

/* Filter dropdowns (products list) */
.filter-dropdown-wrapper {
    position: relative;
}

.filter-search-input {
    cursor: text;
}

.filter-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    min-width: 220px;
    max-height: 320px;
    overflow: hidden;
    display: none;
    flex-direction: column;
    padding: 0;
    margin-top: 2px;
    z-index: 1000;
    background: white;
    border: 1px solid rgba(0,0,0,.15);
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.175);
}

.filter-dropdown.show {
    display: flex;
}

/* Ensure filter dropdowns in modals appear above modal content */
.modal .filter-dropdown {
    z-index: 1060;
}

.filter-dropdown .filter-options {
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 0;
}

.filter-option-item {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 0;
    transition: background-color 0.15s ease;
    user-select: none;
    margin: 0;
}

.filter-option-item:hover {
    background-color: #f8f9fa;
}

.filter-option-item.selected {
    background-color: #0d6efd;
    color: white;
}

.filter-option-item.selected:hover {
    background-color: #0b5ed7;
}

.filter-option-item.filter-option-todas {
    color: #0d6efd;
}

.filter-option-item.filter-option-todas:hover {
    background-color: #e7f1ff;
    color: #0a58ca;
}

/* Category item with department name */
.filter-option-item .categoria-nome {
    font-weight: 500;
}

.filter-option-item .text-muted {
    font-size: 0.85em;
    margin-left: 4px;
}

/* Filter button groups for comandas */
.btn-group .btn-check:checked + .btn-outline-secondary {
    background-color: #6c757d;
    border-color: #6c757d;
    color: white;
}

.btn-group .btn-check:checked + .btn-outline-success {
    background-color: #198754;
    border-color: #198754;
    color: white;
}

.btn-group .btn-check:checked + .btn-outline-warning {
    background-color: #ffc107;
    border-color: #ffc107;
    color: #000;
}

.btn-group .btn-check:checked + .btn-outline-info {
    background-color: #0dcaf0;
    border-color: #0dcaf0;
    color: #000;
}

/* Date inputs in filters */
.form-control[type="date"] {
    max-width: 180px;
}

/* Active filters chips - separate row */
#filtrosAtivosRow {
    align-items: center;
}

#filtrosAtivosRow .d-flex {
    flex-wrap: wrap;
}

.filtro-ativo-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    font-weight: 500;
}

.filtro-chip-remove {
    cursor: pointer;
    margin-left: 2px;
    padding: 0 2px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
}

.filtro-chip-remove:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.25);
}

/* ============================================
   ESTILOS PARA PAGAMENTOS PARCIAIS
   ============================================ */

/* Badges de status de pagamento */
.badge.bg-success {
    background-color: #28a745 !important;
}

.badge.bg-warning {
    background-color: #ffc107 !important;
    color: #000 !important;
}

.badge.bg-secondary {
    background-color: #6c757d !important;
}

/* Barra de progresso de pagamento */
.progress {
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    transition: width 0.6s ease;
    font-weight: bold;
    font-size: 0.75rem;
}

.progress-bar.bg-success {
    background-color: #28a745 !important;
}

.progress-bar.bg-warning {
    background-color: #ffc107 !important;
    color: #000 !important;
}

.progress-bar.bg-secondary {
    background-color: #6c757d !important;
}

/* Card de resumo de pagamentos */
.card-header.bg-info {
    background-color: #0dcaf0 !important;
}

/* Tabela de histórico de pagamentos */
#pagamentosBody tr {
    transition: background-color 0.2s ease;
}

#pagamentosBody tr:hover:not(.table-secondary) {
    background-color: #f0f8ff;
    cursor: pointer;
}

#pagamentosBody tr.table-secondary {
    opacity: 0.6;
}

#pagamentosBody .badge {
    font-size: 0.875rem;
    padding: 0.4em 0.7em;
    font-weight: 500;
}

#pagamentosBody td {
    vertical-align: middle;
}

#pagamentosFooter {
    font-size: 1.1rem;
}

#totalPagamentosBadge {
    font-size: 0.9rem;
    padding: 0.5em 1em;
}

/* Modal de pagamento */
#modalAdicionarPagamento .form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

#modalAdicionarPagamento .input-group-text {
    background-color: #e9ecef;
    border-color: #ced4da;
    font-weight: 500;
}

#modalAdicionarPagamento .form-select-lg,
#modalAdicionarPagamento .input-group-lg .form-control {
    font-size: 1.1rem;
    padding: 0.75rem;
}

#modalAdicionarPagamento small.text-muted {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    line-height: 1.4;
}

#modalAdicionarPagamento .alert-info {
    border-left: 4px solid #0dcaf0;
}

#modalAdicionarPagamento .alert-info strong {
    color: #0c5460;
}

/* Botões de ação de pagamento */
.btn-cancelar-pagamento {
    font-size: 0.875rem;
}

/* Indicadores visuais */
.text-success {
    color: #28a745 !important;
}

.text-warning {
    color: #ffc107 !important;
}

/* Botão de adicionar pagamento no header */
.card-header #btnAdicionarPagamento {
    transition: all 0.2s ease;
    font-weight: 500;
}

.card-header #btnAdicionarPagamento:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    background-color: #fff !important;
    color: #0dcaf0 !important;
}

/* Tabelas com scroll fixo */
.table-responsive {
    position: relative;
}

.table-responsive .sticky-top {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #f8f9fa;
}

.table-responsive .sticky-bottom {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background-color: #f8f9fa;
}

/* Botão no resumo */
#btnAdicionarPagamentoResumo {
    transition: all 0.2s ease;
}

#btnAdicionarPagamentoResumo:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Responsividade para resumo de pagamentos */
@media (max-width: 992px) {
    /* Em tablets e mobile, voltar ao layout vertical */
    .row > .col-lg-6 {
        margin-bottom: 1.5rem;
    }
}

@media (max-width: 768px) {
    .card-header.bg-info {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .card-header #btnAdicionarPagamento {
        width: 100%;
    }
}