/* =========================================================================
   Inteligência de Mercado — estilos do módulo.
   Usa os tokens globais (--hm-*) para acompanhar light/dark automaticamente.
   Estilo sóbrio/flat alinhado ao restante do Hype Metrics.
   ========================================================================= */

.mkt-view { display: block; }
.mkt-panel { display: block; }

/* ---- Aviso "em desenvolvimento" ---- */
.mkt-devbanner {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
  padding: 10px 14px; border-radius: 12px; font-size: 13px; color: #92400e;
  background: #fef3c7; border: 1px solid #fde68a;
}
.mkt-devbanner strong { font-weight: 700; }
:root[data-theme="dark"] .mkt-devbanner { background: #3a2e12; color: #fde68a; border-color: #57430f; }
.mkt-devmodal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; }
.mkt-devmodal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.5); }
.mkt-devmodal-card {
  position: relative; width: min(420px, 92vw); background: var(--hm-surface);
  border: 1px solid var(--hm-border); border-radius: 18px; padding: 28px; text-align: center;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
}
.mkt-devmodal-icon { font-size: 40px; margin-bottom: 6px; }
.mkt-devmodal-card h3 { margin: 0 0 8px; font-size: 19px; color: var(--hm-text); }
.mkt-devmodal-card p { margin: 0 0 18px; color: var(--hm-muted); font-size: 14px; }

.mkt-muted { color: var(--hm-muted); font-size: 13px; }
.mkt-error { color: #dc2626; }

/* ---- Hero / home cards ---- */
.mkt-hero { margin-bottom: 20px; }
.mkt-hero h2 { margin: 0 0 4px; font-size: 22px; color: var(--hm-text); }
.mkt-hero p { margin: 0; color: var(--hm-muted); }
.mkt-home-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.mkt-big-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  text-align: left; padding: 24px; border: 1px solid var(--hm-border);
  border-radius: 16px; background: var(--hm-surface); cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.mkt-big-card:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(15, 23, 42, 0.10); border-color: var(--hm-primary); }
.mkt-big-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 12px; background: color-mix(in srgb, var(--hm-primary) 12%, transparent); color: var(--hm-primary); }
.mkt-big-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mkt-big-title { font-size: 17px; font-weight: 700; color: var(--hm-text); }
.mkt-big-desc { color: var(--hm-muted); font-size: 13px; }
.mkt-big-cta { margin-top: 6px; padding: 8px 18px; border-radius: 10px; background: var(--hm-primary); color: #fff; font-weight: 600; font-size: 13px; }

/* ---- Search ---- */
.mkt-section-header { margin-bottom: 16px; }
.mkt-search { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 20px; }
.mkt-search-field { display: flex; flex-direction: column; gap: 6px; flex: 1 1 260px; }
.mkt-search-field label { font-size: 12px; font-weight: 600; color: var(--hm-muted); text-transform: uppercase; letter-spacing: .04em; }
.mkt-search input, .mkt-own-price, .mkt-ranking-tools input, .mkt-ranking-tools select {
  padding: 10px 12px; border: 1px solid var(--hm-border); border-radius: 10px;
  background: var(--hm-surface); color: var(--hm-text); font-size: 14px; outline: none;
}
.mkt-search input:focus, .mkt-own-price:focus { border-color: var(--hm-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hm-primary) 18%, transparent); }
.mkt-own-price { width: 170px; }
.mkt-btn { padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; font-size: 14px; cursor: pointer; }
.mkt-btn-primary { background: var(--hm-primary); color: #fff; }
.mkt-btn-primary:disabled { opacity: .6; cursor: default; }
.mkt-btn-ghost { background: var(--hm-surface); border-color: var(--hm-border); color: var(--hm-text); }
.mkt-btn-ghost:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Loading / empty ---- */
.mkt-loading { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 60px 0; color: var(--hm-muted); }
.mkt-spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--hm-border); border-top-color: var(--hm-primary); animation: mkt-spin 0.9s linear infinite; }
@keyframes mkt-spin { to { transform: rotate(360deg); } }
.mkt-empty { padding: 30px 0; }

