/**
 * Dashboard TanaGest - Estilos
 * Versão Limpa: 2.0
 */

/* =================================================================
 * 1. RESET E VARIÁVEIS
 * ================================================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Cores */
    --brand: #22bcad;
    --brand-dark: #1a998c;
    --bg-page: #f0f4f8;
    --bg-card: #ffffff;
    --border: #e1e8ed;
    --text: #233238;
    --text-muted: #6b7280;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --secondary: #D9F0EE;

    /* Sombras e Bordas */
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 8px;

    /* Tipografia */
    --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}

body {
    font-family: var(--font);
    background-color: var(--bg-page);
    color: var(--text);
    line-height: 1.6;
}

/* =================================================================
 * 2. NAVBAR
 * ================================================================= */

.navbar {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: none;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    color: var(--brand);
}

.navbar-brand svg {
    width: 32px;
    height: 32px;
}

/* =================================================================
 * 2.1 WORKSPACE SELECTOR
 * ================================================================= */

.workspace-selector {
    position: relative;
    margin-right: auto;
    z-index: 1002;
}

.workspace-active {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color 0.2s;
    border: 1px solid transparent;
}

.workspace-active:hover, .workspace-selector.open .workspace-active {
    background-color: #f3f4f6;
    border-color: var(--border);
}

.workspace-icon {
    width: 24px;
    height: 24px;
    color: var(--brand);
}

.workspace-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.workspace-chevron {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.workspace-selector.open .workspace-chevron {
    transform: rotate(180deg);
}

.workspace-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    padding: 8px;
}

.workspace-selector.open .workspace-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.workspace-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.workspace-option:hover {
    background-color: #f3f4f6;
}

.workspace-option.active {
    background-color: #f0fdfa; /* light brand */
}

.workspace-option-icon {
    width: 32px;
    height: 32px;
    background-color: var(--brand);
    color: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.workspace-option-text {
    font-size: 14px;
    font-weight: 500;
}

.workspace-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 8px;
}

.workspace-portal {
    background: #f8fafc;
    border-radius: 6px;
    margin: 4px;
}

.portal-icon {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%) !important;
    color: white !important;
}

.workspace-option:not(.active) .workspace-option-icon {
    background-color: var(--text-muted);
}

.workspace-option-text {
    color: var(--text);
    font-weight: 500;
    font-size: 14px;
}

/* =================================================================
 * 2.2 NAV DROPDOWNS
 * ================================================================= */

.nav-dropdown-container {
    position: relative;
}

.nav-item-split {
    display: inline-flex;
    align-items: stretch;
    border-radius: var(--radius);
    overflow: hidden;
    transition: background-color 0.2s, color 0.2s;
}

.nav-item-split-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 8px 16px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 14px;
    transition: color 0.2s;
}

.nav-item-split-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    padding: 0 10px;
    border: none;
    border-left: 1px solid #ffffff;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    transition: background-color 0.2s, color 0.2s, border-left-color 0.25s ease;
}

.nav-item-split:hover,
.nav-item-split.active,
.nav-dropdown-container.open .nav-item-split {
    background-color: #f3f4f6;
}

.nav-item-split:hover .nav-item-split-toggle,
.nav-item-split.active .nav-item-split-toggle,
.nav-dropdown-container.open .nav-item-split-toggle {
    border-left-color: rgba(0, 0, 0, 0.12);
}

.nav-item-split:hover .nav-item-split-link,
.nav-item-split.active .nav-item-split-link,
.nav-dropdown-container.open .nav-item-split-link,
.nav-item-split:hover .nav-item-split-toggle,
.nav-item-split.active .nav-item-split-toggle,
.nav-dropdown-container.open .nav-item-split-toggle {
    color: var(--brand);
}

.nav-item-split-toggle:hover {
    background-color: rgba(34, 188, 173, 0.1);
}

.nav-dropdown-container.open .nav-item-split-toggle {
    background-color: rgba(34, 188, 173, 0.14);
}

.dropdown-chevron {
    transition: transform 0.2s;
    pointer-events: none;
}

.nav-dropdown-container.open .dropdown-chevron {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    padding: 8px;
    z-index: 1001;
}

.nav-dropdown-container.open .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.2s;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
}

.nav-dropdown-item:hover, .nav-dropdown-item.active {
    background-color: #f3f4f6;
    color: var(--brand);
}

.nav-dropdown-item svg {
    color: var(--text-muted);
}

.nav-dropdown-item:hover svg, .nav-dropdown-item.active svg {
    color: var(--brand);
}

