/* =========================================================
   HEADER / FOOTER DO SISTEMA
   Usa as variáveis --primary / --primary-dark / --primary-rgb
   já injetadas via functions.php (tema por usuário/escritório).
   Fallbacks abaixo garantem que funcione mesmo sem elas.
   ========================================================= */

:root {
    --primary:       var(--primary, #3f502e);
    --primary-dark:  var(--primary-dark, #2c3a20);
    --primary-rgb:   var(--primary-rgb, 63, 80, 46);
}

/* ---------- HEADER ---------- */

.sys-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.sys-topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 64px;
    padding: 0 24px;
    max-width: 1600px;
    margin: 0 auto;
}

.sys-topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.sys-topbar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--primary-dark);
    font-size: 16px;
    cursor: pointer;
    transition: background 0.15s ease;
}
.sys-topbar-toggle:hover {
    background: rgba(var(--primary-rgb), 0.08);
}

.sys-topbar-logo img {
    display: block;
    max-height: 34px;
    width: auto;
}
.sys-topbar-logo a {
    font-weight: 700;
    font-size: 18px;
    color: var(--primary-dark);
    text-decoration: none;
}

.sys-topbar-divider {
    width: 1px;
    height: 26px;
    background: #e5e7eb;
    display: block;
}

.sys-topbar-page-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #4b5563;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sys-topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.sys-topbar-icon-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 8px;
    color: #4b5563;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}
.sys-topbar-icon-btn:hover {
    background: rgba(var(--primary-rgb), 0.08);
    color: var(--primary-dark);
}

/* ---------- Menu do usuário ---------- */

.sys-topbar-user {
    position: relative;
}

.sys-topbar-user-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 6px 6px;
    border: none;
    background: transparent;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s ease;
}
.sys-topbar-user-trigger:hover {
    background: rgba(var(--primary-rgb), 0.08);
}

.sys-topbar-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.sys-topbar-user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.25;
}
.sys-topbar-user-name {
    font-size: 13px;
    font-weight: 700;
    color: #1f2937;
}
.sys-topbar-user-role {
    font-size: 11px;
    color: #9ca3af;
}

.sys-topbar-user-caret {
    font-size: 10px;
    color: #9ca3af;
    margin-left: 2px;
    transition: transform 0.15s ease;
}
.sys-topbar-user-trigger[aria-expanded="true"] .sys-topbar-user-caret {
    transform: rotate(180deg);
}

.sys-topbar-user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 210px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
    padding: 8px;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 200;
}
.sys-topbar-user-dropdown.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.sys-topbar-user-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    text-decoration: none;
}
.sys-topbar-user-dropdown a i {
    width: 16px;
    text-align: center;
    color: var(--primary);
}
.sys-topbar-user-dropdown a:hover {
    background: #f3f4f6;
}
.sys-topbar-user-dropdown-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 6px 4px;
}
.sys-topbar-user-dropdown-logout {
    color: #b91c1c !important;
}
.sys-topbar-user-dropdown-logout i {
    color: #b91c1c !important;
}
.sys-topbar-user-dropdown-logout:hover {
    background: #fef2f2 !important;
}

/* ---------- FOOTER ---------- */

.sys-footer {
    background: #fff;
    border-top: 1px solid #e5e7eb;
    margin-top: 40px;
}

.sys-footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px 24px;
}

.sys-footer-credit {
    margin: 0;
    font-size: 13px;
    color: #6b7280;
}
.sys-footer-credit b {
    color: var(--primary-dark);
}

.sys-footer-links {
    display: flex;
    gap: 20px;
}
.sys-footer-links a {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    text-decoration: none;
}
.sys-footer-links a:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* ---------- Botão voltar ao topo ---------- */

.sys-back-to-top {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 16px;
    box-shadow: 0 6px 16px rgba(var(--primary-rgb), 0.35);
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.15s ease;
    z-index: 150;
}
.sys-back-to-top.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.sys-back-to-top:hover {
    background: var(--primary-dark);
}

/* ---------- Responsivo ---------- */

@media (max-width: 782px) {
    .sys-topbar-inner {
        padding: 0 14px;
        height: 58px;
    }
    .hide-mobile {
        display: none !important;
    }
    .sys-topbar-page-title {
        max-width: 42vw;
    }
    .sys-footer-inner {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px 14px;
    }
}