/* =========================================================
   TABELA CMIs
========================================================= */

/*
 * Botão de criação original do cmi.css do Faci·lite.
 * A gestão de Agências reutiliza esta mesma classe no Core.
 */
.cmi-new-button {
    display: flex;
    align-items: center;
    justify-content: center;

    min-height: 44px;
    padding: 0 24px;

    background: #FF7A00;
    color: #FFFFFF !important;
    border-radius: 14px;

    text-decoration: none !important;
    font-weight: 600;

    transition: all .2s ease;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .12);
}

.cmi-new-button:hover {
    background: #00205B;
}

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

.cmis-table-modern {
    width: 100%;
    table-layout: auto;
    border-collapse: collapse;
    background: #FFFFFF;
    border: 1px solid #e5e7eb;
}

.cmis-table-modern th,
.cmis-table-modern td {
    border: 1px solid #e5e7eb;
    vertical-align: middle;
    padding: 9px 8px;
}

.cmis-table-modern th {
    color: #00205B;
    background: #FFFFFF;
    white-space: nowrap;
}

.cmis-table-modern td {
    color: inherit;
}

.cmis-table-modern tbody tr:hover {
    background: #F5F7FA;
}

.cmis-table-modern tbody tr {
    position: relative;
}

.cmis-table-modern tbody tr:hover {
    z-index: 10;
}

/*
 * Nos filtros históricos, os estados de preenchimento já não são úteis.
 * Mantêm-se disponíveis nas restantes vistas do dashboard.
 */
.cmis-dashboard.cmis-filtro-historico .cmis-table-modern .cmi-col-cliente,
.cmis-dashboard.cmis-filtro-historico .cmis-table-modern .cmi-col-consultor-estado,
.cmis-dashboard.cmis-filtro-historico .cmis-table-modern .cmi-col-cmi,
.cmis-dashboard.cmis-filtro-historico .cmi-card-estados {
    display: none;
}

.cmis-table-modern th:nth-child(2),
.cmis-table-modern td:nth-child(2),
.cmis-table-modern th:nth-child(3),
.cmis-table-modern td:nth-child(3),
.cmis-table-modern th:nth-child(4),
.cmis-table-modern td:nth-child(4),
.cmis-table-modern th:nth-child(5),
.cmis-table-modern td:nth-child(5),
.cmis-table-modern th:nth-child(7),
.cmis-table-modern td:nth-child(7),
.cmis-table-modern th:nth-child(8),
.cmis-table-modern td:nth-child(8) {
    text-align: center;
}
	
.cmi-col-data,
.cmi-col-edicao,
.cmi-col-editor,
.cmi-col-numero,
.cmi-col-agencia,
.cmi-col-consultor,
.cmi-col-acoes {
    white-space: nowrap;
}

/* CMI — corrigir ID da Angariação */

.cmi-col-numero,
.cmi-card-numero {
    position: relative;
}

.cmi-acquisition-id-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 20px;
    height: 20px;
    margin-left: 5px;
    padding: 0;

    border: 0;
    background: transparent;

    color: #00205B;
    font-size: 18px;
    line-height: 1;

    cursor: pointer;
    vertical-align: middle;

    transition: color .15s ease, opacity .15s ease;
}

/* Desktop — aparece apenas ao passar pela célula Nº */
.cmis-desktop-view .cmi-acquisition-id-edit {
    opacity: 0;
}

.cmis-desktop-view .cmi-col-numero:hover .cmi-acquisition-id-edit,
.cmis-desktop-view .cmi-acquisition-id-edit:focus {
    opacity: 1;
}

.cmi-acquisition-id-edit:hover {
    color: #FF7A00;
}

/* Mobile — fica sempre visível */
.cmis-mobile-view .cmi-acquisition-id-edit {
    opacity: 1;
}

.cmi-col-nome {
    min-width: 160px;
}

.cmi-col-acoes {
    width: 130px;
    text-align: center;
}

/*
 * Os temas podem aplicar padding/min-width genéricos a todos os botões.
 * Nesta tabela, cada ação deve ocupar apenas o quadrado do respetivo ícone.
 */
.cmis-table-modern td.cmi-col-acoes .cmi-action-icon {
    display: inline-flex !important;
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    margin: 0 2px !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* =========================================================
   BADGES / ESTADOS
   Copiado do cmi.css do Faci·lite.
========================================================= */

.cmi-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 11px;
    border-radius: 999px;
    background: #F5F7FA;
    color: #6B7280;
}

