/* ==========================================
   GLOBAL STYLES
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    font-family: 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    color: #1a1a1a;
    width: 100%;
    overflow-x: hidden;
}

body {
    font-size: 0.75rem;
    overflow-x: hidden;
}

/* ==========================================
   LAYOUT CONTAINER
   ========================================== */
.layout-container {
    display: flex;
    min-height: 100vh;
}

/* ==========================================
   SIDEBAR
   ========================================== */
.sidebar {
    width: 250px;
    background: linear-gradient(135deg, #004085, #003262);
    color: #fff;
    padding-top: 0;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    left: 0;
    top: 0;
    transition: transform 0.3s ease, width 0.3s ease;
    z-index: 1000;
}

.sidebar-header {
    padding: 1.5rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1rem;
}

.sidebar-header h2 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.1rem 0;
}

.sidebar-header p {
    font-size: 0.75rem;
    opacity: 0.8;
    margin: 0;
}

.sidebar-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu li {
    margin: 0;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 0.7rem 1rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    font-size: 0.8rem;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.menu-item.active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-left-color: #ffc107;
    font-weight: 600;
}

.menu-item i {
    margin-right: 0.75rem;
    font-size: 1.1rem;
}

/* ==========================================
   MAIN CONTENT
   ========================================== */
.main-content {
    flex: 1;
    margin-left: 250px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* ==========================================
   HEADER
   ========================================== */
.header {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 0.7rem 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.btn-toggle-sidebar {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: #004085;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.page-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #004085;
    margin: 0;
}

/* ==========================================
   HEADER RIGHT - USUÁRIO
   ========================================== */
.header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1rem;
    border-left: 1px solid #e0e0e0;
    padding-left: 1rem;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #004085;
    white-space: nowrap;
}

.btn-logout {
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-logout:hover {
    background: linear-gradient(135deg, #ff5252, #ee4e5f);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.btn-logout i {
    font-size: 0.9rem;
}

/* ==========================================
   PAGES CONTAINER
   ========================================== */
.pages-container {
    flex: 1;
    overflow-y: auto;
    padding: 0.7rem;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ==========================================
   WELCOME PAGE
   ========================================== */
.welcome-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: auto;
    padding: 1rem 0;
}

.welcome-card {
    background: #fff;
    border-radius: 8px;
    padding: 1.2rem 1rem;
    max-width: 600px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.welcome-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.welcome-card h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #004085;
    margin: 0.5rem 0;
}

.welcome-subtitle {
    font-size: 0.95rem;
    color: #6c757d;
    margin-bottom: 0.6rem;
}

.welcome-description {
    color: #555;
    line-height: 1.4;
    margin-bottom: 0.8rem;
    font-size: 0.8rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.8rem;
    margin: 0.8rem 0;
}

.feature-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem 0.8rem;
    border: 1px solid #e0e0e0;
    transition: all 0.3s ease;
}

.feature-card:hover {
    box-shadow: 0 4px 12px rgba(0, 64, 133, 0.1);
    border-color: #004085;
    transform: translateY(-2px);
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 0.3rem;
}

.feature-card h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #004085;
    margin-bottom: 0.3rem;
}

.feature-card p {
    font-size: 0.75rem;
    color: #6c757d;
    margin: 0;
}

/* ==========================================
   CARDS & SECTIONS
   ========================================== */
.header-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 0 1 auto;
}