.navbar-menu {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nav-item {
    padding: 8px 16px;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-item:hover, .nav-item.active {
    background-color: #f3f4f6;
    color: var(--brand);
}

/* === ÁREA DO USUÁRIO === */
.navbar-user {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}

.user-info {
    text-align: right;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

.btn-logout {
    padding: 8px 16px;
    background-color: var(--danger);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background-color: var(--danger-dark);
}

/* =================================================================
 * 2.3 USER PROFILE DROPDOWN
 * ================================================================= */

.user-profile-dropdown {
    position: relative;
    z-index: 1002;
}

.user-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    background-color: #f3f4f6;
    color: var(--text-muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.user-avatar-notification-dot {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--brand);
    border: 2px solid var(--bg-card);
    box-sizing: border-box;
    display: none;
    pointer-events: none;
    z-index: 1;
}

.user-avatar-notification-dot.visible {
    display: block;
}

.user-avatar:hover, .user-profile-dropdown.open .user-avatar {
    background-color: var(--brand);
    color: white;
    border-color: var(--brand-dark);
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 240px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    padding: 8px;
}

.user-profile-dropdown.open .user-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-header {
    padding: 12px;
}

.user-dropdown-header .user-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.user-dropdown-header .user-role {
    font-size: 13px;
    color: var(--text-muted);
}

.user-dropdown-divider {
    height: 1px;
    background-color: var(--border);
    margin: 8px 0;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.2s;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    width: 100%;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
}

.user-dropdown-item:hover {
    background-color: #f3f4f6;
}

.user-dropdown-item svg {
    color: var(--text-muted);
}

.user-dropdown-item.logout-btn {
    color: var(--danger);
}

.user-dropdown-item.logout-btn:hover {
    background-color: #fef2f2;
}

.user-dropdown-item.logout-btn svg {
    color: var(--danger);
}


/* Badge de notificações no menu */
.notification-badge {
    background-color: #22bcad10;
    color: var(--brand);
    padding: 0px 6px;
    border-radius: var(--radius);
    font-size: 10px;
    font-weight: 800;
    border: 2px solid var(--brand);
    display: inline-block;
    transition: all 0.3s ease;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* =================================================================
 * 3. LAYOUT GLOBAL E BOTÕES
 * ================================================================= */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 32px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* Estilo Base do Botão */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--brand);
    color: white;
    justify-content: center;
}

.btn-primary:hover {
    background-color: var(--brand-dark);
}

.btn-secondary {
    background-color: white;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background-color: #f9fafb;
}

/* =================================================================
 * 4. SECÇÃO DE ATUALIZAÇÕES DE PREÇO
 * ================================================================= */

.price-updates {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.section-header-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.section-date {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.badge {
    background-color: #22bcad10;
    color: var(--brand);
    padding: 4px 6px;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
    border: 2px solid var(--brand);
    display: inline-block;
    transition: all 0.3s ease;
}

.badge-link {
    text-decoration: none;
    cursor: pointer;
}

.badge-link:hover {
    background-color: rgba(34, 188, 173, 0.18);
    color: var(--brand-dark);
}

.time-filter {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 6px 12px;
    background-color: var(--brand);
    color: white;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
}

.updates-scroll {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 8px 0;
    /* Ajuste de scrollbar para melhor estética */
}

.updates-scroll::-webkit-scrollbar {
    height: 6px;
}

.updates-scroll::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.updates-scroll::-webkit-scrollbar-thumb {
    background: var(--brand);
    border-radius: 10px;
}

.update-card {
    min-width: 220px;
    background-color: #f9fafb;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    flex-shrink: 0; /* Impede que os cards encolham */
}

.update-product-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.update-cnp {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.update-lab {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.price-comparison {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.old-price {
    text-decoration: line-through;
    color: var(--text-muted);
    font-size: 13px;
}

.new-price {
    color: var(--brand);
    font-weight: 700;
    font-size: 16px;
}

/* =================================================================
 * 5. LISTA DE PRODUTOS E CONTROLES
 * ================================================================= */

.product-list {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.list-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    gap: 16px;
    flex-wrap: wrap;
}

/* Pesquisa */
.search-box {
    flex: 1;
    min-width: 300px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 10px 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    transition: all 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(34,188,173,0.1);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.ui-icon-inline {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    line-height: 0;
}

.ui-icon-inline svg {
    flex-shrink: 0;
}

.btn .ui-icon-inline,
.filter-btn .ui-icon-inline,
.time-filter-btn .ui-icon-inline,
.update-type-badge .ui-icon-inline {
    margin-right: 4px;
}

.update-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.file-upload-icon.ui-icon-inline {
    justify-content: center;
    margin-bottom: 12px;
    color: var(--text-muted);
}

/* Filtros */
.filter-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filter-btn {
    padding: 8px 16px;
    background-color: white;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    box-sizing: border-box;
    transition: all 0.2s;
    user-select: none;
}

.filter-btn.download-btn {
    font-weight: 500;
}

.filter-btn.download-btn .export-btn-label {
    line-height: 1;
}

.filter-btn:hover {
    background-color: #f9fafb;
}

/* Estilo para o seletor de itens por página */
.pagination-select {
    border: none;
    background-color: transparent;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    text-align-last: right;
    cursor: pointer;
    /* Remover estilos padrão do browser */
    -webkit-appearance: none; 
    -moz-appearance: none;
    appearance: none;
}

.pagination-select:hover {
    color: var(--brand);
    
}

.pagination-select:focus {
    color: var(--text);
    border-color: var(--brand);
    outline: 2px solid var(--brand);
    border-radius: 4px;
    background-color: #f0fdfa;
    
}

/* =================================================================
 * 6. TABELA
 * ================================================================= */

.table-wrapper {
    overflow-x: auto;
    max-width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto !important; /* Ajuda a gerir larguras de coluna */
    min-width: 0; /* Prevent minimum width issues */
}

thead {
    background-color: #f9fafb;
    border-bottom: 1px solid var(--border);
}

th {
    padding: 12px 20px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}


/* Colunas de Largura Fixa para melhor alinhamento */
th:nth-child(1) { width: 40px; } /* Checkbox */
th:nth-child(2) { width: 120px; } /* CNP */
th:nth-child(3) { width: 400px; min-width: 350px; } /* NOME - Guaranteed minimum */
th:nth-child(4) { width: 120px; } /* IVA */
th:nth-child(5) { width: 120px; } /* PVPR */
th:nth-child(5) { width: 160px; } /* PREÇOTANARA */
th:nth-child(8) { width: 120px; } /* AÇÕES */


td {
    padding: 4px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    /* Adicionar overflow para ellipsis em colunas de texto */
    overflow: hidden; 
    text-overflow: ellipsis;
    white-space: nowrap;
}

tbody tr {
    transition: background-color 0.15s;
}

tbody tr:hover {
    background-color: #f9fafb;
}

tbody tr:last-child td {
    border-bottom: none;
}

.product-name {
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    margin: 0;
    padding: 0;
}

.product-cnp {
    color: var(--text-muted);
    font-size: 13px;
}

/* Preço PVPR - Cinza escuro */
.price-pvpr {
    color: #6b7280 !important;
    font-weight: 600;
}

/* Preço Tanara - Mantém a cor turquesa original */
.price-tanara {
    color: #22bcad !important;
    font-weight: 700;
}

.lab-badge {
    background-color: #f3f4f6;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text);
    display: inline-block;
}

.actions-cell {
    display: flex;
    gap: 8px;
    justify-content: center;
    min-width: 0; /* Prevent flex items from causing overflow */
}

.action-btn {
    padding: 6px 10px;
    border: 1px solid var(--border);
    background-color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-muted);
    transition: all 0.2s;
}

.action-btn:hover {
    background-color: #f9fafb;
    color: var(--brand);
    border-color: var(--brand);
}


/* Paginação */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.pagination-info {
    font-size: 14px;
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    gap: 8px;
}

.pagination-controls button {
    padding: 8px 12px;
    border: 1px solid var(--border);
    background-color: white;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    box-sizing: border-box;
}

.pagination-chevron {
    display: inline-flex;
    align-items: center;
    line-height: 0;
    color: currentColor;
}

.pagination-controls button:hover:not(:disabled) {
    background-color: #f9fafb;
    border-color: var(--brand);
    color: var(--brand);
}

.pagination-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =================================================================
 * 7. RESPONSIVE
 * ================================================================= */

@media (max-width: 768px) {
    .navbar {
        padding: 12px 16px;
        flex-wrap: wrap;
    }

    /* Ocultar menu na navegação móvel (opcional) */
    .navbar-menu {
        display: none;
    }

    .container {
        padding: 16px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .header-actions {
        flex-wrap: wrap;
        width: 100%;
    }

    .header-actions .btn {
        flex: 1;
        min-width: 150px;
    }

    /* Controles de Lista */
    .list-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .search-box {
        width: 100%;
        min-width: auto;
    }
    
    .filter-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .filter-btn {
        flex-grow: 1;
        justify-content: center;
    }
    
    /* Tabela */
    table {
        font-size: 12px;
    }

    th, td {
        padding: 12px 10px;
    }
    
    /* Remover larguras fixas em mobile */
    th:nth-child(1), th:nth-child(4), th:nth-child(5), th:nth-child(6), th:nth-child(8) {
        width: auto;
    }

    /* Paginação */
    .pagination {
        flex-direction: column;
        gap: 12px;
    }
}


/* Modal de Edição */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}



.modal h2 {
    margin-bottom: 20px;
    color: var(--text);
}

/* Barra de Ações em Lote */
.bulk-actions-bar {
    position: fixed;
    bottom: -100px;
    left: 0;
    right: 0;
    background-color: var(--bg-card);
    border-top: 2px solid var(--brand);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    padding: 16px 32px;
    z-index: 999;
    transition: bottom 0.3s ease, opacity 0.3s ease;
}

.bulk-actions-bar.active {
    bottom: 0;
}

.bulk-actions-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bulk-actions-content span {
    font-weight: 600;
    color: var(--brand);
}

.bulk-actions-buttons {
    display: flex;
    gap: 12px;
}

.bulk-actions-buttons .btn-bulk-muted,
.bulk-actions-buttons .btn-bulk-danger {
    color: #fff;
}

.bulk-actions-buttons .btn-bulk-muted .ui-icon-inline,
.bulk-actions-buttons .btn-bulk-danger .ui-icon-inline {
    color: #fff;
}

.bulk-actions-buttons .btn-bulk-muted .ui-icon-inline svg,
.bulk-actions-buttons .btn-bulk-danger .ui-icon-inline svg {
    stroke: #fff;
}

.product-list input[type="checkbox"],
#selectAll,
.row-checkbox {
    accent-color: var(--brand);
    cursor: pointer;
}

.help-widget {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.help-icon {
  width: 60px;
  height: 60px;
  background: var(--brand);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: all 0.3s ease;
  border: 2px solid var(--brand-dark);
  flex-shrink: 0;
}

.help-icon:hover {
  background: var(--brand-dark);
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(34, 188, 173, 0.3);
}

.help-content {
  width: 280px;
  background: var(--bg-card);
  color: var(--text);
  padding: 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 14px;
  line-height: 1.5;
  
  /* Posição fixa - sem transição no CSS, controlada apenas por JS */
  position: absolute;
  left: 80px;
  bottom: 0;
  
  /* Estado inicial (será sobrescrito pelo JavaScript) */
  opacity: 0;
  visibility: hidden;
  transform: translateX(-10px);
}

.help-content:hover {
  background: var(--secondary);
  border-color: var(--brand);
}

.help-content strong {
  color: var(--brand-dark);
}

/* Responsividade */
@media (max-width: 768px) {
  .help-widget {
    bottom: 15px;
    left: 15px;
  }
  
  .help-icon {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }
  
  .help-content {
    width: 240px;
    left: 70px;
    padding: 14px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .help-content {
    width: 220px;
    left: 65px;
  }
}


/* Indicador visual quando o ESC está disponível */
.bulk-actions-bar::after {
    content: "Pressione ESC para limpar";
    position: absolute;
    top: -20px;
    right: 20px;
    background: var(--brand);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.bulk-actions-bar.active::after {
    opacity: 1;
}


@media (max-width: 768px) {
    .bulk-actions-content {
        flex-direction: column;
        gap: 12px;
    }
    
    .bulk-actions-buttons {
        width: 100%;
    }
    
    .bulk-actions-buttons button {
        flex: 1;
    }
}

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


/* Greyed out save buttons when no changes */
tr:not(.modified) .action-btn:not(.delete-btn):not(.cancel-btn):not(.test-btn),
tr:not(.modified) .lab-action-btn.save {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

tr.modified .action-btn,
tr.modified .lab-action-btn.save {
    opacity: 1;
    cursor: pointer;
    pointer-events: auto;
}

.action-btn.delete-btn {
    color: var(--danger) !important;
    background-color: transparent !important;
    opacity: 1 !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 8px;
}

.action-btn.delete-btn:hover {
    background-color: #fef2f2 !important;
    border-color: var(--danger) !important;
}

tr:not(.modified) .action-btn.delete-btn,
tr:not(.modified) .action-btn.cancel-btn,
tr:not(.modified) .action-btn.test-btn {
    opacity: 1 !important;
    cursor: pointer !important;
    pointer-events: auto !important;
}

.action-btn.cancel-btn {
    color: var(--text-muted);
}

.action-btn.test-btn {
    color: var(--brand);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

tr.modified {
    background-color: #fef3c7;
}

tr.saved {
    background-color: #d1fae5;
    transition: background-color 0.3s;
}

tr.new-user-row {
    background-color: #eff6ff;
}

.editable {
    cursor: text;
    border-radius: 4px;
    padding: 4px 6px;
    transition: background-color 0.2s;
}

.editable:hover {
    background-color: #f3f4f6;
}

.editable.editing {
    background-color: #fff;
    outline: 2px solid var(--brand);
    outline-offset: -1px;
}

.user-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.user-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(34, 188, 173, 0.1);
}

.user-tipo-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.user-tipo-select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(34, 188, 173, 0.1);
}

/* Admin panel — usuarios-gestao.php */
.emails-management-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 32px;
    margin-bottom: 16px;
    gap: 16px;
    flex-wrap: wrap;
}

.emails-management-section {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.emails-management-content {
    padding: 20px;
}

.emails-controls {
    margin-bottom: 20px;
}

.user-select-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 400px;
}

.user-select-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.new-email-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
    padding: 16px;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.new-email-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 180px;
}

.new-email-form .form-group-small {
    flex: 0 0 140px;
    min-width: 120px;
}

.new-email-form label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.emails-table {
    width: 100%;
    border-collapse: collapse;
}

.emails-table th,
.emails-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.emails-table th {
    background-color: #f9fafb;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.email-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.email-field {
    width: 100%;
}

.page-admin .emails-table input.email-field.user-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    box-sizing: border-box;
    background: #fff;
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.page-admin .emails-table input.email-field.user-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(34, 188, 173, 0.1);
}

.emails-stats-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin: -4px 0 12px;
}

.no-user-selected,
.no-emails {
    text-align: center;
    padding: 48px 24px !important;
    color: var(--text-muted);
}

.empty-state-icon {
    display: flex;
    justify-content: center;
    color: var(--text-muted);
    opacity: 0.45;
    margin-bottom: 16px;
}

.empty-state-sub {
    font-size: 14px;
    color: #9ca3af;
    margin-top: 8px;
}

.emails-stats-panel {
    margin-top: 20px;
    padding: 16px 20px;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.emails-stats-panel h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

.emails-stat-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.emails-stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.emails-stat-label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-muted);
}

.emails-stat-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: white;
}

.emails-stat-badge.total { background: var(--brand); }
.emails-stat-badge.active { background: #10b981; }
.emails-stat-badge.inactive { background: #6b7280; }

.btn.loading {
    opacity: 0.7;
    cursor: wait;
}



/* Undo Button Styles */
.undo-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--brand);
    border-radius: 3px;
    transition: all 0.2s;
    display: none;
    line-height: 1;
    height: 18px;
    width: 18px;
    margin-left: 6px;
    vertical-align: middle;
}

.undo-btn:hover {
    background-color: var(--muted);
    transform: rotate(-15deg);
}

/* Product list undo button - same style as lab modal */
.product-list th .undo-btn {
    background: none;
    border: none;
    font-size: 16px;
    font-family: inter;
    font-weight: 600;
    cursor: pointer;
    color: fieldtext;
    border-radius: 3px;
    transition: all 0.2s;
    line-height: 1;
    height: 24px;
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    margin-left: 8px;
    opacity: 0.5;
}

.product-list th .undo-btn:hover {
    color: var(--brand);
    opacity: 1;
}

/* Fixed height for table container to prevent layout shifts */
.table-wrapper {
    min-height: 440px;
    position: relative;
}

/* Ensure the table body maintains consistent height */
#tableBody {
    min-height: 400px;
}

/* Filter dropdown styles */
.filter-dropdown {
    position: relative;
}

.filter-select {
    padding: 11px 32px 11px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: white;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    min-width: 180px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(34,188,173,0.1);
}

/* Sortable header styles */
.sortable-header {
    position: relative;
    cursor: pointer;
    user-select: none;
    /* Remove the padding-right since arrow is next to text now */
}

.sortable-header:hover {
    color: #22bcad;
}

.sort-arrow {
    /* Remove absolute positioning and put it inline with text */
    display: inline-block;
    margin-left: 4px;
    font-size: 14px;
    transition: transform 0.2s ease;
}


/* =================================================================
 * 9. MODAL LABERATÓRIOS - ATUALIZADO
 * ================================================================= */

#gerirLaboratoriosModal .modal-content {
    max-width: 750px;
    width: 90%;
    max-height: 750px;
    height: 90%;
    margin: auto;
    background-color: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    position: relative;
}

.modal-header-custom {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background-color: white;
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header-custom h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.modal-header-actions {
    display: flex;
    gap: 16px;
    align-items: center;
    overflow: hidden;
    background-color: white;
}

/* Botão Novo Laboratório */
#gerirLaboratoriosModal #btnToggleNewLab {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 0;
    padding: 8px 16px;
    height: 36px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
}

/* X button like pagination */
#gerirLaboratoriosModal .modal-close {
    padding: 8px 12px;
    border: 1px solid var(--border);
    background-color: white;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 18px;
    color: var(--text-muted);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: 36px;
    line-height: 1;
    font-weight: normal;
}

#gerirLaboratoriosModal .modal-close:hover {
    background-color: #f9fafb;
    border-color: var(--brand);
    color: var(--brand);
}

