/* ══════════════════════════════════════════
   SevPay Admin — Componentes
══════════════════════════════════════════ */

/* ── Page Header ─────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
}

.page-header p {
  font-size: 0.875rem;
  color: var(--admin-muted);
  margin-top: 2px;
}

/* ── Botões ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  height: 40px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--admin-gradient);
  color: #fff;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-secondary {
  background: var(--admin-surface);
  border: 1.5px solid var(--admin-border);
  color: var(--admin-text);
}
.btn-secondary:hover { border-color: var(--admin-primary); }

.btn-danger {
  background: #fee2e2;
  color: var(--admin-error);
}
.btn-danger:hover { background: #fecaca; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1.5px solid var(--admin-border);
  background: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: all 0.15s;
}
.btn-icon:hover { background: var(--admin-bg); }
.btn-icon--danger:hover { background: #fee2e2; border-color: var(--admin-error); }

/* ── Card ───────────────────────────────── */
.card {
  background: var(--admin-surface);
  border-radius: var(--admin-radius);
  box-shadow: var(--admin-shadow);
  padding: 24px;
}

/* ── Tabela ─────────────────────────────── */
.table-wrap {
  background: var(--admin-surface);
  border-radius: var(--admin-radius);
  box-shadow: var(--admin-shadow);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--admin-bg);
  border-bottom: 1px solid var(--admin-border);
}

th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--admin-muted);
}

td {
  padding: 14px 16px;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--admin-border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

.td-actions { display: flex; gap: 6px; }

.product-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--admin-bg);
}

.product-thumb-empty {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--admin-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--admin-muted);
}
.product-thumb-empty::after { content: '📦'; }

.empty-row td {
  text-align: center;
  padding: 48px 16px;
  color: var(--admin-muted);
  font-size: 0.95rem;
}

/* ── Badges ─────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-error   { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }

/* ── Modal ──────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--admin-surface);
  border-radius: var(--admin-radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--admin-border);
}

.modal-header h3 { font-size: 1.1rem; font-weight: 700; }

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--admin-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--admin-bg); color: var(--admin-text); }

.modal-body { padding: 24px; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--admin-border);
}

/* ── Formulário ─────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--admin-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--admin-border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--admin-surface);
  color: var(--admin-text);
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--admin-primary);
  outline: none;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Toggle switch */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle-row label { margin: 0; text-transform: none; font-size: 0.9rem; color: var(--admin-text); }

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--admin-border);
  border-radius: 24px;
  cursor: pointer;
  transition: 0.2s;
}
.switch-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}
.switch input:checked + .switch-slider { background: var(--admin-success); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }

/* ── Alert / erro no modal ──────────────── */
.modal-error {
  background: #fee2e2;
  color: #991b1b;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}
.modal-error.hidden { display: none; }

/* ── Toast ──────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  z-index: 2000;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  transition: opacity 0.3s;
}
.toast--success { background: var(--admin-success); }
.toast--error   { background: var(--admin-error); }
.toast.hidden   { display: none; }

/* ── Stats cards ────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--admin-surface);
  border-radius: var(--admin-radius);
  box-shadow: var(--admin-shadow);
  padding: 20px;
}

.stat-card__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--admin-muted);
  margin-bottom: 8px;
}

.stat-card__value {
  font-size: 1.8rem;
  font-weight: 700;
}

/* ── Buscador ───────────────────────────── */
.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.search-bar input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--admin-border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--admin-surface);
}

.search-bar input:focus {
  border-color: var(--admin-primary);
  outline: none;
}

/* ── Image Upload ──────────────────────── */
.image-upload-area {
  position: relative;
  width: 100%;
  height: 160px;
  border: 2px dashed var(--admin-border);
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s;
}
.image-upload-area:hover { border-color: var(--admin-primary); }

.image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 8px;
  color: var(--admin-muted);
  font-size: 0.85rem;
}

.image-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.image-preview.hidden { display: none; }

.btn-image-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-image-remove.hidden { display: none; }
.btn-image-remove:hover { background: var(--admin-error); }

.form-group select:focus {
  border-color: var(--admin-primary);
  outline: none;
}

/* ── AI Section ────────────────────────── */
.ai-section {
  background: linear-gradient(135deg, rgba(139,92,246,0.06), rgba(6,182,212,0.06));
  border: 1.5px solid rgba(139,92,246,0.2);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-section__header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-section__title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #8B5CF6;
}

.ai-section__subtitle {
  font-size: 0.8rem;
  color: var(--admin-muted);
}

/* Dropzone */
.ai-dropzone {
  border: 2px dashed rgba(139,92,246,0.3);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
}
.ai-dropzone:hover,
.ai-dropzone:focus {
  border-color: #8B5CF6;
  background: rgba(139,92,246,0.04);
}
.ai-dropzone.has-images {
  padding: 12px;
  border-style: solid;
  border-color: rgba(139,92,246,0.3);
}

.ai-dropzone__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.ai-dropzone__text {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--admin-text);
}

.ai-dropzone__text kbd {
  display: inline-block;
  padding: 2px 6px;
  background: var(--admin-border);
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: inherit;
}

.ai-dropzone__hint {
  font-size: 0.75rem;
  color: var(--admin-muted);
}

/* Thumbnails */
.ai-thumbs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.ai-thumbs.hidden { display: none; }

.ai-thumb {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ai-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ai-thumb__remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.ai-thumb__remove:hover { background: var(--admin-error); }

/* Analyze button */
.btn-ai-analyze {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  background: linear-gradient(135deg, #8B5CF6, #06B6D4);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
}
.btn-ai-analyze:hover { opacity: 0.9; }
.btn-ai-analyze:active { transform: scale(0.98); }
.btn-ai-analyze:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.ai-status {
  font-size: 0.8rem;
  color: var(--admin-muted);
  text-align: center;
}
.ai-status.hidden { display: none; }

/* ── Loading spinner ────────────────────── */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--admin-border);
  border-top-color: var(--admin-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 48px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