/* ---- Product card ---- */
.mkt-product-card { display: flex; gap: 18px; padding: 20px; border: 1px solid var(--hm-border); border-radius: 16px; background: var(--hm-surface); margin-bottom: 18px; }
.mkt-product-empty { color: var(--hm-muted); padding: 8px; }
.mkt-product-media img, .mkt-product-media .mkt-noimg { width: 96px; height: 96px; object-fit: contain; border-radius: 12px; background: var(--hm-surface-muted); border: 1px solid var(--hm-border); }
.mkt-product-info h3 { margin: 0 0 10px; font-size: 18px; color: var(--hm-text); }
.mkt-product-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.mkt-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--hm-surface-muted); border: 1px solid var(--hm-border); font-size: 12px; color: var(--hm-text); }
.mkt-chip em { color: var(--hm-muted); font-style: normal; font-weight: 600; }
.mkt-product-updated { margin-top: 10px; font-size: 12px; color: var(--hm-muted); }

/* ---- KPIs ---- */
.mkt-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.mkt-kpi { padding: 14px 16px; border: 1px solid var(--hm-border); border-radius: 12px; background: var(--hm-surface); display: flex; flex-direction: column; gap: 4px; }
.mkt-kpi-label { font-size: 12px; color: var(--hm-muted); }
.mkt-kpi-value { font-size: 20px; font-weight: 700; color: var(--hm-text); }
.mkt-kpi.good .mkt-kpi-value { color: #16a34a; }
.mkt-kpi.bad .mkt-kpi-value { color: #dc2626; }

/* ---- Hype AI ---- */
.mkt-ai-card { border: 1px solid var(--hm-border); border-radius: 16px; background: var(--hm-surface); padding: 18px; margin-bottom: 18px; }
.mkt-ai-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.mkt-ai-head h3 { margin: 0; font-size: 15px; color: var(--hm-text); }
.mkt-ai-badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff; }
.mkt-ai-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.mkt-ai-item { padding: 12px 14px; border-radius: 12px; background: var(--hm-surface-muted); border-left: 3px solid var(--hm-muted); display: flex; flex-direction: column; gap: 3px; }
.mkt-ai-item strong { font-size: 13px; color: var(--hm-text); }
.mkt-ai-item span { font-size: 12px; color: var(--hm-muted); }
.mkt-ai-item.success { border-left-color: #16a34a; }
.mkt-ai-item.warning { border-left-color: #d97706; }
.mkt-ai-item.danger { border-left-color: #dc2626; }
.mkt-ai-item.opportunity { border-left-color: #2563eb; }

/* ---- Charts ---- */
.mkt-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 18px; }
.mkt-chart-card { border: 1px solid var(--hm-border); border-radius: 16px; background: var(--hm-surface); padding: 16px; }
.mkt-chart-wide { grid-column: 1 / -1; }
.mkt-chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.mkt-chart-head h3 { margin: 0; font-size: 14px; color: var(--hm-text); }
.mkt-chart-note { margin: 8px 0 0; font-size: 11px; color: var(--hm-muted); }
.mkt-chart-card .hm-chart { width: 100%; height: 240px; }
.mkt-period { display: inline-flex; gap: 2px; background: var(--hm-surface-muted); border: 1px solid var(--hm-border); border-radius: 8px; padding: 2px; }
.mkt-period button { border: none; background: transparent; color: var(--hm-muted); font-size: 12px; padding: 4px 8px; border-radius: 6px; cursor: pointer; }
.mkt-period button.active { background: var(--hm-surface); color: var(--hm-text); font-weight: 600; box-shadow: 0 1px 2px rgba(15,23,42,.08); }

/* ---- Tables / ranking ---- */
.mkt-ranking-card { border: 1px solid var(--hm-border); border-radius: 16px; background: var(--hm-surface); padding: 16px; margin-bottom: 18px; }
.mkt-ranking-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.mkt-ranking-head h3 { margin: 0; font-size: 15px; color: var(--hm-text); }
.mkt-ranking-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.mkt-ranking-tools input, .mkt-ranking-tools select { padding: 8px 10px; font-size: 13px; }
.mkt-table-wrap { overflow-x: auto; }
.mkt-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mkt-table thead th { text-align: left; padding: 10px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--hm-muted); border-bottom: 1px solid var(--hm-border); white-space: nowrap; }
.mkt-table tbody td { padding: 10px 12px; border-bottom: 1px solid var(--hm-border); color: var(--hm-text); vertical-align: middle; }
.mkt-table tbody tr:hover { background: var(--hm-surface-muted); }
.mkt-cell-product { display: flex; align-items: center; gap: 8px; min-width: 200px; }
.mkt-cell-media img { width: 34px; height: 34px; object-fit: contain; border-radius: 6px; background: var(--hm-surface-muted); border: 1px solid var(--hm-border); }
.mkt-tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.mkt-tag.full { background: #dcfce7; color: #166534; }
.mkt-tag.flex { background: #e0e7ff; color: #3730a3; }
.mkt-tag.prem { background: #fef3c7; color: #92400e; }
.mkt-tag.ok { background: #dcfce7; color: #166534; }
.mkt-rep-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.mkt-link { background: none; border: none; color: var(--hm-primary); font-weight: 600; font-size: 13px; cursor: pointer; padding: 0; }
.mkt-status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.mkt-status.ok { background: #dcfce7; color: #166534; }
.mkt-status.warn { background: #fef3c7; color: #92400e; }
.mkt-status.info { background: #dbeafe; color: #1e40af; }
.mkt-status.danger { background: #fee2e2; color: #991b1b; }
.mkt-status.muted { background: var(--hm-surface-muted); color: var(--hm-muted); }

/* ---- Pagination ---- */
.mkt-pagination { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.mkt-page-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--hm-border); background: var(--hm-surface); color: var(--hm-text); cursor: pointer; }
.mkt-page-btn:disabled { opacity: .4; cursor: default; }
.mkt-page-info { font-size: 13px; color: var(--hm-muted); }

/* ---- Drawer (detalhe do concorrente) ---- */
.mkt-drawer { position: fixed; inset: 0; z-index: 60; }
.mkt-drawer-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); }
.mkt-drawer-panel { position: absolute; top: 0; right: 0; height: 100%; width: min(420px, 92vw); background: var(--hm-surface); border-left: 1px solid var(--hm-border); padding: 20px; overflow-y: auto; box-shadow: -12px 0 40px rgba(15,23,42,.18); }
.mkt-drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.mkt-drawer-head h3 { margin: 0; font-size: 17px; color: var(--hm-text); }
.mkt-drawer-close { border: none; background: var(--hm-surface-muted); width: 32px; height: 32px; border-radius: 8px; font-size: 18px; cursor: pointer; color: var(--hm-muted); }
.mkt-drawer-media img { width: 100%; max-height: 220px; object-fit: contain; border-radius: 12px; background: var(--hm-surface-muted); border: 1px solid var(--hm-border); margin-bottom: 12px; }
.mkt-drawer-grid { display: grid; gap: 8px; margin-bottom: 16px; }
.mkt-drawer-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--hm-border); font-size: 13px; }
.mkt-drawer-row span { color: var(--hm-muted); }
.mkt-drawer-future { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--hm-border); }
.mkt-drawer-future h5 { margin: 0 0 4px; font-size: 13px; color: var(--hm-text); }

/* ---- Upload / lote ---- */
.mkt-upload { border: 2px dashed var(--hm-border); border-radius: 16px; padding: 34px; text-align: center; cursor: pointer; background: var(--hm-surface); transition: border-color .15s ease, background .15s ease; }
.mkt-upload:hover, .mkt-upload.dragging { border-color: var(--hm-primary); background: color-mix(in srgb, var(--hm-primary) 5%, var(--hm-surface)); }
.mkt-upload-inner { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mkt-upload-inner strong { color: var(--hm-text); }
.mkt-upload-icon { width: 44px; height: 44px; display: grid; place-items: center; color: var(--hm-primary); }
.mkt-upload-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#mktBatchPreview { margin-top: 16px; }
.mkt-preview-wrap { max-height: 320px; overflow-y: auto; margin: 8px 0 12px; }
.mkt-progress-card { border: 1px solid var(--hm-border); border-radius: 16px; background: var(--hm-surface); padding: 20px; margin-bottom: 18px; }
.mkt-progress-card h3 { margin: 0 0 12px; font-size: 15px; color: var(--hm-text); }
.mkt-progress-bar { height: 12px; background: var(--hm-surface-muted); border-radius: 999px; overflow: hidden; }
.mkt-progress-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #6366f1, #22c55e); transition: width .4s ease; }
.mkt-progress-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 14px; }
.mkt-progress-stat { padding: 10px 12px; border: 1px solid var(--hm-border); border-radius: 10px; display: flex; flex-direction: column; gap: 2px; }
.mkt-progress-stat span { font-size: 12px; color: var(--hm-muted); }
.mkt-progress-stat strong { font-size: 18px; color: var(--hm-text); }

@media (max-width: 640px) {
  .mkt-search-field { flex-basis: 100%; }
  .mkt-own-price { width: 100%; }
  .mkt-product-card { flex-direction: column; }
}