.modal-body-custom {
    flex: 1;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* CORREÇÃO: Container sem scroll - apenas para layout */
.laboratorios-table-wrapper {
    flex: 1;
    overflow: hidden; /* Remove scroll do wrapper */
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* CORREÇÃO: Table com estrutura flex para scroll separado */
.laboratorios-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg-card);
    table-layout: fixed;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.laboratorios-table thead {
    background-color: #f9fafb;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0; /* Impede que o header scroll */
    display: table;
    width: 100%;
    table-layout: fixed;
}

/* CORREÇÃO: Tbody com scroll próprio */
.laboratorios-table tbody {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: block;
}

/* Garantir que as linhas mantenham display de tabela */
.laboratorios-table tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

/* CORREÇÃO: Scrollbar styling APENAS no tbody */
.laboratorios-table tbody::-webkit-scrollbar {
    width: 6px;
}

.laboratorios-table tbody::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
    margin: 4px 0;
}

.laboratorios-table tbody::-webkit-scrollbar-thumb {
    background: var(--brand);
    border-radius: 10px;
}

/* Height das linhas */
.laboratorios-table th {
    padding: 12px 20px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    background-color: #f9fafb;
    height: 40px;
}

.laboratorios-table td {
    padding: 4px 20px;
    font-size: 14px;
    color: var(--text);
    vertical-align: top;
    height: 40px;
}

