/* ==========================================================================
   Componentes (redesign denso). Depende de tokens.css + base.css.
   ========================================================================== */

/* ---- Page header (H1 + ação na mesma linha; sem subtítulo genérico) ---- */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-6); }
.page-header h1 { font-size: var(--fs-xl); font-weight: 600; }
.page-header p { color: var(--text-dim); font-size: var(--fs-base); margin-top: 2px; }
.page-header__actions { display: flex; align-items: center; gap: var(--sp-2); }

.section-label { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .08em; color: var(--text-mute); font-weight: 600; margin-bottom: var(--sp-3); }

/* ---- Barra de métricas (substitui stat cards) ---- */
.metrics { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; margin-bottom: var(--sp-6); }
.metric { flex: 1; padding: var(--sp-4) var(--sp-5); min-width: 0; border-left: 1px solid var(--border); }
.metric:first-child { border-left: 0; }
.metric__value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--fs-2xl); font-weight: 500; line-height: 1; color: var(--text); }
.metric__label { font-size: var(--fs-xs); color: var(--text-dim); margin-top: 6px; }
a.metric { transition: background-color var(--d-2) var(--e-out); }
a.metric:hover { background: var(--surface-2); text-decoration: none; }
@media (max-width: 720px) { .metrics { flex-wrap: wrap; } .metric { flex: 1 0 40%; border-top: 1px solid var(--border); } }

/* ---- Listas densas (servidores, changelogs, categorias, publicações) ---- */
.list { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.list-row {
    display: flex; align-items: center; gap: var(--sp-3); height: 44px; padding: 0 var(--sp-4);
    border-top: 1px solid var(--border); color: var(--text); position: relative;
    transition: background-color var(--d-1) linear;
}
.list-row:first-child { border-top: 0; }
.list-row:hover { background: var(--surface-2); text-decoration: none; }
.list-row__main { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--sp-3); overflow: hidden; }
.list-row__title { font-weight: 500; font-size: var(--fs-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row__meta { color: var(--text-dim); font-size: var(--fs-xs); white-space: nowrap; }
.list-row__meta .mono { font-size: var(--fs-xs); }
.list-row__actions { display: flex; align-items: center; gap: 2px; opacity: 0; transition: opacity var(--d-1) var(--e-out); }
.list-row:hover .list-row__actions, .list-row:focus-within .list-row__actions { opacity: 1; }
@media (hover: none) { .list-row__actions { opacity: 1; } }

.dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; background: var(--text-mute); }
.color-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.color-dot--lg { width: 10px; height: 10px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }

/* categorias */
.cat-grip { color: var(--text-mute); cursor: grab; display: grid; place-items: center; opacity: 0; transition: opacity var(--d-1); }
.list-row:hover .cat-grip { opacity: 1; }
.cat-ico { color: var(--text-dim); display: grid; place-items: center; }
.emoji-token { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-mute); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 2px 6px; cursor: pointer; max-width: 220px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.emoji-token:hover { color: var(--text-dim); border-color: var(--border-hi); }
.emoji-token svg { width: 12px; height: 12px; flex-shrink: 0; }
.icon-btn.is-active { color: var(--warn); }
.check-inline { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--text-dim); font-size: var(--fs-sm); cursor: pointer; }
.check-inline input { accent-color: var(--accent); }
.is-loading { opacity: .6; pointer-events: none; }
.is-dragging { opacity: .5; }

