/**
 * Layout helpdesk (admin / portal): sidebar, topbar, cartões e tabelas.
 * Cores base alinhadas ao tema Norden (detalhes em norden-theme.css).
 */
:root {
    --sidebar-width: 280px;
    /*
     * Wordmark panorâmico (ex. 1824×497): escala pela altura da faixa; excesso horizontal recortado no .navbar-brand.
     * Padding vertical da faixa = 0.575 × --sidebar-brand-padding-y (15% acima do antigo 0.5×); logo max-height ligeiramente menor para caber na coluna.
     */
    /* Faixa da logo: altura mínima estável; tamanho da arte via --sidebar-logo-max-height (flex + contain). */
    /* +30% vs bloco anterior: faixa acompanha a altura máxima da arte (evita corte). */
    --sidebar-brand-min-height: clamp(11.5rem, calc(8.5vw + 7.5rem), 16.75rem);
    --sidebar-brand-padding-y: 0.95rem;
    --sidebar-logo-max-height: clamp(10.4rem, calc(9.1vw + 7.15rem), 15.25rem);
    --helpdesk-topbar-height: 56px;
    --helpdesk-border: rgba(148, 163, 184, 0.14);
}

body.norden-theme {
    margin: 0;
    min-height: 100vh;
    background: var(--norden-bg, #0a1018);
    color: var(--norden-text, #e2e8f0);
}

/* ——— Login / convite ——— */
.helpdesk-login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    /* Mesmo degradê da coluna .helpdesk-sidebar (identidade no login/convite) */
    background: linear-gradient(180deg, var(--norden-deep, #050a12) 0%, var(--norden-bg, #0a1018) 100%);
}

.helpdesk-login-card {
    width: 100%;
    max-width: 440px;
    padding: 2rem;
    border-radius: 12px;
    background: var(--norden-surface, #0f1724);
    border: 1px solid var(--helpdesk-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.helpdesk-login-card h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: #f1f5f9;
}

.login-subtitle {
    color: var(--norden-muted, #94a3b8);
    margin-bottom: 1.5rem;
}

/* ~2× o tamanho anterior: largura quase a coluna do cartão; altura com teto em vh para não comer o formulário em ecrãs baixos */
.login-logo {
    display: block;
    margin: 0 auto 1rem;
    width: 100%;
    max-width: min(100%, 22rem);
    height: auto;
    max-height: min(16.5rem, 48vh, clamp(10rem, 30vw + 2.5rem, 16.5rem));
    object-fit: contain;
    object-position: center;
    min-width: 0;
    filter: drop-shadow(0 0 14px rgba(34, 211, 238, 0.14));
}

/* Espaço estável entre bloco da logo e títulos/formulário */
.helpdesk-login-card > .text-center:first-child {
    margin-bottom: 1.125rem !important;
}

/* ——— Sidebar ——— */
.helpdesk-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1020;
    background: rgba(5, 10, 18, 0.65);
}

.helpdesk-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1030;
    width: var(--sidebar-width);
    height: 100vh;
    min-height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    background: linear-gradient(180deg, #050a12 0%, #0a1018 100%);
    border-right: 1px solid var(--helpdesk-border);
    overflow: hidden;
}

.helpdesk-sidebar .navbar-brand.logo-container {
    min-height: 80px;
}

.helpdesk-sidebar .navbar-brand {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0;
    margin-right: 0;
    text-align: center;
    flex: 0 0 auto;
    overflow: hidden;
}

/* Barra de ações em massa (fila de tickets) */
.helpdesk-tickets-bulk-toolbar {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--helpdesk-border, rgba(255, 255, 255, 0.12)) !important;
}

.helpdesk-table-col--select {
    width: 2.75rem;
}

.helpdesk-sidebar .navbar-brand.helpdesk-sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    height: var(--sidebar-brand-min-height);
    min-height: var(--sidebar-brand-min-height);
    padding: 0.5rem 0.65rem;
    box-sizing: border-box;
    overflow: hidden;
}

body.norden-theme .helpdesk-sidebar.navbar-dark .navbar-brand,
body.norden-theme .helpdesk-sidebar .navbar-brand {
    /* Fundo transparente: usa só o gradiente da coluna (.helpdesk-sidebar), alinhado a --norden-deep / --norden-bg */
    background: transparent;
    border-radius: 0;
    border-bottom: 1px solid var(--helpdesk-border);
    box-shadow: none;
}

/* Logo base (sidebar); altura máxima realçada só na coluna — ver regra .helpdesk-sidebar abaixo */
.helpdesk-brand-logo {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    min-width: 0;
    object-fit: contain;
    object-position: left center;
}

.helpdesk-sidebar .helpdesk-brand-logo.helpdesk-brand-logo--sidebar {
    display: block;
    position: relative;
    flex: 0 1 auto;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: var(--sidebar-logo-max-height);
    min-width: 0;
    margin: 0;
    object-fit: contain;
    object-position: center center;
}

.helpdesk-sidebar .navbar-brand:hover .helpdesk-brand-logo,
.helpdesk-sidebar .navbar-brand:focus .helpdesk-brand-logo {
    filter: drop-shadow(0 0 10px rgba(34, 211, 238, 0.18));
}

/* Navbar horizontal (layouts/app): maior, mais extensa à direita, responsiva */
body.norden-theme .navbar:not(.helpdesk-sidebar) .navbar-brand {
    background-color: transparent;
    box-shadow: none;
    gap: 0.625rem;
}

.navbar:not(.helpdesk-sidebar) .helpdesk-brand-logo--navbar {
    width: auto;
    flex: 0 0 auto;
    max-width: min(72vw, clamp(12.5rem, 28vw + 4rem, 22.5rem));
    max-height: clamp(2.75rem, 3.5vw + 1.75rem, 4.5rem);
    height: auto;
    object-fit: contain;
    object-position: left center;
}

.helpdesk-sidebar .nav-scroll {
    flex: 1 1 0%;
    min-height: 0;
    overflow-y: scroll;
    overflow-x: hidden;
    padding: 0 0.45rem 1.15rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.45) rgba(15, 23, 36, 0.4);
}

.helpdesk-sidebar .nav-scroll::-webkit-scrollbar {
    width: 8px;
}

.helpdesk-sidebar .nav-scroll::-webkit-scrollbar-track {
    background: rgba(15, 23, 36, 0.35);
    border-radius: 8px;
}

.helpdesk-sidebar .nav-scroll::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.45);
    border-radius: 8px;
}