.label-search {
    font-size: 0.7rem;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.input-search {
    font-size: 0.7rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 120px;
}

.input-search:focus {
    border-color: #004085;
    box-shadow: 0 0 0 0.15rem rgba(0, 64, 133, 0.15);
    outline: none;
}

.btn-search {
    font-size: 0.7rem;
    padding: 0.4rem 0.8rem;
    white-space: nowrap;
}

.hint-search {
    font-size: 0.65rem;
    white-space: nowrap;
}

.hint-success {
    font-size: 0.65rem;
    white-space: nowrap;
    color: #0d3c26;
    font-weight: 600;
}

.section-dados,
.section-resume,
.section-referencias {
    margin-bottom: 0.6rem;
}

.card {
    border: none;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 0.6rem;
}

.card-header {
    padding: 0.5rem 0.8rem;
    font-weight: 600;
    font-size: 0.8rem;
    color: #fff;
    border: none;
    background: linear-gradient(135deg, #004085, #003262);
}

.card-header.bg-primary {
    background: linear-gradient(135deg, #004085, #003262) !important;
}

.card-header.bg-success {
    background: #0d3c26 !important;
}

/* Verde mais forte para linhas corrigidas */
.table-success-strong {
    background-color: #198754 !important; /* Bootstrap green but a bit stronger */
}

/* Linhas com status 'certo' (verde claro, texto escuro) */
.row-certo {
    background-color: #d4edda !important; /* bootstrap success light */
}

/* Linhas corrigidas (verde escuro) */
.row-corrigido {
    background-color: #0b5e3a !important; /* verde escuro */
}

.card-header.bg-danger {
    background: #721c24 !important;
}

.card-header.bg-info {
    background: #00396b !important;
}

.card-header.bg-warning {
    background: #856404 !important;
}

.card-body {
    padding: 0.75rem;
    background: #fff;
}

/* ==========================================
   FORMS
   ========================================== */
.form-label {
    font-size: 0.7rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: #333;
}

.form-control,
.form-select {
    font-size: 0.7rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.form-control:focus,
.form-select:focus {
    border-color: #004085;
    box-shadow: 0 0 0 0.15rem rgba(0, 64, 133, 0.15);
}

.input-group {
    gap: 0;
}

.input-group .form-control {
    border-radius: 4px 0 0 4px;
}

.input-group .btn {
    border-radius: 0 4px 4px 0;
    margin-left: -1px;
}

/* ==========================================
   BUTTONS
   ========================================== */
.btn {
    font-size: 0.75rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #004085, #003262);
    color: #fff;
}

.btn-primary:hover {
    background: #003262;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #6c757d;
    color: #fff;
}

.btn-success {
    background: #0d3c26;
    color: #fff;
}

.btn-lg {
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.7rem;
}

/* ==========================================
   TABLES
   ========================================== */
.table {
    font-size: 0.65rem;
    margin-bottom: 0;
}

.table thead {
    background: #f0f4f8;
}

.table th {
    padding: 0.3rem;
    text-align: center;
    border-bottom: 2px solid #e0e0e0;
    font-weight: 600;
    color: #004085;
}

/* Cabeçalhos com tema escuro (ex.: modal Ver/Editar Referência) — fonte branca.
   Sobrepõe o .table th azul-escuro acima para que os títulos (Revenda, Cat., Tipo, ...) fiquem em branco. */
.table thead.table-dark,
.table thead.table-dark th {
    background-color: #212529;
    color: #fff;
    border-color: #32383e;
}

.table td {
    padding: 0.3rem;
    text-align: center;
    border-bottom: 1px solid #f0f4f8;
}

/* ==========================================
   ALERTS & STATUS
   ========================================== */
.alert {
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
    font-size: 0.7rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    margin-bottom: 0.8rem;
}

.alert-warning {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.card-validacao-resumo {
    padding: 0.8rem;
    border-radius: 6px;
    text-align: center;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

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

.card-validacao-resumo h6 {
    font-size: 0.65rem;
    margin: 0 0 0.2rem 0;
    font-weight: 700;
}

.card-validacao-resumo h3 {
    font-size: 1.2rem;
    margin: 0;
    font-weight: 700;
}

.card-validacao-resumo.correto {
    background: linear-gradient(135deg, #0d3c26, #0a2f1f);
}

.card-validacao-resumo.alerta {
    background: linear-gradient(135deg, #856404, #6c5203);
}

.card-validacao-resumo.erro {
    background: linear-gradient(135deg, #721c24, #5a1620);
}

.card-validacao-resumo.conformidade {
    background: linear-gradient(135deg, #004085, #003262);
}

/* ==========================================
   ACCORDION
   ========================================== */
.accordion-button {
    font-size: 0.75rem;
    padding: 0.5rem 0.6rem;
    font-weight: 600;
    color: #004085;
}

.accordion-button:not(.collapsed) {
    background: #f0f4f8;
    color: #004085;
}

.accordion-body {
    padding: 0.5rem 0.75rem;
    font-size: 0.7rem;
}

/* ==========================================
   UTILITIES
   ========================================== */
.d-none {
    display: none !important;
}

.d-flex {
    display: flex !important;
}

.justify-content-between {
    justify-content: space-between !important;
}

.align-items-center {
    align-items: center !important;
}

.text-muted {
    color: #6c757d !important;
    font-size: 0.75rem !important;
}

.text-danger {
    color: #721c24 !important;
}

.text-success {
    color: #0d3c26 !important;
}

.text-white {
    color: #fff !important;
}

.fw-bold {
    font-weight: 700 !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mb-1 {
    margin-bottom: 0.2rem !important;
}

.mb-2 {
    margin-bottom: 0.4rem !important;
}

.mb-3 {
    margin-bottom: 0.6rem !important;
}

.mb-4 {
    margin-bottom: 1rem !important;
}

.mt-2 {
    margin-top: 0.4rem !important;
}

.mt-4 {
    margin-top: 1rem !important;
}

/* ==========================================
   SIDEBAR COLLAPSED STATE (DESKTOP)
   ========================================== */
.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed .sidebar-header h2,
.sidebar.collapsed .sidebar-header p {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    padding: 1rem 0.5rem;
    text-align: center;
}

.sidebar.collapsed .menu-item {
    padding: 1rem 0.75rem;
    justify-content: center;
    position: relative;
    font-size: 0;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar.collapsed .menu-item i {
    margin-right: 0;
    font-size: 1.3rem;
    display: inline-block;
}

/* Tooltip para menu recolhido */
.sidebar.collapsed .menu-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1001;
}

.sidebar.collapsed .menu-item:hover::after {
    opacity: 1;
}

.sidebar.collapsed .menu-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.main-content.collapsed {
    margin-left: 60px;
}

.btn-toggle-sidebar:hover {
    background: rgba(0, 64, 133, 0.1);
    transform: scale(1.05);
}

.btn-toggle-sidebar:active {
    transform: scale(0.95);
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 250px;
    }

    .sidebar.collapsed {
        transform: translateX(0);
        width: 250px;
    }

    .main-content {
        margin-left: 0;
    }

    .main-content.collapsed {
        margin-left: 0;
    }

    .btn-toggle-sidebar {
        display: block;
    }

    .pages-container {
        padding: 1rem;
    }

    .welcome-card {
        padding: 2rem 1.5rem;
    }

    .welcome-card h2 {
        font-size: 1.5rem;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    .page-title {
        font-size: 1.2rem;
    }

    header h1 {
        font-size: 1.3rem !important;
    }

    body {
        font-size: 0.8rem !important;
    }
}

@media (max-width: 480px) {
    .welcome-card {
        padding: 1.5rem 1rem;
    }

    .welcome-icon {
        font-size: 3rem;
    }

    .card-validacao-resumo h3 {
        font-size: 1.2rem;
    }
}

/* ==========================================
   TABELA DE REFERÊNCIAS - INTERATIVIDADE
   ========================================== */

table tbody tr.cursor-pointer {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

table tbody tr.cursor-pointer:hover {
    background-color: rgba(0, 123, 255, 0.1) !important;
    box-shadow: inset 0 0 5px rgba(0, 123, 255, 0.15);
}

/* Badge de validação */
.badge-validacao {
    font-size: 0.75rem;
    padding: 0.35rem 0.5rem;
}

/* Modal estilos */
.modal-body code {
    background-color: #f5f5f5;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    color: #d73852;
    font-size: 0.85rem;
}