/* ============================================================
   PAINEL ADMIN — usa as variáveis de tema definidas em app.css
   (btn*, chip*, icon-btn*, logo-box*, price-*, alert*, flash,
    empty-state, badge-icon e fade-in vêm de app.css)
   ============================================================ */

/* ---------- LAYOUT BASE ---------- */
.admin-body { display: flex; min-height: 100vh; background: var(--bg); }

.sidebar {
  width: 258px; flex-shrink: 0; background: var(--secondary); color: #fff;
  display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 60;
  transition: transform .25s ease;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px; padding: 18px 18px;
  font-weight: 800; font-size: 17px; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar__brand span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__nav { flex: 1; overflow-y: auto; padding: 10px 12px; }
.sidebar__section {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: rgba(255,255,255,.45); padding: 14px 10px 6px; font-weight: 700;
}
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px;
  color: rgba(255,255,255,.82); font-weight: 500; font-size: 14.5px; margin-bottom: 2px;
  transition: background .14s, color .14s;
}
.nav-item:hover { background: rgba(255,255,255,.10); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item svg { flex-shrink: 0; }
.sidebar__foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar__foot .nav-item { color: rgba(255,255,255,.75); }

.admin-main {
  flex: 1; margin-left: 258px; display: flex; flex-direction: column; min-width: 0;
}

/* ---------- TOPBAR ---------- */
.topbar {
  height: 62px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
  position: sticky; top: 0; z-index: 40;
}
.topbar__toggle {
  display: none; width: 40px; height: 40px; border-radius: 10px;
  background: var(--surface-2); color: var(--text); place-items: center;
}
.breadcrumb { font-size: 14px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb strong { color: var(--text); font-weight: 700; }
.topbar__spacer { flex: 1; }
.topbar__user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700; flex-shrink: 0;
}
.avatar--sm { width: 32px; height: 32px; font-size: 13px; }

.content { padding: 22px; flex: 1; }

/* ---------- CABEÇALHO DE PÁGINA ---------- */
.page-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-bottom: 22px; flex-wrap: wrap;
}
.page-title { font-size: 24px; font-weight: 800; }
.page-sub { color: var(--text-muted); font-size: 14px; margin-top: 2px; }

/* ---------- STAT CARDS ---------- */
.stats-grid {
  display: grid; gap: 14px; grid-template-columns: repeat(2, 1fr); margin-bottom: 22px;
}
@media (min-width: 640px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .stats-grid { grid-template-columns: repeat(6, 1fr); } }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px;
}
.stat-card__icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0;
}
.stat-card__value { font-size: 22px; font-weight: 800; line-height: 1.1; }
.stat-card__label { color: var(--text-muted); font-size: 12.5px; }