.helpdesk-sidebar .nav-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.65);
}

.helpdesk-sidebar .nav-scroll:focus-within {
    outline: none;
}

/* Bootstrap 4 .collapse não deve cortar itens dentro da área rolável */
.helpdesk-sidebar .nav-dropdown-section .collapse {
    overflow: visible;
}

/* Ticket admin: OK (status) e fechar — mesma altura perceptível, colunas flex sem estouro */
.ticket-status-actions-row__col {
    min-width: 0;
}

.ticket-status-actions-row .btn {
    min-height: 2.75rem;
    font-weight: 600;
}

@media (max-width: 991.98px) {
    .helpdesk-sidebar {
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
    }
}

/* Menu lateral: tipografia compacta (não altera resto do painel) */
.helpdesk-sidebar .sidebar-menu,
.helpdesk-sidebar .navbar-nav .nav-link {
    font-size: 13px;
    line-height: 1.4;
}

.helpdesk-sidebar .navbar-nav .nav-link {
    color: #cbd5e1;
    border-radius: 8px;
    padding: 0.3rem 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.helpdesk-sidebar .navbar-nav .nav-link:hover {
    background: rgba(0, 180, 216, 0.08);
    color: #f8fafc;
}

.helpdesk-sidebar .navbar-nav .nav-link.active {
    background: rgba(0, 180, 216, 0.15);
    color: #67e8f9;
    font-weight: 600;
}

.helpdesk-sidebar .nav-link i {
    opacity: 0.9;
}

.nav-dropdown-section {
    margin-bottom: 0.12rem;
}

.nav-section-toggle {
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    color: #94a3b8;
    /* Títulos de secção: ligeiramente maiores que os links (≈12px) */
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.055em;
    text-transform: uppercase;
    padding: 0.55rem 0.65rem 0.28rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.nav-section-toggle:hover {
    color: #cbd5e1;
}

.nav-chevron {
    transition: transform 0.2s ease;
}

.nav-section-toggle:not(.collapsed) .nav-chevron {
    transform: rotate(180deg);
}

/* ——— Área principal ——— */
.helpdesk-main-wrap {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

.helpdesk-watermark {
    pointer-events: none;
    position: fixed;
    left: var(--sidebar-width);
    right: 0;
    bottom: 0;
    height: 40vh;
    opacity: 0.04;
    background: radial-gradient(ellipse at bottom right, #00b4d8, transparent 60%);
    z-index: 0;
}

.helpdesk-topbar {
    position: sticky;
    top: 0;
    z-index: 1010;
    min-height: var(--helpdesk-topbar-height);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 0.5rem;
    background: rgba(10, 16, 24, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--helpdesk-border);
}

@media (max-width: 991.98px) {
    .helpdesk-topbar {
        flex-wrap: wrap;
    }
}

.helpdesk-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--helpdesk-border);
    border-radius: 8px;
    background: rgba(15, 23, 36, 0.9);
    color: #e2e8f0;
    cursor: pointer;
}

.helpdesk-nav-toggle:hover {
    border-color: rgba(0, 180, 216, 0.5);
}

.helpdesk-nav-toggle__bars {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.helpdesk-nav-toggle__bar {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
}

.page-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #f1f5f9;
}

.topbar-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 0.5rem;
    min-width: 0;
}

.topbar-meta__client {
    max-width: min(100%, 220px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-meta__user .btn-outline-light {
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .topbar-meta {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .topbar-meta__client {
        max-width: 100%;
    }
}

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 9999px;
    background: rgba(0, 180, 216, 0.2);
    color: #67e8f9;
    font-size: 0.85rem;
    font-weight: 700;
}

.user-dropdown__name {
    color: #e2e8f0;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    font-size: 0.65rem;
    line-height: 18px;
    text-align: center;
    border-radius: 9999px;
    background: #ef4444;
    color: #fff;
    font-weight: 700;
}

.notification-dropdown {
    min-width: 280px;
    max-width: min(360px, 100vw - 2rem);
}

.helpdesk-content {
    flex: 1;
    padding: 1rem 1.25rem 2rem;
    position: relative;
    z-index: 1;
}

.helpdesk-page-header {
    margin-bottom: 1rem;
}

.helpdesk-pagination-footer {
    background-color: rgba(15, 23, 36, 0.92) !important;
    border-color: var(--helpdesk-border) !important;
}

.helpdesk-code-block {
    background: rgba(15, 23, 42, 0.95) !important;
    border-color: var(--helpdesk-border) !important;
    color: #e2e8f0 !important;
}

.helpdesk-card {
    background: var(--norden-surface, #0f1724);
    border: 1px solid var(--helpdesk-border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.helpdesk-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.helpdesk-table {
    color: #e2e8f0;
}

.helpdesk-table thead th {
    border-top: 0;
    border-color: var(--helpdesk-border);
    color: #94a3b8;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.helpdesk-table td {
    border-color: var(--helpdesk-border);
    vertical-align: middle;
}

.helpdesk-queue-actions-cell {
    vertical-align: middle;
    white-space: normal;
}

.helpdesk-queue-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.55rem;
    max-width: min(100%, 22rem);
}

.helpdesk-queue-actions .btn {
    flex: 0 0 auto;
}

.helpdesk-queue-actions form.helpdesk-queue-actions__form {
    display: inline-flex;
    margin: 0;
}

.helpdesk-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-end;
}

.helpdesk-row--sla-overdue {
    box-shadow: inset 3px 0 0 #f97316;
}

.helpdesk-empty-state__title {
    font-weight: 600;
    color: #f1f5f9;
}

.helpdesk-empty-state__subtitle {
    color: #94a3b8;
    font-size: 0.9rem;
}

.helpdesk-alert-banner {
    border-radius: 8px;
}

.fs-5 {
    font-size: 1.25rem !important;
}

.smaller {
    font-size: 0.8rem;
}

.text-body {
    color: #e2e8f0 !important;
}

.welcome-page .helpdesk-login-wrap {
    min-height: auto;
}

/* ——— Cartões KPI (metric-card) — tema escuro; antes herdava .card branco do Bootstrap ——— */
.norden-theme .helpdesk-metric-card {
    background: linear-gradient(165deg, rgba(17, 28, 44, 0.98), rgba(12, 20, 32, 0.95));
    border: 1px solid var(--helpdesk-border);
    border-radius: 12px;
    color: #e2e8f0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.norden-theme .helpdesk-metric-card .card-body {
    padding: 1rem 1.1rem;
}

.norden-theme .helpdesk-metric-card .text-muted {
    color: #94a3b8 !important;
    letter-spacing: 0.04em;
    font-size: 0.72rem;
    font-weight: 600;
}

.norden-theme .helpdesk-metric-card .h4 {
    color: #f8fafc;
    font-weight: 700;
    font-size: 1.65rem;
    line-height: 1.2;
}

.norden-theme .helpdesk-metric-card .norden-metric-card__link {
    color: inherit;
    display: block;
}

.norden-theme .helpdesk-metric-card--primary {
    border-left: 3px solid #22d3ee;
    background: linear-gradient(165deg, rgba(17, 28, 44, 0.98), rgba(8, 18, 32, 0.92));
}

.norden-theme .helpdesk-metric-card--secondary {
    border-left: 3px solid #64748b;
}

.norden-theme .helpdesk-metric-card--success {
    border-left: 3px solid #34d399;
}

.norden-theme .helpdesk-metric-card--warning {
    border-left: 3px solid #fbbf24;
}

.norden-theme .helpdesk-metric-card--danger {
    border-left: 3px solid #f87171;
}

/* Painel SLA — realce do separador ativo (alinhado ao tema, sem “card rosa”) */
.norden-theme .sla-kpi-tab--active {
    box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.35);
}

/* ——— Listas do dashboard (links com .helpdesk-list-item) ——— */
.helpdesk-list-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    padding: 0.7rem 1rem;
    margin: 0;
    border-bottom: 1px solid var(--helpdesk-border);
    color: #e2e8f0;
    text-decoration: none;
    font-size: 0.9rem;
    line-height: 1.45;
    transition: background 0.15s ease, color 0.15s ease;
}

.helpdesk-list-item:last-child {
    border-bottom: none;
}

.helpdesk-list-item:hover,
.helpdesk-list-item:focus {
    background: rgba(0, 180, 216, 0.08);
    color: #f8fafc;
    text-decoration: none;
}

.helpdesk-list-item > span:first-child {
    flex: 1 1 12rem;
    min-width: 0;
    word-break: break-word;
}

.helpdesk-list-item code {
    display: inline-block;
    color: #67e8f9;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(34, 211, 238, 0.25);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.78rem;
    margin-right: 0.35rem;
    vertical-align: baseline;
}

.norden-theme .helpdesk-list-item .badge-light {
    background: rgba(30, 41, 59, 0.95) !important;
    color: #e2e8f0 !important;
    border-color: rgba(148, 163, 184, 0.35) !important;
}

/* Cartão com lista: sem padding duplo; cabeçalho alinhado */
.helpdesk-card.helpdesk-card--flush,
.helpdesk-card:has(.helpdesk-list-item) {
    padding: 0;
    overflow: hidden;
}

.helpdesk-card.helpdesk-card--flush > .card-header,
.helpdesk-card:has(.helpdesk-list-item) > .card-header {
    padding: 0.75rem 1rem;
    margin: 0;
    border-bottom: 1px solid var(--helpdesk-border);
    background: rgba(15, 23, 42, 0.75);
}

.helpdesk-card--flush > .card-body {
    background: rgba(15, 23, 36, 0.35);
}

/* ——— SOC / painel master ——— */
.soc-insight-card .card-header {
    background: rgba(15, 23, 42, 0.75);
}

.soc-insight-callout {
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
    font-size: 0.85rem;
    line-height: 1.45;
    border: 1px solid var(--helpdesk-border);
    background: rgba(15, 23, 36, 0.9);
    color: #cbd5e1;
}

.soc-insight-callout--critical {
    border-color: rgba(248, 113, 113, 0.45);
    background: rgba(127, 29, 29, 0.15);
    color: #fecaca;
}

.soc-insight-callout--warning {
    border-color: rgba(251, 191, 36, 0.4);
    background: rgba(120, 53, 15, 0.12);
    color: #fde68a;
}

.soc-insight-callout--ok {
    border-color: rgba(52, 211, 153, 0.35);
    background: rgba(6, 78, 59, 0.12);
    color: #a7f3d0;
}

.soc-kpi-grid {
    margin-top: 0.5rem;
}

.soc-kpi-card {
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--helpdesk-border);
    background: rgba(12, 20, 32, 0.95);
    height: 100%;
}

.soc-kpi-card--critical {
    border-color: rgba(248, 113, 113, 0.35);
}

.soc-kpi-card__label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
}