/* Widths das colunas - IMPORTANTE para table-layout: fixed */
.laboratorios-table th:nth-child(1),
.laboratorios-table td:nth-child(1) { 
    width: 200px; 
}

.laboratorios-table th:nth-child(2),
.laboratorios-table td:nth-child(2) { 
    width: 400px; 
}

.laboratorios-table th:nth-child(3),
.laboratorios-table td:nth-child(3) { 
    width: 150px; 
}

.laboratorios-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background-color 0.15s;
    height: 40px;
}

.laboratorios-table tbody tr:hover {
    background-color: #f9fafb;
}

.laboratorios-table tbody tr.new-lab-row {
    background-color: #ecfdf5;
	border:2px solid var(--brand);
    box-shadow: 1px 18px 20px #c3c3c359;
}

.laboratorios-table tbody tr.modified {
    background-color: #D9F0EE;
}

.laboratorios-table td:nth-child(3) {
    text-align: left;
}

.laboratorios-table td:nth-child(3) > div {
    justify-content: flex-start !important;
}

.editable-lab {
    cursor: text;
    transition: all 0.2s;
    padding: 6px 12px;
    border-radius: 6px;
    min-height: 28px;
    border: 1px solid transparent;
    line-height: 1.4;
    width: 100%;
    display: flex;
    align-items: center;
}

