﻿/* Extraído de html/layouts/navbar.html (antes era <style> inline no CORPO, depois da marcação: o navegador pintava a
   tela sem estes estilos por alguns instantes — "distorção" ao navegar). Agora vai no <head>. */

/* ==========================================
   NAVBAR PREMIUM - TOP DE MERCADO
   ========================================== */

.navbar-premium {
    position: fixed;
    top: 0;
    left: 260px;   /* começa após o sidebar — painel unificado */
    right: 0;
    height: 60px;
    background: var(--navbar-bg);
    border-bottom: 1px solid var(--navbar-border);
    z-index: 1001;
    /* sem backdrop-filter: blur recalculado a cada frame de rolagem sobre cards/gráficos SVG (jank no dashboard) */
    transition: left 0.26s cubic-bezier(0.4, 0, 0.2, 1),
                background-color 0.3s ease,
                border-color 0.3s ease;
}

body.sidebar-collapsed .navbar-premium { left: 60px; }

@media (max-width: 991px) {
    .navbar-premium { left: 0 !important; }
}

.navbar-container {
    height: 100%;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

/* ==========================================
   LEFT SECTION — largura espelha o sidebar
   ========================================== */

.navbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.sidebar-toggle-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s, transform 0.15s;
}

.sidebar-toggle-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

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

.navbar-logo {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.125rem;
}

.navbar-lockup { height: 26px; width: auto; display: block; }
.navbar-lockup--dark { display: none; }
.dark-mode .navbar-lockup--light { display: none; }
.dark-mode .navbar-lockup--dark  { display: block; }

/* ==========================================
   BREADCRUMBS
   ========================================== */

.breadcrumb-nav {
    display: none;
}

.breadcrumb-list {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
}

.breadcrumb-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.breadcrumb-link:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.breadcrumb-item.active span {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.875rem;
}

.breadcrumb-separator {
    color: var(--text-tertiary);
    font-size: 0.75rem;
}

/* Visível em qualquer largura de tela — em mobile colapsa para mostrar
   só a filial (a informação mais importante: "onde estou agora"), já que
   o breadcrumb some e sobra espaço ao lado do logo mobile. */
.navbar-context-chip {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: 0.5rem;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.18);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    max-width: 320px;
    overflow: hidden;
    min-width: 0;
}

.navbar-context-chip .ctx-group {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.navbar-context-chip i {
    font-size: 0.75rem;
    color: #6366f1;
    flex-shrink: 0;
}

.navbar-context-chip .ctx-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 130px;
}

.navbar-context-chip .ctx-sep {
    color: var(--text-tertiary);
    font-weight: 400;
    flex-shrink: 0;
}

@media (min-width: 992px) {
    .breadcrumb-nav {
        display: block;
    }
}

@media (max-width: 1199px) {
    .navbar-context-chip .ctx-value {
        max-width: 90px;
    }
}

/* Mobile: se houver filial, mostra só ela (esconde empresa + separador) */
@media (max-width: 991px) {
    .navbar-context-chip:has(.ctx-filial) .ctx-empresa,
    .navbar-context-chip:has(.ctx-filial) .ctx-sep {
        display: none;
    }

    .navbar-context-chip {
        margin-left: 0.4rem;
        padding: 0.25rem 0.55rem;
    }

    .navbar-context-chip .ctx-value {
        max-width: 110px;
    }
}

/* Telas muito pequenas: chip vira só o ícone (nome ainda acessível no
   dropdown do usuário, que já lista Empresa/Filial com rótulo) */
@media (max-width: 420px) {
    .navbar-context-chip .ctx-value {
        display: none;
    }
}

/* ==========================================
   CENTER SECTION - SEARCH
   ========================================== */

.navbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    max-width: 600px;
}

.search-container {
    width: 100%;
    max-width: 500px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 0.875rem;
    color: var(--text-tertiary);
    font-size: 1rem;
}

.search-input {
    width: 100%;
    height: 38px;
    padding: 0 3.5rem 0 2.75rem;
    border: 1px solid var(--input-border);
    border-radius: 10px;
    background: var(--input-bg);
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: all 0.2s;
}

.search-input::placeholder {
    color: var(--text-tertiary);
}

.search-input:focus {
    outline: none;
    background: var(--bg-surface);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-kbd {
    position: absolute;
    right: 0.625rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: monospace;
    box-shadow: var(--shadow-sm);
}

@media (max-width: 991px) {
    .navbar-center {
        display: none;
    }
}

/* ==========================================
   SEARCH DROPDOWN
   ========================================== */

.search-container {
    position: relative;
}

.search-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 520px;
    max-width: calc(100vw - 2rem);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,.18), 0 4px 16px rgba(0,0,0,.1);
    z-index: 2000;
    overflow: hidden;
    animation: searchFadeIn .15s ease;
}

.search-dropdown.open { display: flex; flex-direction: column; }

