/* public/css/default.css */
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");

/* =========================
   TOKENS
========================= */
:root {
   --bg: #0b1220;
   --elev: #121826;
   --panel: #101624;

   --text: #e7ecf6;
   --muted: #94a3b8;

   --brand: #6c6d6e;
   --brand-contrast: #ffffff;

   --border: rgba(148, 163, 184, 0.18);
   --hover: rgba(59, 130, 246, 0.14);

   --shadow: 0 16px 50px rgba(0, 0, 0, 0.35);
   --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.18);

   --success: #22c55e;
   --warning: #f59e0b;
   --danger: #ef4444;
   --info: #3b82f6;

   --success-bg: color-mix(in oklab, var(--success), #0000 85%);
   --warning-bg: color-mix(in oklab, var(--warning), #0000 85%);
   --danger-bg: color-mix(in oklab, var(--danger), #0000 85%);
   --info-bg: color-mix(in oklab, var(--info), #0000 85%);

   --r-sm: 10px;
   --r-md: 14px;
   --r-lg: 18px;
   --r-xl: 22px;

   --s-1: 6px;
   --s-2: 10px;
   --s-3: 14px;
   --s-4: 16px;
   --s-5: 20px;
   --s-6: 24px;
   --s-7: 30px;

   --fs-xs: 0.78rem;
   --fs-sm: 0.88rem;
   --fs-md: 1rem;
   --fs-lg: 1.15rem;
   --fs-xl: 1.45rem;

   --t: 180ms cubic-bezier(0.2, 0.8, 0.2, 1);

   --container: 1100px;
   --header-h: 64px;
   --scrollbar-comp: 0px;

   --overlay: rgba(0, 0, 0, 0.45);
   --ring: color-mix(in oklab, var(--brand), #fff 12%);

   --z-header: 1000;
   --z-sidebar: 950;
   --z-backdrop: 900;
   --z-dropdown: 1200;
   --z-toast: 2000;
   --z-modal: 2100;
}

html[data-theme="light"] {
   --bg: #f5f7fb;
   --elev: #ffffff;
   --panel: #ffffff;

   --text: #0f172a;
   --muted: #475569;

   --border: rgba(2, 6, 23, 0.10);
   --shadow: 0 18px 50px rgba(15, 23, 42, 0.10);
   --hover: rgba(2, 132, 199, 0.10);

   --success-bg: color-mix(in oklab, var(--success), #fff 88%);
   --warning-bg: color-mix(in oklab, var(--warning), #fff 88%);
   --danger-bg: color-mix(in oklab, var(--danger), #fff 88%);
   --info-bg: color-mix(in oklab, var(--info), #fff 88%);
}

/* =========================
   BASE / RESET
========================= */
* {
   box-sizing: border-box;
}

html,
body {
   height: 100%;
}

body {
   margin: 0;
   font-family: "Poppins", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
   background: var(--bg);
   color: var(--text);
   -webkit-font-smoothing: antialiased;
   -moz-osx-font-smoothing: grayscale;
   text-rendering: optimizeLegibility;
}

img {
   max-width: 100%;
   display: block;
}

a {
   color: inherit;
   text-decoration: none;
}

button,
input,
select,
textarea {
   font: inherit;
}

code,
pre,
kbd,
samp {
   font-family: inherit;
   font-size: 1em;
   background: none;
}

@media (prefers-reduced-motion: no-preference) {

   .btn,
   .btn-outline,
   .btn-ghost,
   .menu-link,
   .section-header,
   .icon-btn,
   .dropdown__item,
   .user-pill,
   .input,
   select.input,
   textarea.input {
      transition:
         background-color 160ms ease,
         color 160ms ease,
         border-color 160ms ease,
         transform 160ms ease;
   }

   .sidebar,
   .dropdown__menu {
      transition:
         transform var(--t),
         opacity var(--t);
   }

   .section-chevron {
      transition: transform var(--t);
   }
}

:focus-visible {
   outline: 2px solid var(--ring);
   outline-offset: 2px;
}

/* Scrollbar */
* {
   scrollbar-width: thin;
   scrollbar-color: color-mix(in oklab, var(--muted), #0000 55%) transparent;
}

*::-webkit-scrollbar {
   width: 10px;
   height: 10px;
}

*::-webkit-scrollbar-thumb {
   background: color-mix(in oklab, var(--muted), #0000 55%);
   border-radius: 999px;
   border: 2px solid transparent;
   background-clip: padding-box;
}

/* =========================
   UTIL
========================= */
.container {
   width: min(var(--container), calc(100% - 32px));
   margin-inline: auto;
}

.hidden {
   display: none !important;
}

.center {
   display: grid;
   place-items: center;
}

.d-flex {
   display: flex;
}

.items-center {
   align-items: center;
}

.justify-between {
   justify-content: space-between;
}

.gap-1 {
   gap: var(--s-1);
}

.gap-2 {
   gap: var(--s-2);
}

.gap-3 {
   gap: var(--s-3);
}

.mt-2 {
   margin-top: var(--s-2);
}

.mt-3 {
   margin-top: var(--s-3);
}

.mt-4 {
   margin-top: var(--s-4);
}

.mb-2 {
   margin-bottom: var(--s-2);
}

.mb-3 {
   margin-bottom: var(--s-3);
}

.text-muted {
   color: var(--muted);
}

.text-center {
   text-align: center;
}

.text-right {
   text-align: right;
}

.truncate {
   white-space: nowrap;
   overflow: hidden;
   text-overflow: ellipsis;
}

.nowrap {
   white-space: nowrap;
}

/* =========================
   TYPO
========================= */
.h1 {
   font-size: clamp(1.35rem, 2vw, 1.8rem);
   font-weight: 700;
   letter-spacing: -0.02em;
}

.h2 {
   font-size: 1.25rem;
   font-weight: 650;
   letter-spacing: -0.01em;
}

.h3 {
   font-size: 1.05rem;
   font-weight: 650;
}

.p {
   font-size: var(--fs-md);
   line-height: 1.6;
}

.small {
   font-size: var(--fs-sm);
}

.mini {
   font-size: var(--fs-xs);
}

/* =========================
   SHELL (menu.js)
========================= */
.app-header {
   position: fixed;
   z-index: var(--z-header);
   top: 0;
   left: 0;
   right: 0;
   height: var(--header-h);
   background: color-mix(in oklab, var(--elev), #fff 2%);
   border-bottom: 1px solid var(--border);
   display: flex;
   align-items: center;
   justify-content: space-between;
   padding-top: 0;
   padding-bottom: 0;
   padding-left: var(--s-4);
   padding-right: calc(var(--s-4) + var(--scrollbar-comp));
}

.header-left,
.header-right {
   display: flex;
   align-items: center;
   gap: var(--s-2);
   min-width: 0;
}

.brand {
   display: flex;
   align-items: center;
   gap: 12px;
   min-width: 0;
}

.brand-logo {
   height: 34px;
   width: auto;
   max-width: 160px;
   object-fit: contain;
   display: block;
}

.brand-text {
   display: grid;
   line-height: 1.05;
}

.brand-title {
   font-weight: 750;
   letter-spacing: -0.02em;
}

.brand-sub {
   font-size: .88rem;
   margin-top: 2px;
   color: var(--muted);
}

.icon-btn {
   width: 40px;
   height: 40px;
   border-radius: 12px;
   border: 1px solid transparent;
   background: transparent;
   color: var(--text);
   display: grid;
   place-items: center;
   cursor: pointer;
   flex: 0 0 auto;
}

.icon-btn:hover {
   background: var(--hover);
}

.icon-btn i {
   font-size: 20px;
   line-height: 1;
}

/* =========================
   MENU SUSPENSO (FLYOUT)
========================= */
.sidebar {
   position: fixed;
   z-index: var(--z-sidebar);
   top: calc(var(--header-h) + 10px);
   left: 12px;

   width: min(360px, calc(100vw - 24px));
   max-height: calc(100dvh - var(--header-h) - 24px);

   background: color-mix(in oklab, var(--elev), #fff 1%);
   border: 1px solid var(--border);
   border-radius: var(--r-xl);
   padding: 12px;
   box-shadow: var(--shadow);

   opacity: 0;
   transform: translateY(-8px);
   pointer-events: none;
}

.sidebar.is-open {
   opacity: 1;
   transform: translateY(0);
   pointer-events: auto;
}

.backdrop {
   position: fixed;
   inset: var(--header-h) 0 0 0;
   background: var(--overlay);
   backdrop-filter: blur(1px);
   z-index: var(--z-backdrop);
}

.backdrop[hidden] {
   display: none;
}

.content {
   min-height: 100dvh;
   padding: calc(var(--header-h) + 20px) var(--s-4) 32px;
}

/* =========================
   USER / DROPDOWN
========================= */
.dropdown {
   position: relative;
}

.user-pill {
   display: inline-flex;
   align-items: center;
   gap: 10px;
   height: 42px;
   padding: 0 10px;
   border-radius: 999px;
   border: 1px solid var(--border);
   background: color-mix(in oklab, var(--panel), #fff 2%);
   color: var(--text);
   cursor: pointer;
   min-width: 120px;
   max-width: min(360px, 46vw);
}

.user-pill .chev {
   font-size: 18px;
   opacity: .85;
}

#userNameTop {
   min-width: 0;
   white-space: nowrap;
   overflow: hidden;
   text-overflow: ellipsis;
}

.dropdown__menu {
   display: none;
   position: absolute;
   top: calc(100% + 8px);
   right: 0;

   width: 280px;
   max-width: min(320px, 90vw);

   padding: 6px;
   border-radius: var(--r-lg);
   background: var(--panel);
   border: 1px solid var(--border);
   box-shadow: var(--shadow);
   z-index: var(--z-dropdown);
}

.dropdown.is-open .dropdown__menu {
   display: block;
}

.dropdown__item {
   width: 100%;
   border: 0;
   background: transparent;
   color: var(--text);
   display: flex;
   align-items: center;
   gap: 10px;
   padding: 10px 12px;
   border-radius: 12px;
   cursor: pointer;
   text-align: left;
}

.dropdown__item:hover {
   background: var(--hover);
}

.dropdown__item i {
   font-size: 18px;
   line-height: 1;
   width: 20px;
   display: inline-flex;
   justify-content: center;
}

.dropdown__item.danger {
   color: var(--danger);
}

/* =========================
   SIDEBAR MENU
========================= */
.nav-scroll {
   overflow: auto;
   padding-right: 4px;
   min-height: 0;
   max-height: calc(100dvh - var(--header-h) - 64px);
}

.menu {
   display: grid;
   gap: 10px;
   padding: 0 4px 10px 4px;
}

.menu-section {
   border: 1px solid var(--border);
   border-radius: 16px;
   background: color-mix(in oklab, var(--panel), #fff 1%);
   overflow: hidden;
}

.section-header {
   width: 100%;
   border: 0;
   background: transparent;
   color: var(--text);
   display: flex;
   align-items: center;
   justify-content: space-between;
   gap: 10px;
   padding: 10px 12px;
   cursor: pointer;
   font-weight: 650;
}

.section-header:hover {
   background: var(--hover);
}

.section-title {
   display: flex;
   align-items: center;
   gap: 10px;
   min-width: 0;
}

.section-title i {
   font-size: 18px;
   line-height: 1;
}

.section-chevron {
   font-size: 18px;
}

.menu-section.is-collapsed .section-chevron {
   transform: rotate(-90deg);
}

.section-body {
   padding: 6px;
   display: grid;
   gap: 6px;
   border-top: 1px solid var(--border);
}

.menu-link {
   display: flex;
   align-items: center;
   gap: 10px;
   padding: 10px 10px;
   border-radius: 12px;
   color: var(--text);
}

.menu-link i {
   font-size: 18px;
   line-height: 1;
   width: 20px;
   display: inline-flex;
   justify-content: center;
}

.menu-link:hover {
   background: var(--hover);
}

.menu-link.active {
   background: color-mix(in oklab, var(--brand), #0000 85%);
   outline: 2px solid color-mix(in oklab, var(--brand), #fff 18%);
   outline-offset: 0;
}

/* =========================
   COMPONENTS
========================= */
.card {
   background: color-mix(in oklab, var(--panel), #fff 1%);
   border: 1px solid var(--border);
   border-radius: var(--r-xl);
   box-shadow: var(--shadow);
}

.card.pad {
   padding: var(--s-6);
}

.card-header {
   padding: var(--s-5) var(--s-6);
   border-bottom: 1px solid var(--border);
}

.card-body {
   padding: var(--s-6);
}

.card-footer {
   padding: var(--s-5) var(--s-6);
   border-top: 1px solid var(--border);
}

.btn {
   display: inline-flex;
   align-items: center;
   justify-content: center;
   gap: 10px;
   height: 44px;
   padding: 0 14px;
   border-radius: var(--r-md);
   border: 1px solid transparent;
   background: var(--brand);
   color: var(--brand-contrast);
   font-weight: 650;
   cursor: pointer;
   user-select: none;
}

.btn:hover {
   filter: brightness(1.06);
   transform: translateY(-1px);
}

.btn:active {
   transform: translateY(0);
}

.btn-outline {
   background: transparent;
   border-color: var(--border);
   color: var(--text);
}

.btn-outline:hover {
   background: var(--hover);
   border-color: transparent;
}

.btn-ghost {
   background: transparent;
   border-color: transparent;
   color: var(--text);
}

.btn-ghost:hover {
   background: var(--hover);
}

.btn[disabled],
.btn:disabled {
   opacity: 0.6;
   cursor: not-allowed;
   transform: none;
   filter: none;
}

.spinner {
   width: 16px;
   height: 16px;
   border: 2px solid currentColor;
   border-bottom-color: transparent;
   border-radius: 50%;
   display: inline-block;
   animation: spin .8s linear infinite;
}

@keyframes spin {
   to {
      transform: rotate(360deg);
   }
}

.form {
   display: grid;
   gap: var(--s-4);
}

.field {
   display: grid;
   gap: 8px;
}

.label {
   font-size: var(--fs-sm);
   color: color-mix(in oklab, var(--muted), var(--text) 10%);
   font-weight: 550;
}

.input,
select.input,
textarea.input {
   width: 100%;
   height: 44px;
   border-radius: var(--r-md);
   border: 1px solid var(--border);
   background: transparent;
   color: var(--text);
   padding: 10px 12px;
   outline: none;
}

textarea.input {
   min-height: 110px;
   height: auto;
   resize: vertical;
}

.input:focus,
select.input:focus,
textarea.input:focus {
   border-color: color-mix(in oklab, var(--ring), #fff 5%);
   box-shadow: 0 0 0 4px color-mix(in oklab, var(--ring), #0000 78%);
}

.badge {
   display: inline-flex;
   align-items: center;
   gap: 8px;
   padding: 6px 10px;
   border-radius: 999px;
   border: 1px solid var(--border);
   background: color-mix(in oklab, var(--panel), var(--text) 4%);
   font-weight: 650;
   font-size: var(--fs-xs);
}

.alert {
   border: 1px solid var(--border);
   background: color-mix(in oklab, var(--panel), #fff 2%);
   border-radius: var(--r-lg);
   padding: 12px 14px;
}

.alert.success {
   border-color: color-mix(in oklab, var(--success), #0000 65%);
   background: var(--success-bg);
}

.alert.warning {
   border-color: color-mix(in oklab, var(--warning), #0000 65%);
   background: var(--warning-bg);
}

.alert.danger {
   border-color: color-mix(in oklab, var(--danger), #0000 65%);
   background: var(--danger-bg);
}

.alert.info {
   border-color: color-mix(in oklab, var(--info), #0000 65%);
   background: var(--info-bg);
}

/* =========================
   AVATAR
========================= */
.avatar {
   width: 34px;
   height: 34px;
   min-width: 34px;
   min-height: 34px;
   border-radius: 999px;
   background: color-mix(in oklab, var(--panel), var(--text) 6%);
   display: inline-flex;
   align-items: center;
   justify-content: center;
   overflow: hidden;
   font-weight: 800;
   font-size: 12px;
   letter-spacing: .02em;
   line-height: 1;
   text-align: center;
   border: 1px solid var(--border);
   color: var(--text);
   vertical-align: middle;
   flex: 0 0 auto;
   position: relative;
}

.avatar__img,
.avatar__fallback {
   position: absolute;
   inset: 0;
   width: 100%;
   height: 100%;
}

.avatar__img {
   display: none;
   width: 100%;
   height: 100%;
   object-fit: cover;
   object-position: center center;
   border-radius: inherit;
}

.avatar__fallback {
   display: flex;
   align-items: center;
   justify-content: center;
   font: inherit;
   color: inherit;
}

.avatar.has-image {
   background: transparent;
   border-color: transparent;
}

.avatar.has-image .avatar__img {
   display: block;
}

.avatar.has-image .avatar__fallback {
   display: none;
}

.avatar--sm {
   width: 36px;
   height: 36px;
   min-width: 36px;
   min-height: 36px;
   font-size: 11px;
}

.avatar--lg {
   width: 46px;
   height: 46px;
   min-width: 46px;
   min-height: 46px;
   font-size: 14px;
}

#userAvatar {
   width: 40px;
   height: 40px;
   min-width: 40px;
   min-height: 40px;
   overflow: hidden;
   border-radius: 999px;
}

#userAvatar .avatar__img {
   width: 100%;
   height: 100%;
   object-position: center center;
}

#userAvatar.avatar--cover .avatar__img {
   object-fit: cover;
}

#userAvatar.avatar--contain .avatar__img {
   object-fit: contain;
   background: color-mix(in oklab, var(--panel), #fff 4%);
}

/* bloqueia transições durante a troca de tema */
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
   transition: none !important;
}

/* =========================
   MOBILE
========================= */
@media (max-width: 520px) {
   .brand-text {
      display: none;
   }

   .brand-logo {
      max-width: 120px;
   }
}

/* =========================
   AUTOFILL
========================= */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill {
   -webkit-text-fill-color: var(--text) !important;
   caret-color: var(--text) !important;
   border: 1px solid var(--border) !important;
   -webkit-box-shadow: 0 0 0 1000px transparent inset !important;
   box-shadow: 0 0 0 1000px transparent inset !important;
   background-color: transparent !important;
   transition: background-color 99999s ease-in-out 0s;
}

html[data-theme="dark"] input:-webkit-autofill,
html[data-theme="dark"] input:-webkit-autofill:hover,
html[data-theme="dark"] input:-webkit-autofill:focus,
html[data-theme="dark"] textarea:-webkit-autofill,
html[data-theme="dark"] select:-webkit-autofill {
   -webkit-text-fill-color: var(--text) !important;
   caret-color: var(--text) !important;
   -webkit-box-shadow: 0 0 0 1000px var(--panel) inset !important;
   box-shadow: 0 0 0 1000px var(--panel) inset !important;
   border: 1px solid var(--border) !important;
}

html[data-theme="light"] input:-webkit-autofill,
html[data-theme="light"] input:-webkit-autofill:hover,
html[data-theme="light"] input:-webkit-autofill:focus,
html[data-theme="light"] textarea:-webkit-autofill,
html[data-theme="light"] select:-webkit-autofill {
   -webkit-text-fill-color: var(--text) !important;
   caret-color: var(--text) !important;
   -webkit-box-shadow: 0 0 0 1000px var(--panel) inset !important;
   box-shadow: 0 0 0 1000px var(--panel) inset !important;
   border: 1px solid var(--border) !important;
}