.editable-lab:hover {
    background-color: #f3f4f6;
}

.editable-lab.editing {
    background-color: #f0fdfa;
    outline: 2px solid var(--brand);
    border-color: var(--brand);
}

.lab-input {
    width: 100%;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: var(--font);
    font-style: italic;
    color: var(--brand);
    background-color: white;
    height: 32px;
}

.lab-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(34,188,173,0.1);
}

.lab-input::placeholder {
    color: var(--brand);
    font-style: italic;
    text-transform: uppercase;
    opacity: 0.7;
}

.modal-footer-custom {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background-color: white;
    display: flex;
    justify-content: space-between; /* Changed from flex-end to space-between */
    align-items: center;
    border-radius: 0 0 var(--radius) var(--radius);
    flex-shrink: 0;
    gap: 12px;
}

.footer-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex: 1;
}

.footer-btn {
    padding: 8px 12px;
    border: 1px solid var(--border);
    background-color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.footer-btn:hover {
    background-color: #f9fafb;
    border-color: var(--brand);
    color: var(--brand);
}

.lab-action-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background-color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
    color: var(--danger);
    height: 28px;
    display: flex;
    align-items: center;
}

.lab-action-btn:hover {
    background-color: #fef2f2;
    border-color: var(--danger);
}

.lab-action-btn.save {
    color: var(--text);
    background-color: var(--brand);
    color: white;
    border-color: var(--brand);
}

.lab-action-btn.save:hover {
    background-color: var(--brand-dark);
    border-color: var(--brand-dark);
}

.lab-action-btn.cancel {
    color: var(--text-muted);
    background-color: white;
}

.lab-action-btn.cancel:hover {
    background-color: #f9fafb;
    border-color: var(--text-muted);
    color: var(--text);
}

/* Prevent background scroll when modal is open */
body.modal-open {
    overflow: hidden;
}