.server-logo { width: 26px; height: 26px; border-radius: var(--r-sm); display: grid; place-items: center; padding: 3px; flex-shrink: 0; }
.server-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---- Avatar ---- */
.avatar { width: 24px; height: 24px; border-radius: var(--r-full); display: grid; place-items: center; flex-shrink: 0; font-size: var(--fs-2xs); font-weight: 600; color: #fff; background: var(--v-600); overflow: hidden; object-fit: cover; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 20px; height: 20px; }
.avatar--lg { width: 40px; height: 40px; font-size: var(--fs-sm); }

/* ---- Dropdown ---- */
.dropdown { position: relative; }
.dropdown__menu {
    position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; padding: var(--sp-1);
    background: var(--surface-2); border: 1px solid var(--border-hi); border-radius: var(--r-md);
    box-shadow: var(--sh-lg); display: none; z-index: var(--z-dropdown);
}
.dropdown.is-open .dropdown__menu { display: block; }
.dropdown--up .dropdown__menu { top: auto; bottom: calc(100% + 6px); left: 0; right: auto; }
.dropdown__item {
    display: flex; align-items: center; gap: var(--sp-2); width: 100%; height: 30px; padding: 0 var(--sp-2);
    border-radius: var(--r-sm); border: 0; background: none; color: var(--text); font: inherit; font-size: var(--fs-base);
    text-align: left; cursor: pointer;
}
.dropdown__item:hover { background: var(--surface-3); text-decoration: none; }
.dropdown__item svg { width: 15px; height: 15px; color: var(--text-dim); }
.dropdown__sep { height: 1px; background: var(--border); margin: var(--sp-1) 0; }
.dropdown__header { padding: var(--sp-2); }
.dropdown__header .name { font-weight: 500; font-size: var(--fs-base); }
.dropdown__header .meta { font-size: var(--fs-xs); color: var(--text-mute); overflow: hidden; text-overflow: ellipsis; }
.dropdown__menu form { width: 100%; margin: 0; }

/* ---- Tabela densa ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
.table th, .table td { padding: 9px var(--sp-4); text-align: left; }
.table thead th { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text-mute); border-bottom: 1px solid var(--border); font-weight: 600; height: 34px; }
.table tbody tr { border-top: 1px solid var(--border); transition: background-color var(--d-1) linear; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.mono, .table td .mono { font-variant-numeric: tabular-nums; }

/* ---- Empty state ---- */
.empty { text-align: center; padding: var(--sp-12) var(--sp-5); border: 1px dashed var(--border-hi); border-radius: var(--r-lg); color: var(--text-dim); }
.empty__icon { width: 40px; height: 40px; margin: 0 auto var(--sp-4); color: var(--text-mute); display: grid; place-items: center; border-radius: var(--r-md); background: var(--surface-2); }
.empty h3 { color: var(--text); font-size: var(--fs-md); margin-bottom: var(--sp-2); }
.empty p { font-size: var(--fs-base); }

/* ---- Pills ---- */
.pill-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.pill { padding: 4px var(--sp-3); border-radius: var(--r-full); border: 1px solid var(--border-hi); background: var(--surface-2); font-size: var(--fs-sm); color: var(--text-dim); }

/* ---- Input com ícone ---- */
.input-group { position: relative; display: flex; align-items: center; }
.input-group > svg { position: absolute; left: var(--sp-3); width: 15px; height: 15px; color: var(--text-mute); pointer-events: none; }
.input-group .input { padding-left: 34px; }
.input-group .input-toggle { position: absolute; right: 6px; background: none; border: 0; color: var(--text-mute); cursor: pointer; padding: 4px; border-radius: var(--r-sm); }
.input-group .input-toggle:hover { color: var(--text); }

/* ---- Modal ---- */
.modal-backdrop { position: fixed; inset: 0; z-index: var(--z-overlay); background: rgba(2,2,4,.6); backdrop-filter: blur(8px); display: none; place-items: center; padding: var(--sp-4); }
.modal-backdrop.is-open { display: grid; }
.modal { width: min(460px, 100%); background: var(--surface-2); border: 1px solid var(--border-hi); border-radius: var(--r-xl); box-shadow: var(--sh-xl); padding: var(--sp-6); }
.modal h3 { font-size: var(--fs-lg); margin-bottom: var(--sp-3); }
.modal__actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-5); }

