/* ==========================================================================
   Portal AGR - Tema (design system "tema_novo")
   --------------------------------------------------------------------------
   Camada de tema carregada DEPOIS do Metronic 6 / Bootstrap 4.
   Traduz os tokens e componentes do novo tema (shadcn/Tailwind, ver
   wwwroot/tema_novo) para o markup existente da aplicacao (kt-* / bootstrap).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
    --agr-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    /* superficies */
    --agr-background: #f8fafc; /* slate-50  */
    --agr-card: #ffffff;
    --agr-foreground: #0f172a; /* slate-900 */
    --agr-muted: #f1f5f9; /* slate-100 */
    --agr-muted-foreground: #64748b; /* slate-500 */
    --agr-border: #e5e7eb; /* gray-200  */
    --agr-border-soft: rgba(0, 0, 0, .08);

    /* acao */
    --agr-primary: #2563eb; /* blue-600  */
    --agr-primary-hover: #1d4ed8; /* blue-700  */
    --agr-primary-active: #1e40af; /* blue-800  */
    --agr-primary-soft: #dbeafe; /* blue-100  */
    --agr-primary-foreground: #ffffff;
    --agr-neutral: #030213; /* --primary do tema (shadcn) */

    /* estados */
    --agr-success: #10b981;
    --agr-success-soft: #d1fae5;
    --agr-warning: #eab308;
    --agr-warning-soft: #fef9c3;
    --agr-danger: #d4183d;
    --agr-danger-soft: #fee2e2;
    --agr-info: #0ea5e9;
    --agr-info-soft: #e0f2fe;

    /* raios (tema: --radius: 0.625rem) */
    --agr-radius: 0.625rem;
    --agr-radius-md: 0.5rem;
    --agr-radius-sm: 0.375rem;
    --agr-radius-full: 9999px;

    /* sombras */
    --agr-shadow-sm: 0 1px 2px 0 rgba(0,0,0,.05);
    --agr-shadow: 0 1px 3px 0 rgba(0,0,0,.1), 0 1px 2px -1px rgba(0,0,0,.06);
    --agr-shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.06);
    --agr-shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);

    /* sidebar */
    --agr-sidebar: #0f172a; /* slate-900 */
    --agr-sidebar-hover: #1e293b; /* slate-800 */
    --agr-sidebar-border: #334155; /* slate-700 */
    --agr-sidebar-foreground: #cbd5e1; /* slate-300 */
    --agr-sidebar-muted: #94a3b8; /* slate-400 */
    --agr-sidebar-active: #2563eb; /* blue-600  */

    /* metricas do shell */
    --agr-sidebar-width: 280px;
    --agr-sidebar-width-collapsed: 72px;
    --agr-topbar-height: 72px;
    --agr-transition: 300ms cubic-bezier(.4, 0, .2, 1);
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
.agr-body *,
.agr-body *::before,
.agr-body *::after {
    box-sizing: border-box;
}

body.agr-body {
    margin: 0;
    font-family: var(--agr-font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--agr-foreground);
    background-color: var(--agr-background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.agr-body h1, .agr-body h2, .agr-body h3,
.agr-body h4, .agr-body h5, .agr-body h6 {
    font-family: var(--agr-font-sans);
    color: var(--agr-foreground);
    font-weight: 500;
    letter-spacing: -.01em;
}

.agr-body a {
    color: var(--agr-primary);
}

.agr-body a:hover {
    color: var(--agr-primary-hover);
    text-decoration: none;
}

.agr-body ::selection {
    background: #bfdbfe;
}

.agr-body ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.agr-body ::-webkit-scrollbar-track {
    background: transparent;
}

.agr-body ::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: var(--agr-radius-full);
}

.agr-body ::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* --------------------------------------------------------------------------
   3. Shell: sidebar + topbar + conteudo
   -------------------------------------------------------------------------- */
.agr-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* ---- Sidebar ---- */
.agr-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1030;
    display: flex;
    flex-direction: column;
    width: var(--agr-sidebar-width);
    background-color: var(--agr-sidebar);
    border-right: 1px solid var(--agr-sidebar-border);
    transition: width var(--agr-transition), transform var(--agr-transition);
}

.agr-sidebar__brand {
    position: relative;
    display: flex;
    align-items: center;
    height: var(--agr-topbar-height);
    padding: 0 16px;
    border-bottom: 1px solid var(--agr-sidebar-border);
    flex-shrink: 0;
}

.agr-body .agr-sidebar__brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    overflow: hidden;
}

.agr-sidebar__logo {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-width: 44px;
    height: 44px;
    padding: 6px 8px;
    background: #fff;
    border-radius: var(--agr-radius-md);
    box-shadow: var(--agr-shadow-sm);
    overflow: hidden;
}

.agr-sidebar__logo img {
    display: block;
    max-height: 26px;
    max-width: 92px;
    object-fit: contain;
    transition: max-width var(--agr-transition);
}

.agr-sidebar__titles {
    display: flex;
    flex-direction: column;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--agr-transition);
}