.modal-title-with-count {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lab-items-count {
	background-color: #22bcad10;
    border: 2px solid;
    color: var(--brand);
    padding: 0px 6px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
}

.modal-header-custom h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

/* Lab Modal Undo Button in AÇÕES header */
.laboratorios-table th .undo-btn {
    background: none;
    border: none;
    font-size: 16px;
    font-family: inter;
    font-weight: 600;
    cursor: pointer;
    color: fieldtext;
    border-radius: 3px;
    transition: all 0.2s;
    display: none; /* Será controlado via JavaScript */
    line-height: 1;
    height: 24px;
    width: 24px;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    margin-left: 8px; /* Espaço entre "Ações" e o botão */
    opacity: 0.5;
}

.laboratorios-table th .undo-btn:hover {
    color: var(--brand);
    opacity: 1;
}

/* Garantir que o container do header mantém o alinhamento */
.laboratorios-table th:nth-child(3) > div {
    display: flex;
    align-items: center;
    justify-content: flex-start !important;
    width: 100%;
}
/* Lab Modal Sortable Headers */
#gerirLaboratoriosModal .sortable-header {
    position: relative;
    cursor: pointer;
    user-select: none;
}

#gerirLaboratoriosModal .sortable-header:hover {
    color: #22bcad;
}

#gerirLaboratoriosModal .sort-arrow {
    display: inline-block;
    margin-left: 4px;
    font-size: 14px;
    transition: transform 0.2s ease;
}

/* Prevent background scroll when modal is open */
body.modal-open {
    overflow: hidden;
}

/* =================================================================
 * 10. MODAL NOVO PRODUTO
 * ================================================================= */

#novoProdutoModal .modal-content {
    max-width: 900px; /* antes 600px */
    width: 95%;
    max-height: 75vh; /* limita a altura total para não ocupar a tela toda */
    background-color: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    position: relative;
    display: flex;
    flex-direction: column;
}



#novoProdutoModal .modal-header-custom {
        padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background-color: white;
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#novoProdutoModal .modal-header-custom h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

#novoProdutoModal .modal-close {
    padding: 8px 12px;
    border: 1px solid var(--border);
    background-color: white;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 18px;
    color: var(--text-muted);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: 36px;
    line-height: 1;
    font-weight: normal;
}

#novoProdutoModal .modal-close:hover {
    background-color: #f9fafb;
    border-color: var(--brand);
    color: var(--brand);
}

#novoProdutoModal .modal-body-custom {
    padding: 32px;
    background-color: #f9fafb;
    border-radius: var(--radius);
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

#novoProdutoModal .form-group.laboratorio,
#novoProdutoModal .form-group.iva {
    position: relative;
    z-index: 2;
}

#novoProdutoModal .form-group.laboratorio:has(.modal-search-dropdown.open),
#novoProdutoModal .form-group.iva:has(.modal-form-dropdown.open) {
    z-index: 50;
}

.form-grid {
    display: grid;
        grid-template-columns: repeat(3, 1fr); /* 3 colunas em vez de 2 */

    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-group label .info-icon {
    color: var(--text-muted);
    cursor: help;
    font-size: 14px;
}

.form-input,
.form-select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    color: var(--text);
    background-color: white;
    transition: all 0.2s;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(34,188,173,0.1);
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.clear-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background-color: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

.clear-btn:hover {
    background-color: #f9fafb;
    border-color: var(--text-muted);
    color: var(--text);
}

.file-upload-area {
    border: 2px dashed var(--brand);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: 0px 0px 0px 6px rgba(34, 188, 173, 0.15);
    text-align: center;
    background-color: #f0fdfa;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 16px;
    margin-bottom: 16px;
    inline-size: -webkit-fill-available;
    width:100%;
}

.file-upload-area:hover {
    background-color: #ccfbf1;
    border-color: var(--brand-dark);
}

.file-upload-icon {
    font-size: 48px;
    color: var(--brand);
    margin-bottom: 12px;
}

.file-upload-text {
    color: var(--brand);
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.file-upload-hint {
    color: var(--text-muted);
    font-size: 12px;
}

#novoProdutoModal .modal-footer-custom {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background-color: white;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    border-radius: 0 0 var(--radius) var(--radius);
    gap: 12px;
    flex-direction: column;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.btn-confirm {
    padding: 10px 24px;
    background-color: #84cc16;
    color: white;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-confirm:hover {
    background-color: #65a30d;
}

@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}


/* ===== GRID DO MODAL DE PRODUTOS ===== */
.form-grid-produto {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
  align-items: end;
}

/* 1ª linha */
.form-grid-produto .cnp {
  grid-column: span 1; 
}

.form-grid-produto .nome {
  grid-column: span 5; 
}

/* 2ª linha */
.form-grid-produto .pvpr {
  grid-column: span 1; 
}

.form-grid-produto .preco-tanara {
  grid-column: span 1; 
}

.form-grid-produto .laboratorio {
  grid-column: span 3; 
}

.form-grid-produto .iva {
  grid-column: span 1; 
}

/* Modal Novo Produto — search dropdown + custom selects */
#novoProdutoModal .modal-search-dropdown {
  position: relative;
}

#novoProdutoModal .modal-search-dropdown-input-wrap {
  position: relative;
}

#novoProdutoModal .modal-search-dropdown-input-wrap .dropdown-search-icon-slot {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
  z-index: 1;
}

#novoProdutoModal .modal-search-dropdown-input {
  width: 100%;
  padding-left: 38px;
  box-sizing: border-box;
}

#novoProdutoModal .modal-search-dropdown-menu {
  display: none;
  position: fixed;
  z-index: 10050;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  max-height: 220px;
  overflow-y: auto;
  box-sizing: border-box;
}

#novoProdutoModal .modal-search-dropdown.open .modal-search-dropdown-menu {
  display: block;
}

#novoProdutoModal .modal-search-dropdown-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s;
}

#novoProdutoModal .modal-search-dropdown-option:hover,
#novoProdutoModal .modal-search-dropdown-option.selected {
  background: rgba(34, 188, 173, 0.1);
  color: var(--brand-dark);
}

#novoProdutoModal .modal-search-dropdown-empty {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

#novoProdutoModal .modal-search-dropdown-input.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.12);
}