/* ---------- GRID 2 COLUNAS ---------- */
.grid-2 { display: grid; gap: 16px; margin-bottom: 16px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* ---------- CARDS ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: 16px;
}
.card__head {
  padding: 15px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card__head h2 { font-size: 15.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card__head h2 svg { color: var(--primary); }
.card__body { padding: 18px; }
.card__body--flush { padding: 0; }
.card__foot { padding: 15px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }

.link-sm { font-size: 13px; font-weight: 600; color: var(--primary); }
.empty-hint { color: var(--text-muted); font-size: 14px; text-align: center; padding: 10px 0; }

/* ---------- DASHBOARD: BAR CHART ---------- */
.bar-chart { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.bar-row__label { width: 110px; flex-shrink: 0; color: var(--text-muted); text-align: right; }
.bar-row__track { flex: 1; height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-row__fill { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width .5s ease; }
.bar-row__value { width: 34px; text-align: left; font-weight: 700; }

/* ---------- DASHBOARD: RANK ---------- */
.rank-list { display: flex; flex-direction: column; gap: 10px; }
.rank-list li { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.rank-badge {
  width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); color: var(--primary);
  display: grid; place-items: center; font-weight: 800; font-size: 13px; flex-shrink: 0;
}
.rank-name { flex: 1; font-weight: 600; }
.rank-val { color: var(--text-muted); font-size: 13px; }

/* ---------- DASHBOARD: MINI LIST ---------- */
.mini-list { display: flex; flex-direction: column; }
.mini-list li { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.mini-list li:last-child { border-bottom: none; }
.mini-thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }
.mini-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.mini-info strong { font-size: 14px; }
.mini-info span { font-size: 12.5px; color: var(--text-muted); }
.mini-file-ic { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-2); color: var(--primary); display: grid; place-items: center; flex-shrink: 0; }

/* ---------- DASHBOARD: LOG LIST ---------- */
.log-list { display: flex; flex-direction: column; }
.log-list li { display: flex; align-items: flex-start; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--border); font-size: 13px; }
.log-list li:last-child { border-bottom: none; }
.log-list li > div { flex: 1; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.log-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex-shrink: 0; }
.log-action { color: var(--text-muted); }
.log-detail { color: var(--text-muted); font-style: italic; }
.log-list time { color: var(--text-muted); white-space: nowrap; font-size: 12px; }

/* ---------- TABELAS ---------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table th {
  background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-muted); font-weight: 700; white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
.cell-nowrap { white-space: nowrap; }
.cell-sub { color: var(--text-muted); font-size: 12.5px; display: block; }
.ta-center { text-align: center; }
.ta-right { text-align: right; }
td.ta-right .list-actions { justify-content: flex-end; }
.user-cell { display: flex; align-items: center; gap: 10px; }

/* ---------- LISTA ORDENÁVEL (categorias) ---------- */
.sortable-list { display: flex; flex-direction: column; }
.sortable-item {
  display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.sortable-item:last-child { border-bottom: none; }
.sortable-item.dragging { opacity: .5; background: var(--surface-2); }
.drag-handle { cursor: grab; color: var(--text-muted); display: inline-flex; flex-shrink: 0; }
.drag-handle:active { cursor: grabbing; }
.list-thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }
.list-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.list-main strong { font-size: 14.5px; }
.list-meta { font-size: 12.5px; color: var(--text-muted); }
.list-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.list-actions { display: flex; gap: 6px; align-items: center; }
.inline { display: inline; }

/* ---------- FORMULÁRIOS ---------- */
.form-grid { display: flex; flex-direction: column; gap: 0; }
.form-fields { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field label { font-size: 13.5px; font-weight: 600; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hint-text { font-size: 12.5px; color: var(--text-muted); }
.hint-text code, .card code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 12px; }

input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="url"], input[type="tel"], input[type="search"],
select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 14.5px; font-family: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
textarea { resize: vertical; min-height: 90px; }
input[type="color"] { width: 100%; height: 42px; padding: 3px; cursor: pointer; }

/* form de 2 colunas (produto) */
.form-2col { display: grid; gap: 16px; align-items: start; }
@media (min-width: 960px) { .form-2col { grid-template-columns: 1fr 340px; } }
.form-2col__main, .form-2col__side { display: flex; flex-direction: column; min-width: 0; }

/* senha com olho */
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { padding-right: 44px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); padding: 6px; display: inline-flex; border-radius: 8px;
}
.pw-toggle:hover { background: var(--surface-2); }

/* switch */
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch__track { width: 44px; height: 25px; border-radius: 999px; background: var(--border); position: relative; transition: background .2s; flex-shrink: 0; }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .switch__track { background: var(--primary); }
.switch input:checked + .switch__track::after { transform: translateX(19px); }
.switch__label { font-size: 14px; font-weight: 500; }
.switch--admin { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); margin-bottom: 16px; }

/* checkbox inline / cards de permissão */
.check-inline { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); cursor: pointer; margin-top: 8px; }
.check-inline input { width: auto; }
.check-card {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13.5px; cursor: pointer; transition: border-color .15s, background .15s;
}
.check-card input { width: auto; }
.check-card:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }

/* grupos de permissões */
.perms-box { transition: opacity .2s; }
.perms-box.is-disabled { opacity: .45; pointer-events: none; }
.perm-group { margin-bottom: 18px; }
.perm-group__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.perm-group__head strong { font-size: 14px; }
.perm-toggle-all { background: none; }
.perm-items { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .perm-items { grid-template-columns: 1fr 1fr; } }

.form-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

/* input de arquivo estilizado */
.file-field { position: relative; display: block; cursor: pointer; }
.file-field input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-field span {
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px;
  border: 2px dashed var(--border); border-radius: var(--radius-sm); color: var(--text-muted);
  font-size: 14px; transition: border-color .15s;
}
.file-field:hover span { border-color: var(--primary); color: var(--primary); }

