/* ==========================================================
   Kraton ERP — ajustes visuais sobre o tema CoreUI
   ========================================================== */

/* ==========================================================
   IDENTIDADE DE COR (substitui o roxo padrão pelo vermelho Kraton)
   Respeita os modos: claro, escuro e auto.
   ========================================================== */

/* --- Variáveis de cor primária (tema CLARO / padrão) --- */
:root,
[data-coreui-theme="light"] {
    --cui-primary: #d42a2a;
    --cui-primary-rgb: 212, 42, 42;
    --cui-primary-text-emphasis: #7f1919;
    --cui-primary-bg-subtle: #fbe0e0;
    --cui-primary-border-subtle: #f0adad;

    --cui-link-color: #d42a2a;
    --cui-link-color-rgb: 212, 42, 42;
    --cui-link-hover-color: #9e1e1e;
    --cui-link-hover-color-rgb: 158, 30, 30;
}

/* --- Variáveis de cor primária (tema ESCURO) --- */
[data-coreui-theme="dark"] {
    --cui-primary: #e84545;
    --cui-primary-rgb: 232, 69, 69;
    --cui-primary-text-emphasis: #f2a6a6;
    --cui-primary-bg-subtle: #3d1414;
    --cui-primary-border-subtle: #7d2a2a;

    --cui-link-color: #ef6a6a;
    --cui-link-color-rgb: 239, 106, 106;
    --cui-link-hover-color: #f28e8e;
    --cui-link-hover-color-rgb: 242, 142, 142;
}

/* --- Botão primário (valores fixos no CoreUI → precisam ser sobrescritos) --- */
.btn-primary {
    --cui-btn-bg: #d42a2a;
    --cui-btn-border-color: #d42a2a;
    --cui-btn-hover-bg: #b22222;
    --cui-btn-hover-border-color: #a72020;
    --cui-btn-active-bg: #9e1e1e;
    --cui-btn-active-border-color: #941c1c;
    --cui-btn-disabled-bg: #d42a2a;
    --cui-btn-disabled-border-color: #d42a2a;
    --cui-btn-focus-shadow-rgb: 212, 42, 42;
}
[data-coreui-theme="dark"] .btn-primary {
    --cui-btn-bg: #e84545;
    --cui-btn-border-color: #e84545;
    --cui-btn-hover-bg: #d23a3a;
    --cui-btn-hover-border-color: #c43535;
    --cui-btn-active-bg: #c43535;
    --cui-btn-active-border-color: #b83131;
    --cui-btn-disabled-bg: #e84545;
    --cui-btn-disabled-border-color: #e84545;
    --cui-btn-focus-shadow-rgb: 232, 69, 69;
}

/* --- Botão outline-primary --- */
.btn-outline-primary {
    --cui-btn-color: #d42a2a;
    --cui-btn-border-color: #d42a2a;
    --cui-btn-hover-bg: #d42a2a;
    --cui-btn-hover-border-color: #d42a2a;
    --cui-btn-active-bg: #d42a2a;
    --cui-btn-active-border-color: #d42a2a;
    --cui-btn-focus-shadow-rgb: 212, 42, 42;
}
[data-coreui-theme="dark"] .btn-outline-primary {
    --cui-btn-color: #ef6a6a;
    --cui-btn-border-color: #e84545;
    --cui-btn-hover-bg: #e84545;
    --cui-btn-hover-border-color: #e84545;
    --cui-btn-active-bg: #e84545;
    --cui-btn-active-border-color: #e84545;
    --cui-btn-focus-shadow-rgb: 232, 69, 69;
}

/* --- Foco de inputs/checkboxes na cor da marca --- */
.form-control:focus,
.form-select:focus {
    border-color: #e1a3a3;
    box-shadow: 0 0 0 .25rem rgba(212, 42, 42, .25);
}
.form-check-input:checked {
    background-color: #d42a2a;
    border-color: #d42a2a;
}
.form-check-input:focus {
    border-color: #e1a3a3;
    box-shadow: 0 0 0 .25rem rgba(212, 42, 42, .25);
}
[data-coreui-theme="dark"] .form-check-input:checked {
    background-color: #e84545;
    border-color: #e84545;
}

/* --- Abas ativas (formulário de peças) na cor da marca --- */
.nav-tabs .nav-link.active {
    color: #d42a2a;
}
[data-coreui-theme="dark"] .nav-tabs .nav-link.active {
    color: #ef6a6a;
}