#novoProdutoModal .field-error {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--danger);
  line-height: 1.4;
}

#novoProdutoModal .field-error-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--brand-dark);
  text-decoration: underline;
  cursor: pointer;
}

#novoProdutoModal .field-error-link:hover {
  color: var(--brand);
}

#gerirLaboratoriosModal.modal-stacked {
  z-index: 1010;
}

#novoProdutoModal .modal-form-dropdown {
  position: relative;
  display: block;
  width: 100%;
}

#novoProdutoModal .modal-form-dropdown .filter-dropdown-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  box-sizing: border-box;
}

#novoProdutoModal .modal-form-dropdown .filter-dropdown-btn:hover,
#novoProdutoModal .modal-form-dropdown.open .filter-dropdown-btn {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(34, 188, 173, 0.12);
}

#novoProdutoModal .modal-form-dropdown .filter-dd-chevron {
  display: inline-flex;
  color: var(--text-muted);
  line-height: 0;
}

#novoProdutoModal .modal-form-dropdown .filter-dropdown-menu {
  display: none;
  position: fixed;
  z-index: 10050;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  box-sizing: border-box;
}

#novoProdutoModal .modal-form-dropdown.open .filter-dropdown-menu {
  display: block;
}

#novoProdutoModal .modal-form-dropdown .filter-dropdown-option {
  display: flex;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}

#novoProdutoModal .modal-form-dropdown .filter-dropdown-option:hover,
#novoProdutoModal .modal-form-dropdown .filter-dropdown-option.selected {
  background: rgba(34, 188, 173, 0.1);
  color: var(--brand-dark);
  font-weight: 600;
}

/* 3ª linha */
.form-grid-produto .form-actions {
  grid-column: span 6;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
  margin-top: 8px;
}

.form-actions .btn-clear {
  grid-column: 1 / span 3; 
  justify-self: end;
	padding: 8px 12px;
    color: var(--text-muted);
    border: 1px solid var(--border);
    background-color: white;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.form-actions .btn-clear:hover {
    border-color: var(--text);
    color: var(--text);
}

.form-actions .btn-confirm {
  grid-column: 4 / span 3; 
  justify-self: start;
}

.btn-clear, .btn-confirm {
  width: 100%;
}

/* Responsividade */
@media (max-width: 640px) {
  .form-grid-produto {
    grid-template-columns: 1fr;
  }

  .form-actions {
    grid-template-columns: 1fr;
  }

  .btn-clear, .btn-confirm {
    grid-column: auto;
    justify-self: stretch;
  }
}

.template-btn-wrapper {
    margin-left: auto;
    margin-right: 16px;
}

/* =================================================================
 * 11. ESTILOS ESPECÍFICOS DO MODAL PRODUTOS INTERNOS (NOVO)
 * Deve ser idêntico ao #novoProdutoModal
 * ================================================================= */

#novoProdutoInternoModal .modal-content {
    /* Define uma altura máxima maior e permite a rolagem no contentor principal */
    max-height: 95vh;
    overflow-y: auto;
    /* Inclua também as propriedades de largura e layout, se não estiverem definidas: */
    width: 95%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
transition: max-height 0.3s ease-out;
}

/* 2. Regra que força o crescimento quando a classe 'expanded-lab' está ativa */
#novoProdutoInternoModal .modal-content.expanded-lab .modal-body-custom {
    /* Aumenta o padding inferior em 220px (Altura do dropdown + margem de segurança) */
    /* Original: 32px | Novo: 32px + 220px = 252px */
    padding-bottom: 200px; 
}

#novoProdutoInternoModal .modal-body-custom {
    padding: 32px; /* Espaçamento interno */
    background-color: #f9fafb; /* Fundo mais claro */
    transition: padding-bottom 0.3s ease-out; 
}

#novoProdutoInternoModal .modal-content.expanded-lab {
    /* Aumenta a altura máxima em cerca de 220px para acomodar o dropdown de 200px */
    max-height: calc(95vh + 220px); 
	transition: max-height 0.3s ease-out;
    /* Nota: Se o modal já for muito pequeno, pode ser necessário usar 'height' 
       mas 'max-height' é mais seguro para responsividade. */
}

/* Estilos para o botão de fechar (X) no modal de PRODUTOS INTERNOS (para igualar a estética) */
#novoProdutoInternoModal .modal-close {
    padding: 8px 12px;
    border: 1px solid var(--border);
    background-color: white;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 18px;
    color: var(--text-muted);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: 36px;
    line-height: 1;
    font-weight: normal;
}

#novoProdutoInternoModal .modal-close:hover {
    background-color: #f9fafb;
    border-color: var(--brand);
    color: var(--brand);
}
#novoProdutoInternoModal .modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
    padding: 20px 0; 
}

/* Lab filter dropdown (same pattern as promocoes.php) */
.product-list .filter-dropdown {
    position: relative;
    display: inline-flex;
}

.product-list .filter-dropdown-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 12px;
    cursor: pointer;
    color: var(--text);
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.product-list .filter-dropdown-btn:hover,
.product-list .filter-dropdown.open .filter-dropdown-btn {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(34, 188, 173, 0.1);
}

.product-list .filter-dropdown-btn.filter-active {
    border-color: var(--brand);
    color: var(--brand-dark);
    background: rgba(34, 188, 173, 0.05);
}

.product-list .filter-dropdown-btn .filter-dd-icon,
.product-list .filter-dropdown-btn .filter-dd-chevron {
    display: inline-flex;
    color: var(--text-muted);
    flex-shrink: 0;
    line-height: 0;
}

.product-list .filter-dropdown-btn.filter-active .filter-dd-icon,
.product-list .filter-dropdown-btn.filter-active .filter-dd-chevron {
    color: var(--brand);
}