/* ---- Command palette ---- */
.palette-backdrop { position: fixed; inset: 0; z-index: var(--z-overlay); background: rgba(2,2,4,.5); backdrop-filter: blur(6px); display: none; justify-content: center; align-items: flex-start; padding-top: 12vh; }
.palette-backdrop.is-open { display: flex; }
.palette { width: min(560px, 92vw); background: var(--surface-2); border: 1px solid var(--border-hi); border-radius: var(--r-xl); box-shadow: var(--sh-xl); overflow: hidden; }
.palette__input { display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-4); height: 48px; border-bottom: 1px solid var(--border); }
.palette__input svg { width: 17px; height: 17px; color: var(--text-mute); }
.palette__input input { flex: 1; background: none; border: 0; outline: none; font: inherit; font-size: var(--fs-md); color: var(--text); }
.palette__results { max-height: 52vh; overflow-y: auto; padding: var(--sp-2); }
.palette__group-label { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .08em; color: var(--text-mute); padding: var(--sp-2) var(--sp-2) var(--sp-1); }
.palette__item { display: flex; align-items: center; gap: var(--sp-3); height: 36px; padding: 0 var(--sp-2); border-radius: var(--r-md); color: var(--text); cursor: pointer; }
.palette__item svg { width: 16px; height: 16px; color: var(--text-dim); flex-shrink: 0; }
.palette__item .meta { margin-left: auto; font-size: var(--fs-xs); color: var(--text-mute); }
.palette__item.is-active, .palette__item:hover { background: var(--v-a12); color: var(--text); }
.palette__item.is-active svg { color: var(--v-300); }
.palette__empty { padding: var(--sp-6); text-align: center; color: var(--text-mute); font-size: var(--fs-base); }
.palette__foot { display: flex; gap: var(--sp-4); padding: var(--sp-2) var(--sp-4); border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-mute); }
.kbd { font-family: var(--font-mono); font-size: var(--fs-2xs); background: var(--surface-3); border: 1px solid var(--border-hi); border-radius: 4px; padding: 1px 5px; color: var(--text-dim); }

/* ---- Toasts ---- */
.toast-region { position: fixed; top: var(--sp-4); right: var(--sp-4); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--sp-2); width: min(340px, calc(100vw - var(--sp-6))); pointer-events: none; }
.toast { pointer-events: auto; position: relative; display: flex; align-items: flex-start; gap: var(--sp-3); padding: 10px var(--sp-3); border-radius: var(--r-md); border: 1px solid var(--border-hi); background: var(--surface-2); box-shadow: var(--sh-lg); color: var(--text); font-size: var(--fs-base); overflow: hidden; opacity: 0; }
.toast.is-visible { opacity: 1; }
.toast__icon { flex-shrink: 0; margin-top: 1px; }
.toast__icon svg { width: 16px; height: 16px; }
.toast__body { flex: 1; line-height: 1.4; }
.toast__close { background: none; border: 0; color: var(--text-mute); cursor: pointer; padding: 2px; border-radius: var(--r-sm); }
.toast__close:hover { color: var(--text); }
.toast__bar { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; transform-origin: left; background: var(--v-500); }
.toast--success .toast__icon { color: var(--ok); } .toast--success .toast__bar { background: var(--ok); }
.toast--error .toast__icon { color: var(--err); } .toast--error .toast__bar { background: var(--err); }
.toast--warning .toast__icon { color: var(--warn); } .toast--warning .toast__bar { background: var(--warn); }
.toast--info .toast__icon { color: var(--info); }

/* ---- Skeleton ---- */
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-sm); min-height: 1em; }
.skel-line { height: 12px; }
.skel-60 { width: 60%; }
.skeleton::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface-3) 80%, transparent), transparent); }

/* ---- Diff ---- */
.diff-line { padding: 6px var(--sp-3); border-radius: var(--r-sm); font-size: var(--fs-base); margin-bottom: 3px; font-family: var(--font-mono); }
.diff-add { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.diff-del { background: color-mix(in srgb, var(--err) 14%, transparent); color: var(--err); }

/* ---- Search ---- */
.search-group { margin-bottom: var(--sp-5); }
.search-group h3 { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text-mute); margin-bottom: var(--sp-2); }
.search-item { display: flex; align-items: center; gap: var(--sp-3); height: 38px; padding: 0 var(--sp-3); border-radius: var(--r-md); color: var(--text); }
.search-item:hover { background: var(--surface-2); text-decoration: none; }
.search-item svg { width: 15px; height: 15px; color: var(--text-dim); }