.soc-kpi-card__value {
    display: block;
    font-size: 1.35rem;
    font-weight: 700;
    color: #f8fafc;
    line-height: 1.2;
}

.soc-kpi-card__hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.72rem;
    color: #64748b;
    line-height: 1.35;
}

/* ——— SOC hero (link) ——— */
a.norden-soc-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    padding: 1rem 1.25rem;
    min-width: 10rem;
    text-decoration: none;
    border: 1px solid rgba(34, 211, 238, 0.35);
    background: linear-gradient(160deg, rgba(15, 23, 42, 0.95), rgba(8, 18, 32, 0.88));
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

a.norden-soc-hero:hover {
    border-color: rgba(34, 211, 238, 0.65);
    box-shadow: 0 10px 36px rgba(34, 211, 238, 0.12);
    text-decoration: none;
}

/* ——— Configurações: painel auditoria de e-mail ——— */
.email-audit-panel__badge-live {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.email-audit-panel__filters .form-control,
.email-audit-panel__filters .btn {
    min-height: 2.05rem;
}

.email-audit-panel__action-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.35em 0.55em;
}

.email-audit-panel__preview {
    max-width: 32rem;
    color: var(--norden-muted, #94a3b8);
}

.email-audit-panel__table-wrap {
    max-height: min(28rem, 55vh);
    overflow: auto;
    border-radius: 0.5rem;
    border: 1px solid var(--helpdesk-border);
}

.email-audit-panel__footer .btn {
    margin-bottom: 0.25rem;
}

.email-audit-panel__json {
    font-size: 0.8125rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: min(65vh, 32rem);
    overflow: auto;
    margin: 0;
    padding: 1rem;
    border-radius: 0.5rem;
    background: rgba(5, 10, 18, 0.65);
    color: var(--norden-text, #e2e8f0);
    border: 1px solid var(--helpdesk-border);
}