.product-list .filter-dropdown-btn .filter-dd-label {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-list .filter-dropdown-menu {
    display: none;
    position: fixed;
    z-index: 10001;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    min-width: 160px;
    max-height: 320px;
    overflow: hidden;
    flex-direction: column;
}

.product-list .filter-dropdown.open .filter-dropdown-menu {
    display: flex;
}

.product-list .filter-dropdown-menu-wide {
    min-width: 260px;
    max-width: 320px;
}

.product-list .filter-dropdown-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    border: none;
    background: none;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    transition: background 0.12s;
}

.product-list .filter-dropdown-option:hover {
    background: #f3f4f6;
}

.product-list .filter-dropdown-option.selected {
    background: rgba(34, 188, 173, 0.1);
    color: var(--brand-dark);
    font-weight: 600;
}

.product-list #dropdownItemsPerPage .filter-dropdown-menu {
    min-width: 160px;
}

.product-list #dropdownItemsPerPage .filter-dd-label {
    max-width: none;
}

.product-list .filter-dropdown-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px 8px;
    border-bottom: 1px solid var(--border);
}

.product-list .filter-dropdown-panel-header .dropdown-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.product-list .filter-dropdown-panel-header .dropdown-clear {
    font-size: 12px;
    color: var(--brand);
    cursor: pointer;
    font-weight: 600;
}

.product-list .filter-dropdown-menu .dropdown-search-wrap {
    position: relative;
    margin: 10px 12px;
}

.product-list .filter-dropdown-menu .dropdown-search-icon-slot {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
}

.product-list .filter-dropdown-menu .dropdown-search-input {
    width: 100%;
    padding: 8px 10px 8px 34px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
}

.product-list .filter-dropdown-menu .dropdown-search-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(34, 188, 173, 0.12);
}

.product-list .filter-dropdown-scroll {
    overflow-y: auto;
    max-height: 220px;
    padding: 0 6px 8px;
}

.product-list .lab-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.product-list .lab-option:hover {
    background: #f3f4f6;
}

.product-list .lab-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: var(--brand);
}

.product-list .lab-option .lab-opt-icon {
    display: inline-flex;
    color: var(--text-muted);
    flex-shrink: 0;
    line-height: 0;
}

.product-list .lab-option.hidden-by-search {
    display: none !important;
}

.product-list .dropdown-no-results {
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    display: none;
}

.product-list .dropdown-no-results.visible {
    display: block;
}

.time-filter-btn .dropdown-arrow.ui-icon-inline {
    margin-left: 2px;
    color: #6b7280;
}

.time-filter-dropdown.active .dropdown-arrow svg {
    transform: rotate(180deg);
}

/* Admin panel — custom select dropdowns (usuarios-gestao.php) */
.page-admin .admin-select-dropdown {
    position: relative;
    display: block;
    width: 100%;
}

.page-admin .admin-select-dropdown.admin-select-compact {
    min-width: 120px;
}

.page-admin .admin-select-dropdown .filter-dropdown-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.page-admin .admin-select-dropdown .filter-dropdown-btn:hover,
.page-admin .admin-select-dropdown.open .filter-dropdown-btn {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(34, 188, 173, 0.1);
}

.page-admin .admin-select-dropdown .filter-dd-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
    flex: 1;
    min-width: 0;
}

.page-admin .admin-select-dropdown .filter-dd-chevron {
    display: inline-flex;
    color: var(--text-muted);
    flex-shrink: 0;
    line-height: 0;
}

.page-admin .admin-select-dropdown .filter-dropdown-menu {
    display: none;
    position: fixed;
    z-index: 10001;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    min-width: 160px;
    max-height: 320px;
    overflow: hidden;
    flex-direction: column;
}

.page-admin .admin-select-dropdown.open .filter-dropdown-menu {
    display: flex;
}

.page-admin .admin-select-dropdown .filter-dropdown-menu-wide {
    min-width: 280px;
    max-width: 360px;
}

.page-admin .admin-select-dropdown .filter-dropdown-scroll {
    overflow-y: auto;
    max-height: 260px;
    padding: 0;
}

.page-admin .admin-select-dropdown .filter-dropdown-option {
    display: flex;
    align-items: center;
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    border: none;
    background: none;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    transition: background 0.12s;
}

.page-admin .admin-select-dropdown .filter-dropdown-option:hover {
    background: #f3f4f6;
}

.page-admin .admin-select-dropdown .filter-dropdown-option.selected {
    background: rgba(34, 188, 173, 0.1);
    color: var(--brand-dark);
    font-weight: 600;
}

.page-admin .admin-select-dropdown .dropdown-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

.page-admin .admin-select-dropdown .dropdown-search-icon-slot {
    display: inline-flex;
    color: var(--text-muted);
    line-height: 0;
    flex-shrink: 0;
}

.page-admin .admin-select-dropdown .dropdown-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    font-family: var(--font);
    background: transparent;
    color: var(--text);
}

.page-admin .admin-select-dropdown .filter-dropdown-option.hidden-by-search {
    display: none !important;
}

.page-admin .usuarios-table td.tipo-cell {
    padding: 8px 10px;
    vertical-align: middle;
}

.page-admin .usuarios-table td.tipo-cell .admin-select-dropdown {
    display: block;
    width: 100%;
    min-width: 0;
}

.page-admin .usuarios-table td.tipo-cell .admin-select-compact .filter-dropdown-btn {
    width: 100%;
    height: 34px;
    font-size: 13px;
    padding: 0 12px;
    box-sizing: border-box;
}

.page-admin .emails-table .admin-select-compact .filter-dropdown-btn {
    height: 34px;
    font-size: 13px;
}
