:root {
    --etiqueta-width: 63.5mm;
    --etiqueta-height: 46.6mm;
}

body {
    background-color: #f8f9fa;
    padding-bottom: 2rem;
}

.header {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: white;
    padding: 1rem 0;
    margin-bottom: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border: none;
    margin-bottom: 1rem;
}

.card-header {
    background-color: #495057;
    color: white;
    font-weight: 600;
    padding: 0.75rem 1rem;
}

/* LAYOUT PRINCIPAL COM GRIDS BS5 */
.area-principal {
    margin-bottom: 2rem;
}

/* DATA TABLES */
#tabelaProdutos {
    font-size: 0.875rem;
}

#tabelaProdutos th {
    background-color: #495057;
    color: white;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.5rem;
}

#tabelaProdutos td {
    padding: 0.5rem;
    vertical-align: middle;
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.375rem 0.75rem;
}

.dataTables_wrapper .dataTables_length select {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.375rem 2rem 0.375rem 0.75rem;
}

/* PREVIEW DA ETIQUETA COMPACTO */
.preview-etiqueta {
    width: var(--etiqueta-width);
    height: var(--etiqueta-height);
    padding: 3mm;
    border: 2px solid #495057;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: white;
    margin: 0 auto 1rem;
    transform: scale(0.9);
    transform-origin: top center;
}

.etiqueta-empresa {
    font-size: 10px;
    font-weight: bold;
    margin-bottom: 2px;
    color: #333;
    max-height: 12px;
    overflow: hidden;
    text-align: center;
}

.etiqueta-logo {
    max-width: 100%;
    max-height: 50px;
    margin-bottom: 2px;
    object-fit: contain;
    display: block;
    margin-left: auto;
    margin-right: auto;
    /* Centraliza horizontalmente */
}

.etiqueta-descricao {
    font-size: 10px;
    font-weight: bold;
    line-height: 1.1;
    margin-bottom: 2px;
    word-break: break-word;
    max-height: 22px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.etiqueta-sigla {
    font-size: 10px;
    font-weight: bold;
    color: #2c5aa0;
    margin-bottom: 3px;
    text-align: left;
    text-transform: uppercase;
}

.etiqueta-codigo {
    font-size: 12px;
    margin-bottom: 2px;
    text-align: center;
    font-weight: bold;
    letter-spacing: 1px;
    font-family: 'Courier New', monospace;
}

.etiqueta-barcode {
    height: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-top: auto;
}

.etiqueta-barcode svg {
    max-width: 100%;
    height: 45px;
    transform: scale(1.3);
}

/* GRADE DE IMPRESSÃO */
.grade-container {
    width: 210mm;
    min-height: 297mm;
    display: grid;
    grid-template-columns: repeat(3, var(--etiqueta-width));
    grid-template-rows: repeat(6, var(--etiqueta-height));
    gap: 0 3.5mm;
    margin: 0 auto;
    padding: 10mm 8.5mm;
    background-color: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    page-break-after: always;
}

.etiqueta-grade {
    width: var(--etiqueta-width);
    height: var(--etiqueta-height);
    padding: 3mm;
    border: 1px dashed #ccc;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
}

.etiqueta-grade .btn-remover {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    padding: 0;
    font-size: 12px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s;
}

.etiqueta-grade:hover .btn-remover {
    opacity: 1;
}

.etiqueta-vazia {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #dee2e6;
    font-size: 12px;
}

/* CONTROLES */
.contador-etiquetas {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #0d6efd;
    color: white;
    padding: 10px 15px;
    border-radius: 50px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    font-weight: bold;
}

.btn-impressao {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
}

/* BOTÕES DE AÇÃO NA TABELA */
.btn-tabela {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    margin: 0 2px;
}

/* MODAL */
.modal-content {
    border: none;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

/* IMPRESSÃO */
@media print {
    body * {
        visibility: hidden;
    }

    .grade-container,
    .grade-container * {
        visibility: visible;
    }

    .grade-container {
        position: absolute;
        left: 0;
        top: 0;
        width: 210mm;
        min-height: 297mm;
        box-shadow: none;
        margin: 0;
        padding: 10mm 8.5mm;
    }

    .no-print {
        display: none !important;
    }

    .etiqueta-grade {
        border: none;
    }

    .btn-remover {
        display: none !important;
    }
}

@page {
    size: A4;
    margin: 0;
}

/* ESTILOS DATA TABLES */
.dataTables_wrapper {
    margin-top: 1rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.25rem 0.5rem;
    margin-left: 2px;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: #0d6efd;
    color: white !important;
    border-color: #0d6efd;
}

/* PREVIEW AREA */
.preview-card {
    height: 100%;
}

.preview-card .card-body {
    display: flex;
    flex-direction: column;
}

.controles-etiqueta {
    margin-top: auto;
}

/* RESPONSIVO */
@media (max-width: 768px) {
    .preview-etiqueta {
        transform: scale(0.8);
    }
}

/* ESTILOS PARA O MODAL MELHORADO */
.btn-aro,
.btn-qualidade {
    flex: 1;
    min-width: 120px;
}

.btn-qualidade {
    flex: 0 1 auto;
}

/* Garantir que os botões fiquem responsivos */
@media (max-width: 576px) {

    .btn-aro,
    .btn-qualidade {
        flex: 1 0 100%;
    }
}

/* Feedback visual para campos automáticos */
#modalDescricao {
    background-color: #f8f9fa;
    border-color: #0d6efd;
}

/* Estilo para o botão de copiar */
.btn-copiar-codigo {
    padding: 0.1rem 0.4rem;
    font-size: 0.75rem;
    border-radius: 0.25rem;
}

.btn-copiar-codigo:hover {
    background-color: #6c757d;
    color: white;
}

.etiqueta-grade .etiqueta-empresa,
.etiqueta-grade .etiqueta-descricao,
.etiqueta-grade .etiqueta-sigla,
.etiqueta-grade .etiqueta-codigo {
    text-align: center;
}

.etiqueta-grade .etiqueta-logo {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* Estilo para linha selecionada */
#tabelaProdutos tbody tr {
    cursor: pointer;
    transition: background-color 0.2s;
}

#tabelaProdutos tbody tr:hover {
    background-color: #f8f9fa !important;
}

#tabelaProdutos tbody tr.selecionada {
    background-color: #e7f1ff !important;
    border-left: 3px solid #0d6efd;
}

/* Evitar que os botões de ação afetem o cursor */
#tabelaProdutos .btn-group {
    cursor: default;
}

/* Estilos para a calculadora DV */
.calculadora-dv {
    max-width: 300px;
    margin-left: auto;
}

.calculadora-dv .input-group {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.calculadora-dv .form-text {
    font-size: 0.75rem;
}

/* Feedback visual melhorado */
#inputCodigoBase.is-valid {
    border-color: #198754;
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.25);
}

#inputCodigoBase.is-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}