@keyframes searchFadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#searchResults {
    overflow-y: auto;
    max-height: 380px;
    padding: 6px;
}

.search-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 2.5rem 1rem;
    color: var(--text-tertiary);
    font-size: .875rem;
}
.search-empty i { font-size: 2rem; opacity: .35; }

.search-group-label {
    padding: 8px 10px 4px;
    font-size: .7rem;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: .07em;
}

.search-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 9px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
    transition: background .1s;
    border: 1px solid transparent;
}
.search-item:hover,
.search-item.active {
    background: var(--bg-surface-hover);
    border-color: var(--border-color-light);
    color: var(--text-primary);
}
.search-item.active {
    background: rgba(99,102,241,.1);
    border-color: rgba(99,102,241,.2);
}

.search-item-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: rgba(99,102,241,.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: .95rem;
    color: #6366f1;
    transition: background .1s;
}
.search-item.active .search-item-icon {
    background: rgba(99,102,241,.2);
}

.search-item-body { flex: 1; min-width: 0; }
.search-item-name {
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-item-name mark {
    background: rgba(99,102,241,.18);
    color: #6366f1;
    border-radius: 3px;
    padding: 0 2px;
    font-weight: 700;
}
.search-item-path {
    font-size: .75rem;
    color: var(--text-tertiary);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-item-enter {
    font-size: .7rem;
    color: var(--text-tertiary);
    opacity: 0;
    flex-shrink: 0;
    transition: opacity .1s;
}
.search-item.active .search-item-enter { opacity: 1; }

/* Adicionar/remover atalho direto no resultado da busca */
.search-item-shortcut {
    width: 28px; height: 28px; min-width: 28px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: .85rem;
    border: 1px solid var(--border-color-light);
    background: transparent;
    color: var(--text-tertiary);
    opacity: 0;
    transition: opacity .12s, background .12s, color .12s, border-color .12s;
    flex-shrink: 0;
    cursor: pointer;
}
.search-item:hover .search-item-shortcut,
.search-item.active .search-item-shortcut { opacity: 1; }
.search-item-shortcut:hover {
    background: rgba(99,102,241,.12);
    border-color: rgba(99,102,241,.3);
    color: #6366f1;
}
.search-item-shortcut.is-added {
    color: #10b981;
    border-color: rgba(16,185,129,.3);
    background: rgba(16,185,129,.08);
}
.search-item-shortcut.is-added:hover {
    color: #ef4444;
    border-color: rgba(239,68,68,.3);
    background: rgba(239,68,68,.08);
}

.search-hints {
    display: flex;
    gap: 14px;
    padding: 8px 14px;
    border-top: 1px solid var(--border-color-light);
    background: var(--bg-surface-secondary);
}
.search-hints span {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .72rem;
    color: var(--text-tertiary);
}
.search-hints kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1px 5px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: .68rem;
    font-family: monospace;
    color: var(--text-secondary);
    box-shadow: 0 1px 0 var(--border-color);
    min-width: 20px;
}

/* ==========================================
   RIGHT SECTION
   ========================================== */

.navbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.icon-btn i {
    font-size: 1.125rem;
}

/* ==========================================
   USER MENU
   ========================================== */

.user-menu-container {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.25rem 0.5rem 0.25rem 0.25rem;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.user-menu-btn:hover {
    border-color: var(--border-color-light);
    background: var(--bg-surface-secondary);
}

.user-avatar {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-avatar-initials {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #0a68f8 0%, #0056e4 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.user-avatar-initials-lg {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #0a68f8 0%, #0056e4 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.user-status-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #10b981;
    border: 2px solid var(--bg-surface);
    border-radius: 50%;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.2;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.user-chevron {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    transition: transform 0.2s;
}

.user-menu-btn.active .user-chevron {
    transform: rotate(180deg);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.6rem);
    right: 0;
    width: 340px;
    background: var(--bg-surface);
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(8, 20, 40, .32);
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: none;
}

.user-dropdown.show {
    display: block;
    animation: fadeInDown 0.18s ease;
}

/* Cabeçalho com a identidade da marca */
.user-dropdown-header {
    position: relative;
    padding: 1.15rem 1.25rem;
    display: flex;
    gap: 0.9rem;
    align-items: center;
    color: #fff;
    background:
        radial-gradient(260px 120px at 100% 0%, rgba(10, 104, 248, .5), transparent 70%),
        linear-gradient(120deg, #122741 0%, #0e2240 100%);
}

.user-avatar-large {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .22);
}

.user-avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-dropdown-info { min-width: 0; }

.user-dropdown-info h6 {
    margin: 0 0 0.2rem 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-info p {
    margin: 0;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, .7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.udp-body { padding: 0.35rem 1rem 0.85rem; }

.udp-section-title {
    margin: 0.85rem 0 0.45rem;
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

/* Empresa / filial */
.udp-ctx {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color-light);
    border-radius: 10px;
    background: var(--bg-surface-secondary);
}
.udp-ctx-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.75rem;
}
.udp-ctx-row + .udp-ctx-row { border-top: 1px solid var(--border-color-light); }
.udp-ctx-ico {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #0a68f8;
    background: rgba(10, 104, 248, .12);
}
.udp-context-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
}
.udp-tag-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
}
.udp-tag-value {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.udp-warn {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.7rem;
    padding: 0.6rem 0.75rem;
    font-size: 0.78rem;
    line-height: 1.4;
    color: #b45309;
    background: rgba(245, 158, 11, .12);
    border: 1px solid rgba(245, 158, 11, .3);
    border-radius: 8px;
}

/* Troca de filial */
.filial-switch-list {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    max-height: 168px;
    overflow-y: auto;
}
.filial-switch-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.5rem 0.65rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.filial-switch-item > i:first-child { font-size: 0.85rem; color: var(--text-tertiary); }
.filial-switch-item:hover:not(:disabled) {
    background: var(--bg-surface-hover);
    border-color: var(--border-color);
    color: var(--text-primary);
}
.filial-switch-item:disabled,
.filial-switch-item.active {
    cursor: default;
    color: #0a68f8;
    font-weight: 700;
    background: rgba(10, 104, 248, .1);
    border-color: rgba(10, 104, 248, .25);
}
.filial-switch-item.active > i:first-child { color: #0a68f8; }
.filial-switch-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filial-switch-check { color: #0a68f8; }
.dark-mode .filial-switch-item.active, .dark-mode .filial-switch-item.active > i:first-child, .dark-mode .filial-switch-check, .dark-mode .udp-ctx-ico, .dark-mode .dropdown-menu-item:hover i { color: #5da2ff; }

/* Plano */
.udp-wrap {
    padding: 0.8rem 0.9rem;
    border-radius: 10px;
    background: var(--bg-surface-secondary);
    border: 1px solid var(--border-color-light);
}
.udp-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}
.udp-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.udp-badge {
    flex-shrink: 0;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 0.18em 0.65em;
    border-radius: 20px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    background: rgba(148, 163, 184, .18);
}
.udp-badge--ativa    { color: #10b981; background: rgba(16, 185, 129, .15); }
.udp-badge--trial    { color: #3b82f6; background: rgba(59, 130, 246, .15); }
.udp-badge--pendente { color: #d97706; background: rgba(245, 158, 11, .17); }
.udp-badge--suspensa { color: #ef4444; background: rgba(239, 68, 68, .15); }
.udp-badge--master   { color: #8b5cf6; background: rgba(139, 92, 246, .15); }
.dark-mode .udp-badge--pendente { color: #fbbf24; }
.udp-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin: 0.3rem 0 0.7rem;
}
.udp-valor { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); }
.udp-venc  { font-size: 0.74rem; color: var(--text-tertiary); }
.udp-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    width: 100%;
    padding: 0.45rem 0;
    font-size: 0.78rem;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    background: #0a68f8;
    transition: background 0.15s;
}
.udp-link i { font-size: 1.05rem; }
.udp-link:hover { background: #0056e4; color: #fff; }

/* Ações */
.user-dropdown-menu {
    padding: 0.4rem 0.5rem;
    border-top: 1px solid var(--border-color-light);
}
.dropdown-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    color: var(--text-primary);
    text-decoration: none;
    text-align: left;
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.86rem;
}
.dropdown-menu-item:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}
.dropdown-menu-item i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    color: var(--text-tertiary);
}
.dropdown-menu-item:hover i { color: #0a68f8; }

.user-dropdown-footer {
    padding: 0.4rem 0.5rem 0.5rem;
    border-top: 1px solid var(--border-color-light);
}
.logout-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    color: #ef4444;
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
    font-size: 0.86rem;
    font-weight: 600;
}
.logout-btn i { font-size: 1.05rem; width: 20px; text-align: center; }
.logout-btn:hover { background: rgba(239, 68, 68, .12); color: #ef4444; }

/* ==========================================
   ANIMATIONS
   ========================================== */

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================
   RESPONSIVE
   ========================================== */

@media (max-width: 991px) {
    .navbar-container {
        padding: 0 0.75rem;
        gap: 0.5rem;
    }

    .user-info {
        display: none !important;
    }

    .user-menu-btn {
        padding: 0.25rem;
    }

    /* Dropdowns: fixos na tela para não sair do viewport */
    .user-dropdown {
        position: fixed;
        top: 64px;
        left: 0.75rem;
        right: 0.75rem;
        width: auto;
        max-height: calc(100svh - 80px);
        overflow-y: auto;
    }

    /* Ícones menores em mobile */
    .icon-btn {
        width: 32px;
        height: 32px;
    }

    /* Ocultar botão de ajuda */
    .icon-btn[title="Ajuda"] {
        display: none;
    }
}