.agr-sidebar__title {
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    line-height: 1;
    margin-bottom: 4px;
    letter-spacing: -.01em;
}

.agr-sidebar__subtitle {
    color: var(--agr-sidebar-muted);
    font-size: 10px;
    font-weight: 500;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.agr-sidebar__toggler {
    position: absolute;
    right: -14px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1040;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    width: 28px;
    padding: 0;
    border-radius: var(--agr-radius-full);
    background-color: #60a5fa;
    border: 2px solid #fff;
    color: #fff;
    cursor: pointer;
    box-shadow: var(--agr-shadow-sm);
    transition: transform 150ms ease, background-color 150ms ease;
}

.agr-sidebar__toggler:hover {
    background-color: #3b82f6;
    transform: translateY(-50%) scale(1.08);
}

.agr-sidebar__toggler:focus {
    outline: none;
}

.agr-sidebar__toggler i {
    font-size: 13px;
    line-height: 1;
}

/* ---- Menu ---- */
.agr-menu {
    flex: 1 1 auto;
    padding: 12px;
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    list-style: none;
}

.agr-menu__item {
    position: relative;
    margin-bottom: 6px;
    list-style: none;
}

.agr-body .agr-menu__link {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--agr-radius-md);
    color: var(--agr-sidebar-foreground);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: background-color 200ms ease, color 200ms ease;
}

.agr-body .agr-menu__link:hover,
.agr-body .agr-menu__link:focus {
    background-color: var(--agr-sidebar-hover);
    color: #fff;
    text-decoration: none;
}

.agr-body .agr-menu__item--active > .agr-menu__link {
    background-color: var(--agr-sidebar-active);
    color: #fff;
    box-shadow: var(--agr-shadow-sm);
}

.agr-menu__icon {
    flex-shrink: 0;
    width: 20px;
    font-size: 18px;
    line-height: 1;
    text-align: center;
    transition: transform 200ms ease;
}

.agr-menu__link:hover .agr-menu__icon,
.agr-menu__item--active > .agr-menu__link .agr-menu__icon {
    transform: scale(1.1);
}

.agr-menu__text {
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--agr-transition);
}

.agr-menu__arrow {
    font-size: 12px;
    opacity: .6;
    transition: transform 200ms ease;
}

.agr-menu__item--open > .agr-menu__link .agr-menu__arrow {
    transform: rotate(180deg);
}

/* submenu (accordion) */
.agr-menu__submenu {
    display: none;
    list-style: none;
    margin: 4px 0;
    padding-left: 16px;
}

.agr-menu__item--open > .agr-menu__submenu {
    display: block;
}

.agr-body .agr-menu__submenu .agr-menu__link {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--agr-sidebar-muted);
}

.agr-menu__bullet {
    flex-shrink: 0;
    width: 6px;
    height: 6px;
    margin: 0 7px;
    border-radius: var(--agr-radius-full);
    background: currentColor;
    opacity: .5;
}

/* ---- Rodape da sidebar ---- */
.agr-sidebar__footer {
    flex-shrink: 0;
    padding: 16px;
    border-top: 1px solid var(--agr-sidebar-border);
    color: var(--agr-sidebar-muted);
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--agr-transition);
}

.agr-sidebar__status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .02em;
}

.agr-sidebar__status-dot {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-radius: var(--agr-radius-full);
    background: var(--agr-success);
}

.agr-sidebar__version {
    margin-left: auto;
    font-size: 10px;
    opacity: .6;
}

/* ---- Estado recolhido ---- */
.agr-sidebar--collapsed {
    width: var(--agr-sidebar-width-collapsed);
}

.agr-sidebar--collapsed .agr-sidebar__brand {
    /* reserva a direita para o botao de recolher (28px, right: -14px) */
    padding: 0 16px 0 6px;
    justify-content: center;
}

.agr-sidebar--collapsed .agr-sidebar__brand-link {
    justify-content: center;
    gap: 0;
}

/* recolhido: o topo vira uma faixa branca com o logo em um cartao que ocupa
   toda a largura util da sidebar recolhida. Os logos da aplicacao sao
   horizontais (simbolo + palavra), entao a imagem e reduzida por inteiro
   (object-fit: contain) em vez de ser cortada no simbolo. */
.agr-sidebar--collapsed .agr-sidebar__brand {
    background-color: #fff;
    border-bottom-color: #fff;
    box-shadow: 2px 0 12px rgba(0, 0, 0, .05);
}

.agr-sidebar--collapsed .agr-sidebar__logo {
    flex-shrink: 1;
    width: 100%;
    min-width: 0;
    height: 44px;
    padding: 4px;
    background: #fff;
    border-radius: var(--agr-radius-md);
    box-shadow: var(--agr-shadow-sm);
}

.agr-sidebar--collapsed .agr-sidebar__logo img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
}

.agr-sidebar--collapsed .agr-sidebar__titles,
.agr-sidebar--collapsed .agr-menu__text,
.agr-sidebar--collapsed .agr-menu__arrow,
.agr-sidebar--collapsed .agr-sidebar__footer {
    opacity: 0;
    width: 0;
    height: 0;
    padding: 0;
    margin: 0;
    border: 0;
    overflow: hidden;
    pointer-events: none;
}