/* ---- Paginação ---- */
.pagination { display: flex; gap: var(--sp-2); justify-content: center; align-items: center; margin-top: var(--sp-5); font-size: var(--fs-sm); color: var(--text-dim); }
.pagination a { padding: 5px var(--sp-3); border-radius: var(--r-md); border: 1px solid var(--border-hi); color: var(--text-dim); }
.pagination a:hover { color: var(--text); border-color: var(--border-hot); text-decoration: none; }
.pagination .is-disabled { opacity: .4; pointer-events: none; }

.log-json { margin-top: var(--sp-2); padding: var(--sp-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); font-size: var(--fs-xs); white-space: pre-wrap; word-break: break-word; max-width: 440px; overflow-x: auto; font-family: var(--font-mono); }
details summary { cursor: pointer; color: var(--text-dim); font-size: var(--fs-sm); }

.form-card { max-width: 620px; }
.form-card__actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-5); }

/* ---- Réplica da mensagem do Discord (paleta do Discord, não a da marca) ---- */
.discord-msg { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: #313338; color: #dbdee1; margin-bottom: var(--sp-2); }
.discord-msg__avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--v-600); color: #fff; display: grid; place-items: center; font-weight: 700; flex-shrink: 0; overflow: hidden; }
.discord-msg__avatar img { width: 100%; height: 100%; object-fit: cover; }
.discord-msg__author { font-weight: 600; color: #f2f3f5; margin-bottom: 3px; display: flex; align-items: center; gap: 6px; font-size: var(--fs-md); }
.discord-msg__tag { font-size: 10px; background: var(--v-600); color: #fff; border-radius: 4px; padding: 0 4px; font-weight: 600; text-transform: uppercase; }
.discord-msg__content { font-size: var(--fs-md); line-height: 1.5; word-break: break-word; }
.dc-h1 { font-size: 1.35em; font-weight: 700; color: #fff; margin: 4px 0; }
.dc-h2 { font-size: 1.12em; font-weight: 700; color: #fff; margin: 8px 0 2px; }
.dc-li { padding-left: 1.3em; position: relative; }
.dc-li::before { content: '•'; position: absolute; left: .4em; color: #b5bac1; }
.dc-gap { height: .5em; }
.dc-emoji { display: inline-block; background: rgba(255,255,255,.08); border-radius: 4px; padding: 0 4px; font-size: .85em; color: #c9cdd4; }
.dc-spoiler { background: #202225; color: #202225; border-radius: 4px; padding: 0 3px; }
.discord-msg code { background: #1e1f22; padding: 1px 4px; border-radius: 4px; font-family: var(--font-mono); font-size: .85em; }

/* ---- Layout de publicação/templates ---- */
.publish-grid { display: grid; grid-template-columns: 1fr 340px; gap: var(--sp-5); align-items: start; }
@media (max-width: 880px) { .publish-grid { grid-template-columns: 1fr; } }
.mini-label { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .08em; color: var(--text-mute); font-weight: 600; margin-bottom: var(--sp-3); }
.tpl-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: 9px 0; border-top: 1px solid var(--border); font-size: var(--fs-base); }
.tpl-row:first-child { border-top: 0; }
.skeleton::after { animation: qs-shimmer 1.15s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .skeleton::after { animation: none; } }
@keyframes qs-shimmer { to { transform: translateX(100%); } }
.spin { animation: qs-spin .8s linear infinite; }
@keyframes qs-spin { to { transform: rotate(360deg); } }

.theme-toggle-fixed { position: fixed; top: var(--sp-4); right: var(--sp-4); z-index: var(--z-sticky); background: var(--surface-2); border: 1px solid var(--border-hi); }