/* ---------- UPLOAD DE IMAGENS ---------- */
.image-uploader { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.image-uploader--row { flex-direction: row; align-items: center; }
.image-preview {
  width: 100%; max-width: 260px; aspect-ratio: 16/9; border-radius: var(--radius-sm);
  object-fit: cover; background: var(--surface-2); border: 1px solid var(--border);
}
.image-preview--sm { width: 64px; height: 64px; aspect-ratio: 1; }

.uploader-drop {
  border: 2px dashed var(--border); border-radius: var(--radius-sm); padding: 26px; text-align: center;
  color: var(--text-muted); cursor: pointer; transition: border-color .15s, background .15s; margin-top: 12px;
}
.uploader-drop svg { color: var(--primary); }
.uploader-drop p { margin-top: 6px; font-size: 14px; }
.uploader-drop.dragover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.upload-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin-top: 10px; }
.upload-preview img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

/* galeria existente */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; margin-bottom: 12px; }
.gallery__item { position: relative; border-radius: var(--radius-sm); overflow: hidden; aspect-ratio: 1; border: 2px solid var(--border); }
.gallery__item.is-cover { border-color: var(--primary); }
.gallery__item img { width: 100%; height: 100%; object-fit: cover; }
.gallery__badge { position: absolute; top: 6px; left: 6px; background: var(--primary); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.gallery__ov { position: absolute; inset: auto 0 0 0; display: flex; gap: 4px; padding: 6px; justify-content: flex-end; background: linear-gradient(transparent, rgba(0,0,0,.55)); }
.gallery__ov .icon-btn { background: rgba(255,255,255,.9); }
.gallery__ov form { display: inline; }

/* ---------- GRID DE PRODUTOS (admin) ---------- */
.product-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: transform .15s, box-shadow .2s;
}
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.product-card__media { position: relative; aspect-ratio: 1; overflow: hidden; background: var(--surface-2); }
.product-card__media img { width: 100%; height: 100%; object-fit: cover; }
.product-card__tags { position: absolute; top: 8px; left: 8px; display: flex; flex-direction: column; gap: 4px; }
.pub-toggle {
  position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 50%;
  background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; transition: background .15s;
}
.pub-toggle.is-on { background: var(--success); }
.product-card__body { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.product-card__cat { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--primary); font-weight: 700; }
.product-card__body h3 { font-size: 14.5px; font-weight: 700; line-height: 1.25; }
.product-card__price { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.product-card__actions { display: flex; gap: 6px; align-items: center; padding: 0 14px 14px; }
.product-card__actions .btn--block { flex: 1; }

/* ---------- FILTROS ---------- */
.filters-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 14px; margin-bottom: 16px;
}
.filters-bar select, .filters-bar .btn { width: auto; }
.search-input { position: relative; flex: 1; min-width: 200px; display: flex; align-items: center; }
.search-input svg { position: absolute; left: 12px; color: var(--text-muted); pointer-events: none; }
.search-input input { padding-left: 40px; border-radius: 999px; }

/* ---------- PAGINAÇÃO ---------- */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.pagination a {
  min-width: 38px; height: 38px; padding: 0 10px; border-radius: var(--radius-sm);
  display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border);
  font-size: 14px; font-weight: 600;
}
.pagination a:hover { border-color: var(--primary); }
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- TEMAS (seletor) ---------- */
.theme-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .theme-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 980px) { .theme-grid { grid-template-columns: repeat(5, 1fr); } }
.theme-card { border: 2px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; background: var(--surface); transition: transform .12s, border-color .15s; }
.theme-card:hover { transform: translateY(-2px); }
.theme-card.is-active { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
.theme-card__preview { height: 66px; position: relative; display: block; }
.theme-card__bar { position: absolute; left: 0; right: 0; bottom: 0; height: 22px; }
.theme-card__dot { position: absolute; top: 12px; width: 18px; height: 18px; border-radius: 50%; }
.theme-card__dot:nth-of-type(2) { left: 14px; }
.theme-card__dot:nth-of-type(3) { left: 38px; }
.theme-card__name { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px; font-size: 13.5px; font-weight: 600; }
.theme-card__check { opacity: 0; color: var(--primary); }
.theme-card.is-active .theme-card__check { opacity: 1; }

/* ---------- AUTENTICAÇÃO ---------- */
.auth-body {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(circle at 20% 15%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 42%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 410px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 32px; }
.auth-brand { text-align: center; margin-bottom: 22px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.auth-brand h1 { font-size: 21px; }
.auth-brand p { color: var(--text-muted); font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-hint { margin-top: 18px; padding: 12px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 13px; color: var(--text-muted); text-align: center; line-height: 1.6; }
.auth-hint a { color: var(--primary); font-weight: 600; }

/* ---------- OVERLAY MOBILE ---------- */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 55; }

/* ---------- RESPONSIVO ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .topbar__toggle { display: grid; }
  .sidebar-overlay.show { display: block; }
  .field-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