/* Marca / logo na sidebar */
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    text-decoration: none;
    color: #fff;
}
.sidebar-brand:hover { color: #fff; }
.sidebar-brand-full .text-danger { color: #e84545 !important; }

/* Marca expandida: emblema + wordmark (flex via CSS, sem utilitário do Bootstrap
   para não gerar display:flex !important, que impediria ocultar no modo estreito) */
.sidebar-brand-full {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.sidebar-brand-narrow { display: none; }

/* Modo minimizado: mostra APENAS o emblema da Kraton, centralizado */
.sidebar-narrow .sidebar-brand-full,
.sidebar-narrow-unfoldable:not(:hover) .sidebar-brand-full { display: none; }
.sidebar-narrow .sidebar-brand-narrow,
.sidebar-narrow-unfoldable:not(:hover) .sidebar-brand-narrow {
    display: block;
    margin: 0 auto;
}

/* ---- Distinção visual entre MENU (grupo) e SUBMENU (itens) ---- */

/* Cabeçalho do grupo: destacado, como um título de seção */
.sidebar-nav .nav-group > .nav-group-toggle {
    font-weight: 600;
    letter-spacing: .02em;
    color: rgba(255, 255, 255, .85);
}
.sidebar-nav .nav-group > .nav-group-toggle .nav-icon {
    color: #e84545;   /* ícone do grupo em vermelho Kraton */
}

/* Itens do submenu: recuados e com uma linha-guia à esquerda.
   Obs.: NÃO alteramos o padding-inline-start do .nav-link (o CoreUI o usa
   junto com a margem negativa do .nav-icon para posicionar o ícone). */
.sidebar-nav .nav-group-items {
    position: relative;
    margin-left: 1.15rem;
    border-left: 1px solid rgba(255, 255, 255, .12);
}
.sidebar-nav .nav-group-items .nav-link {
    font-size: .925rem;
    color: rgba(255, 255, 255, .68);
}
.sidebar-nav .nav-group-items .nav-link:hover {
    color: #fff;
}
.sidebar-nav .nav-group-items .nav-link.active {
    color: #fff;
    font-weight: 600;
}
/* Marcador do item ativo do submenu sobre a linha-guia */
.sidebar-nav .nav-group-items .nav-link.active::before {
    content: "";
    position: absolute;
    left: -1px;
    width: 2px;
    height: 1.25rem;
    margin-top: .15rem;
    background: #e84545;
    border-radius: 2px;
}

/* Ícones dos itens filhos (submenus): visíveis e levemente suavizados */
.sidebar-nav .nav-group-items .nav-icon {
    opacity: .9;
}

/* Quando a sidebar está minimizada, esconde a linha-guia/recuo */
.sidebar-narrow .nav-group-items,
.sidebar-narrow-unfoldable:not(:hover) .nav-group-items {
    margin-left: 0;
    border-left: 0;
}

/* ---- Botões de ação (ícone + texto) ---- */
.btn .icon { vertical-align: -.125em; }
.btn-sm .icon { width: 1rem; height: 1rem; }

/* Espaço entre botões de ação nas tabelas */
td .btn + form, td form + .btn, td .btn + .btn, td form + form { margin-left: .35rem; }

/* Cor primária alinhada à identidade Kraton (vermelho) nos destaques sutis */
.breadcrumb-item.active span { font-weight: 600; }

/* ---- Árvore de categorias / subcategorias ---- */
.kt-tree-node + .kt-tree-node {
    border-top: 1px solid var(--cui-border-color, rgba(0, 0, 0, .1));
}
.kt-tree-children {
    position: relative;
    margin-left: 6px;
    padding-left: 1.25rem;
    border-left: 1px solid var(--cui-border-color, rgba(0, 0, 0, .12));
}
.kt-tree-leaf {
    position: relative;
}
/* Conector horizontal ligando a linha-guia a cada subcategoria */
.kt-tree-leaf::before {
    content: "";
    position: absolute;
    left: -1.25rem;
    top: 50%;
    width: 1rem;
    height: 1px;
    background: var(--cui-border-color, rgba(0, 0, 0, .12));
}
/* Marcador circular de cor */
.kt-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 auto;
    border: 1px solid rgba(0, 0, 0, .15);
}
.kt-dot-sm {
    width: 12px;
    height: 12px;
}

/* ---- Paleta de cores-padrão (categoria) ---- */
.kt-palette {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}
.kt-swatch {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid transparent;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .1) inset;
    cursor: pointer;
    padding: 0;
    transition: transform .1s ease;
}
.kt-swatch:hover { transform: scale(1.1); }
.kt-swatch.active {
    border-color: var(--cui-body-color, #333);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, .15);
}
/* Cor já em uso: risco diagonal + desabilitada */
.kt-swatch.disabled,
.kt-tone.disabled .kt-tone-swatch {
    opacity: .45;
    cursor: not-allowed;
    background-image: linear-gradient(45deg, transparent 44%, rgba(0,0,0,.55) 45%, rgba(0,0,0,.55) 55%, transparent 56%);
}
.kt-swatch.disabled:hover,
.kt-tone.disabled:hover .kt-tone-swatch { transform: none; }
.kt-tone.disabled { cursor: not-allowed; }

/* ---- Seletor de tonalidade (subcategoria) ---- */
.kt-tones {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
}
.kt-tone {
    cursor: pointer;
    margin: 0;
    line-height: 0;
}
.kt-tone input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.kt-tone-swatch {
    display: inline-block;
    width: 34px;
    height: 26px;
    border-radius: 6px;
    border: 2px solid transparent;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .1) inset;
    transition: transform .1s ease;
}
.kt-tone:hover .kt-tone-swatch { transform: scale(1.08); }
.kt-tone input:checked + .kt-tone-swatch {
    border-color: var(--cui-body-color, #333);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, .2);
}

/* ---- Tela de carregamento (tela cheia, identidade Kraton) ---- */
.kt-loading {
    position: fixed;
    inset: 0;
    z-index: 2000;                 /* acima de tudo, inclusive modais e FAB */
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    /* Tela cheia opaca com a identidade Kraton (igual ao painel do login) */
    background:
        radial-gradient(1000px 600px at 50% 30%, rgba(212, 42, 42, .28), transparent 60%),
        linear-gradient(160deg, #23272f 0%, #14161b 55%, #0c0d11 100%);
}
.kt-loading.show { display: flex; }
.kt-spinner-wrap {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.kt-loading-logo { width: 62px; height: 62px; object-fit: contain; }
.kt-spinner {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 6px solid rgba(255, 255, 255, .15);
    border-top-color: #e84545;     /* vermelho Kraton */
    animation: kt-spin .8s linear infinite;
}
@keyframes kt-spin { to { transform: rotate(360deg); } }
.kt-loading-wordmark {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: .04em;
}
.kt-loading-wordmark span { color: #e84545; }
.kt-loading-text {
    color: rgba(255, 255, 255, .7);
    font-weight: 500;
    letter-spacing: .02em;
}

/* ---- DataTable (ordenação, filtros, colunas) ---- */
.kt-datatable th.kt-sortable {
    user-select: none;
    white-space: nowrap;
}
.kt-datatable th.kt-sortable::after {
    content: "";
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: .4rem;
    vertical-align: middle;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    opacity: .25;
    border-top: 5px solid currentColor;
}
.kt-datatable th.kt-sort-asc::after {
    border-top: 0;
    border-bottom: 5px solid currentColor;
    opacity: .9;
}
.kt-datatable th.kt-sort-desc::after {
    opacity: .9;
}
.kt-datatable .kt-filter-row th {
    padding: .25rem .5rem .5rem;
    background: var(--cui-tertiary-bg, #f8f9fa);
}
[data-kt-filter-toggle].active {
    background: var(--cui-secondary-bg, #e9ecef);
}
.kt-datatable [data-kt-columns] .dropdown-item { cursor: pointer; }
.kt-datatable [data-kt-columns] .dropdown-item:active { color: inherit; background: var(--cui-tertiary-bg, #f1f3f5); }

/* ---- Botão flutuante do WhatsApp (FAB expansível) ---- */
.kt-whatsapp-fab {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 1030;
    height: 64px;
    display: inline-flex;
    align-items: center;
    background: #25d366;
    color: #fff;
    border-radius: 999px;
    text-decoration: none;
    box-shadow: 0 6px 20px rgba(37, 211, 102, .45);
    overflow: hidden;
    transition: box-shadow .2s ease, transform .2s ease;
}
.kt-whatsapp-fab:hover,
.kt-whatsapp-fab:focus {
    color: #fff;
    box-shadow: 0 10px 26px rgba(37, 211, 102, .6);
    transform: translateY(-2px);
}
/* Núcleo circular com o ícone (sempre visível) */
.kt-whatsapp-fab .kt-wa-icon {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.kt-whatsapp-fab .kt-wa-icon svg.icon {
    width: 36px;
    height: 36px;
}
/* Rótulo que aparece ao passar o mouse */
.kt-whatsapp-fab .kt-wa-label {
    max-width: 0;
    opacity: 0;
    white-space: nowrap;
    font-weight: 700;
    font-size: 1rem;
    padding-right: 0;
    transition: max-width .3s ease, opacity .2s ease, padding-right .3s ease;
}
.kt-whatsapp-fab:hover .kt-wa-label,
.kt-whatsapp-fab:focus .kt-wa-label {
    max-width: 200px;
    opacity: 1;
    padding-right: 1.4rem;
}
/* Anel pulsante (só enquanto está recolhido) */
.kt-whatsapp-fab::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    animation: kt-wa-pulse 2.2s ease-out infinite;
    pointer-events: none;
}
.kt-whatsapp-fab:hover::after { animation: none; }
@keyframes kt-wa-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(37, 211, 102, .5); }
    70%  { box-shadow: 0 0 0 16px rgba(37, 211, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}
@media (max-width: 575.98px) {
    .kt-whatsapp-fab { right: 1rem; bottom: 1rem; height: 56px; }
    .kt-whatsapp-fab .kt-wa-icon { flex-basis: 56px; width: 56px; height: 56px; }
    .kt-whatsapp-fab .kt-wa-icon svg { width: 46px; height: 46px; }
    .kt-whatsapp-fab::after { width: 56px; height: 56px; }
}

/* ============ Galeria de fotos + lightbox com zoom ============ */
.kt-galeria { display: flex; flex-wrap: wrap; gap: .5rem; }
.kt-galeria-thumb {
    width: 96px; height: 96px; object-fit: cover; border-radius: .5rem;
    border: 1px solid var(--cui-border-color, #d8dbe0); background: #fff;
    transition: transform .12s ease, box-shadow .12s ease;
}
.kt-galeria-thumb:hover { transform: translateY(-2px); box-shadow: 0 .35rem .9rem rgba(0,0,0,.18); }
.kt-galeria-principal .kt-galeria-thumb { width: 180px; height: 180px; }

body.kt-lb-travado { overflow: hidden; }
.kt-lightbox {
    position: fixed; inset: 0; z-index: 2000; display: none;
    background: rgba(15, 18, 22, .92); backdrop-filter: blur(2px);
    align-items: center; justify-content: center;
}
.kt-lightbox.aberto { display: flex; }
.kt-lb-barra {
    position: absolute; top: 0; left: 0; right: 0; z-index: 3;
    display: flex; align-items: center; justify-content: space-between;
    padding: .75rem 1rem; color: #fff;
}
.kt-lb-contador { font-size: .9rem; opacity: .9; }
.kt-lb-acoes { display: inline-flex; gap: .4rem; }
.kt-lb-btn {
    width: 38px; height: 38px; border: 0; border-radius: .5rem;
    background: rgba(255,255,255,.14); color: #fff; font-size: 1.1rem; cursor: pointer;
    line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.kt-lb-btn:hover { background: rgba(255,255,255,.28); }
.kt-lb-nav {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
    width: 48px; height: 64px; border: 0; border-radius: .5rem;
    background: rgba(255,255,255,.12); color: #fff; font-size: 2rem; cursor: pointer;
}
.kt-lb-nav:hover { background: rgba(255,255,255,.26); }
.kt-lb-prev { left: 1rem; }
.kt-lb-next { right: 1rem; }
.kt-lb-palco {
    width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
    overflow: hidden; padding: 3.5rem 1rem 1rem;
}
.kt-lb-img {
    max-width: 92vw; max-height: 84vh; object-fit: contain;
    transform-origin: center center; user-select: none; -webkit-user-drag: none;
    transition: transform .06s linear;
}
.kt-lb-img.arrastando { cursor: grabbing !important; transition: none; }
@media (max-width: 575.98px) {
    .kt-lb-nav { width: 40px; height: 52px; font-size: 1.6rem; }
    .kt-galeria-principal .kt-galeria-thumb { width: 140px; height: 140px; }
}