.cmi-status-badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #6B7280;
}

.cmi-status-rascunho {
    background: #fff7ed;
    color: #FF7A00;
}

.cmi-status-rascunho::before {
    background: #FF7A00;
}

.cmi-status-finalizado {
    background: #ecfdf5;
    color: #22C55E;
}

.cmi-status-finalizado::before {
    background: #22C55E;
}

.cmi-status-anulado {
    background: #fef2f2;
    color: #EF4444;
}

.cmi-status-anulado::before {
    background: #EF4444;
}

/* =========================================================
   ÍCONES DE AÇÃO
   Copiado do cmi.css do Faci·lite.
========================================================= */

/*
 * O Faci·lite usa as classes oficiais do Font Awesome no HTML. A tipografia
 * global da plataforma não pode ser herdada pelos elementos que representam
 * esses ícones.
 */
i.fa-solid,
i.fas {
    font-family: "Font Awesome 6 Free" !important;
    font-style: normal;
    font-weight: 900 !important;
}

i.fa-regular,
i.far {
    font-family: "Font Awesome 6 Free" !important;
    font-style: normal;
    font-weight: 400 !important;
}

.cmi-action-icon {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    box-sizing: border-box;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 2px;
    color: #00205B !important;
    font-size: 20px;
    text-decoration: none !important;
    vertical-align: middle;
    transition: .2s ease;
    cursor: pointer;
}

.cmi-action-icon:hover {
    color: #FF7A00 !important;
    background: transparent !important;
    transform: scale(1.08);
}

.cmi-actions-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: max-content;
    max-width: 100%;
    margin: 0 auto;
    white-space: nowrap;
}

.cmis-table-modern td.cmi-col-acoes .cmi-actions-row .cmi-action-icon {
    flex: 0 0 38px;
    margin: 0 !important;
}

.cmis-table-modern td.cmi-col-acoes .cmi-docs-menu {
    display: inline-flex;
    flex: 0 0 38px;
}

/*
 * Desktop — a tabela deve ocupar exatamente a largura do contentor do CMI.
 * O deslocamento horizontal fica reservado para ecrãs pequenos.
 */
@media (min-width: 1025px) {
    .cmis-toolbar {
        width: 100%;
        max-width: 100%;
        grid-template-columns: minmax(0, 1fr) minmax(0, 300px) !important;
        min-width: 0;
        box-sizing: border-box;
    }

    .cmis-toolbar > *,
    .cmis-toolbar-side,
    .cmis-toolbar-side .cmi-new-button,
    .cmis-toolbar-side .cmi-cmis-search {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    .cmis-toolbar-side {
        width: 300px !important;
        min-width: 0 !important;
        max-width: 300px !important;
        justify-self: end;
        box-sizing: border-box;
    }

    .cmis-toolbar-side .cmi-new-button,
    .cmis-toolbar-side .cmi-cmis-search {
        width: 100% !important;
        max-width: 300px !important;
        box-sizing: border-box;
    }

    .cmis-dashboard,
    .cmis-toolbar,
    .cmis-desktop-view,
    .cmis-table-wrap {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    .cmis-table-wrap {
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
    }

    .cmis-table-modern {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
        table-layout: auto;
    }

    .cmis-table-modern th,
    .cmis-table-modern td {
        box-sizing: border-box;
    }

    /* Neutraliza percentagens herdadas: o browser calcula cada coluna. */
    .cmis-table-modern th:nth-child(n),
    .cmis-table-modern td:nth-child(n) {
        width: auto;
    }

    .cmis-table-modern .cmi-col-nome {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .cmis-table-modern th.cmi-col-acoes,
    .cmis-table-modern td.cmi-col-acoes {
        width: 340px !important;
        min-width: 340px !important;
        max-width: 340px !important;
        overflow: visible;
        white-space: nowrap;
    }

    .cmis-table-modern th.cmi-col-acoes .cmi-actions-row,
    .cmis-table-modern td.cmi-col-acoes .cmi-actions-row {
        width: 100%;
        max-width: 100%;
        justify-content: center;
    }

    .cmis-table-modern td.cmi-col-acoes .cmi-docs-dropdown {
        font-size: 14px;
    }

    .cmis-table-modern td.cmi-col-acoes .cmi-action-icon {
        font-size: 20px;
    }
}