.agr-sidebar--collapsed .agr-menu__link {
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0 auto;
    padding: 0;
    /* sem o gap o icone fica no centro exato do item (o texto/seta ocupam
       largura zero, mas o gap continuaria deslocando o icone para a esquerda) */
    gap: 0;
}

.agr-sidebar--collapsed .agr-menu__icon {
    width: auto;
    font-size: 20px;
}

/* o texto e a seta continuam no fluxo (para a transicao de opacidade), entao
   precisam parar de crescer - senao empurram o icone para a esquerda */
.agr-sidebar--collapsed .agr-menu__text,
.agr-sidebar--collapsed .agr-menu__arrow,
.agr-sidebar--collapsed .agr-sidebar__titles {
    flex: 0 0 0;
}

.agr-sidebar--collapsed .agr-menu__submenu {
    display: none !important;
}

/* tooltip quando recolhido */
.agr-sidebar--collapsed .agr-menu__item > .agr-menu__link::after {
    content: attr(data-title);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    z-index: 1050;
    padding: 6px 10px;
    border-radius: var(--agr-radius-sm);
    background: #1e293b;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 150ms ease;
}

.agr-sidebar--collapsed .agr-menu__item > .agr-menu__link:hover::after {
    opacity: 1;
}

/* ---- Area principal ---- */
.agr-main {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    margin-left: var(--agr-sidebar-width);
    transition: margin-left var(--agr-transition);
}

.agr-shell--collapsed .agr-main {
    margin-left: var(--agr-sidebar-width-collapsed);
}

/* ---- Topbar ---- */
.agr-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    height: var(--agr-topbar-height);
    padding: 0 24px;
    background: #fff;
    border-bottom: 1px solid var(--agr-border);
}

.agr-topbar__mobile-toggler {
    display: none;
    align-items: center;
    justify-content: center;
    height: 36px;
    width: 36px;
    margin-right: auto;
    border: 0;
    border-radius: var(--agr-radius-md);
    background: transparent;
    color: var(--agr-muted-foreground);
    font-size: 20px;
    cursor: pointer;
}

.agr-topbar__mobile-toggler:hover {
    background: var(--agr-muted);
    color: var(--agr-foreground);
}

/* menu do usuario */
.agr-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: var(--agr-radius-md);
    cursor: pointer;
    transition: background-color 150ms ease;
}

.agr-user:hover {
    background-color: #f3f4f6;
}

.agr-user__info {
    text-align: right;
    line-height: 1.3;
}

.agr-user__name {
    display: block;
    color: #111827;
    font-size: 14px;
    font-weight: 500;
}

.agr-user__place {
    display: block;
    color: #6b7280;
    font-size: 12px;
}

.agr-user__avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    height: 40px;
    width: 40px;
    border-radius: var(--agr-radius-full);
    border: 2px solid var(--agr-border);
    background: var(--agr-primary-soft);
    color: #1d4ed8;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
}

.agr-user-menu {
    min-width: 264px;
    padding: 6px;
    border: 1px solid var(--agr-border);
    border-radius: var(--agr-radius);
    box-shadow: var(--agr-shadow-lg);
    background: #fff;
}

.agr-user-menu__header {
    padding: 10px 12px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--agr-border);
}

.agr-user-menu__header-name {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--agr-foreground);
}

.agr-user-menu__header-meta {
    display: block;
    font-size: 12px;
    color: var(--agr-muted-foreground);
    word-break: break-all;
}

.agr-body .agr-user-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--agr-radius-sm);
    color: var(--agr-foreground);
    font-size: 14px;
    text-decoration: none;
}

.agr-body .agr-user-menu__item:hover {
    background: var(--agr-muted);
    color: var(--agr-foreground);
    text-decoration: none;
}

.agr-user-menu__item i {
    width: 16px;
    font-size: 15px;
    color: var(--agr-muted-foreground);
}

.agr-body .agr-user-menu__item--danger,
.agr-body .agr-user-menu__item--danger i {
    color: #dc2626;
}

.agr-body .agr-user-menu__item--danger:hover {
    background: var(--agr-danger-soft);
    color: #b91c1c;
}

.agr-user-menu__separator {
    height: 1px;
    margin: 6px 0;
    background: var(--agr-border);
}

/* ---- Conteudo ---- */
.agr-content {
    flex: 1 0 auto;
    min-width: 0;
    padding: 24px;
}

.agr-page-head {
    margin-bottom: 24px;
}

.agr-page-head__title {
    margin: 0 0 6px;
    font-size: 24px;
    font-weight: 500;
    color: #111827;
}

.agr-page-head__desc {
    margin: 0;
    font-size: 14px;
    color: #4b5563;
}

/* backdrop do menu mobile */
.agr-backdrop {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1025;
    background: rgba(15, 23, 42, .5);
}

.agr-backdrop--on {
    display: block;
}
