/* ============================================================ */
/* PALETA NANNUK                                                  */
/* ============================================================ */
:root {
  --brand: #12af9b;          /* teal principal del logo */
  --brand-dark: #0d8b7c;     /* hover */
  --brand-light: #e0f7f3;    /* fondos suaves */
  --brand-ghost: #f4fbfa;    /* tint apenas perceptible */
  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --border: #d2d2d7;
  --border-soft: #e5e5ea;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --accent-warn: #ff9500;
  --accent-warn-dark: #d97700;
  --accent-success: #34c759;
  --accent-success-dark: #28a745;
  --accent-danger: #ff3b30;
  --shadow: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 14px rgba(18, 175, 155, 0.08);
}

* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

/* ============================================================ */
/* HEADER                                                         */
/* ============================================================ */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 16px; }
.logo {
  height: 48px;
  width: auto;
  display: block;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.brand-text small {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--brand-ghost);
  border: 1px solid var(--brand-light);
  border-radius: 999px;
  font-size: 13px;
  color: var(--brand-dark);
  cursor: pointer;
  user-select: none;
}
.check-pill input { accent-color: var(--brand); }

/* ============================================================ */
/* USER MENU (avatar + logout)                                    */
/* ============================================================ */
.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 6px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: white;
  font-size: 13px;
  color: var(--text);
}
.user-menu img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
}
.user-menu .logout-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 700;
  padding-left: 8px;
  border-left: 1px solid var(--border-soft);
  margin-left: 4px;
}
.user-menu .logout-link:hover { color: var(--accent-danger); }

/* ============================================================ */
/* LOGIN PAGE                                                     */
/* ============================================================ */
.login-body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 20%, rgba(18, 175, 155, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(18, 175, 155, 0.10) 0%, transparent 40%),
    linear-gradient(180deg, #fafbfc 0%, #f0faf8 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  position: relative;
  overflow: hidden;
}

/* Patrón geométrico decorativo (puntos sutiles) */
.login-bg-pattern {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(18, 175, 155, 0.08) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at center, black 0%, transparent 70%);
  -webkit-mask-image: radial-gradient(circle at center, black 0%, transparent 70%);
  z-index: 0;
}

.login-card {
  background: white;
  border-radius: 20px;
  padding: 56px 56px 48px 56px;
  text-align: center;
  box-shadow:
    0 1px 2px rgba(18, 175, 155, 0.04),
    0 8px 32px rgba(18, 175, 155, 0.10),
    0 24px 64px rgba(18, 175, 155, 0.06);
  max-width: 420px;
  width: 100%;
  position: relative;
  z-index: 1;
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.login-brand {
  margin-bottom: 40px;
}
.login-logo {
  height: 64px;
  width: auto;
  display: inline-block;
}

.google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 14px 32px;
  background: white;
  color: #3c4043;
  text-decoration: none;
  border: 1px solid #dadce0;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  width: 100%;
  transition: all 0.18s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.google-btn:hover {
  background: #f8f9fa;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
.google-btn:active {
  transform: translateY(0);
}

.error-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 14px 18px;
  border-radius: 10px;
  margin-top: 24px;
  font-size: 13px;
  text-align: left;
  line-height: 1.5;
}
.error-box strong { display: block; margin-bottom: 4px; }
.error-box code {
  background: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.login-footer {
  position: absolute;
  bottom: 24px;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  z-index: 1;
}

/* ============================================================ */
/* BOTONES                                                        */
/* ============================================================ */
button {
  padding: 8px 16px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: white;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
button:hover:not(:disabled) { background: var(--brand-dark); border-color: var(--brand-dark); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary {
  background: var(--surface);
  color: var(--brand);
  border-color: var(--brand-light);
}
button.secondary:hover:not(:disabled) {
  background: var(--brand-light);
}
button.warning {
  background: var(--accent-warn);
  border-color: var(--accent-warn);
}
button.warning:hover:not(:disabled) {
  background: var(--accent-warn-dark);
  border-color: var(--accent-warn-dark);
}

/* ============================================================ */
/* TABS (filtros por estado)                                      */
/* ============================================================ */
.tabs-bar {
  background: var(--surface);
  display: flex;
  gap: 4px;
  padding: 14px 28px 0 28px;
  border-bottom: 1px solid var(--border);
}
.tab {
  padding: 12px 22px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  border-bottom: 3px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: all 0.15s;
}
.tab:hover {
  background: var(--bg);
  color: var(--text);
}
.tab.active {
  color: var(--text);
  background: var(--bg);
}
.tab-pending.active    { border-bottom-color: var(--brand); }
.tab-processed.active  { border-bottom-color: var(--accent-success); }
.tab-historico.active  { border-bottom-color: #8e8e93; }
.tab-review.active     { border-bottom-color: var(--accent-warn); }

.tab-count {
  display: inline-block;
  background: var(--border-soft);
  color: var(--text);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  min-width: 28px;
  text-align: center;
}
.tab-pending.active    .tab-count { background: var(--brand); color: white; }
.tab-processed.active  .tab-count { background: var(--accent-success); color: white; }
.tab-historico.active  .tab-count { background: #8e8e93; color: white; }
.tab-review.active     .tab-count { background: var(--accent-warn); color: white; }

/* ============================================================ */
/* BARRA DE ACCIONES BULK (flotante, abajo)                       */
/* ============================================================ */
#bulk-bar {
  background: var(--brand-dark);
  color: white;
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  box-shadow: 0 -4px 14px rgba(13, 139, 124, 0.25);
  animation: slideUp 0.2s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
#bulk-bar[hidden] { display: none !important; }
#bulk-bar strong { font-size: 16px; }

/* Padding inferior del main para que la barra no tape la última fila */
main { padding-bottom: 100px; }
.bulk-actions { display: flex; gap: 10px; }
.bulk-actions button {
  background: white;
  color: var(--brand-dark);
  border-color: white;
}
.bulk-actions button:hover { background: var(--brand-light); }
.bulk-actions button.secondary {
  background: transparent;
  color: white;
  border-color: rgba(255,255,255,0.4);
}
.bulk-actions button.secondary:hover { background: rgba(255,255,255,0.15); }

.checkbox-col { width: 40px; text-align: center; }
.checkbox-col input { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; }

/* ============================================================ */
/* LAYOUT PRINCIPAL                                               */
/* ============================================================ */
main {
  display: grid;
  grid-template-columns: 1fr 600px;
  gap: 24px;
  padding: 24px 28px 100px 28px;
  align-items: start;
}
@media (max-width: 1100px) {
  main { grid-template-columns: 1fr; }
}

section, aside {
  background: var(--surface);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}

aside#detail {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  border: 1px solid var(--brand-light);
  box-shadow: var(--shadow-md);
}

h2 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

/* ============================================================ */
/* TABLA DE PEDIDOS                                               */
/* ============================================================ */
.loading { color: var(--text-muted); padding: 28px; text-align: center; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
th {
  background: var(--bg);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}
tr { transition: background 0.1s; }
tr:hover { background: var(--brand-ghost); cursor: pointer; }
tr.selected {
  background: var(--brand-light);
  box-shadow: inset 3px 0 0 var(--brand);
}
.product-name { font-weight: 500; max-width: 320px; }
.product-sku { color: var(--text-muted); font-size: 11px; }

.row-thumb {
  width: 100px;
  height: 100px;
  object-fit: contain;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  display: block;
}
.row-thumb.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c7c7cc;
  font-size: 18px;
}

code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: "SF Mono", monospace;
}

/* ============================================================ */
/* PANEL DETALLE                                                  */
/* ============================================================ */
#detail h3 { margin: 18px 0 8px 0; font-size: 14px; font-weight: 600; color: var(--brand-dark); }
#detail .field { font-size: 13px; padding: 7px 0; border-bottom: 1px solid #f0f0f0; }
#detail .field strong { display: inline-block; min-width: 120px; color: var(--text-muted); }

/* Cabecera siempre visible (Pedido + badges) */
.detail-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 12px;
  font-size: 13px;
}
.detail-header code { font-size: 13px; padding: 4px 8px; }

/* Sección colapsable de detalles */
.detail-collapsible {
  margin-bottom: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  overflow: hidden;
}
.detail-collapsible summary {
  padding: 10px 14px;
  background: var(--bg);
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-dark);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.detail-collapsible summary::-webkit-details-marker { display: none; }
.detail-collapsible summary::before {
  content: "▶";
  font-size: 10px;
  transition: transform 0.15s;
}
.detail-collapsible[open] summary::before { transform: rotate(90deg); }
.detail-collapsible[open] summary { border-bottom: 1px solid var(--border-soft); }
.detail-meta { padding: 12px 14px; }

/* Lado a lado (cliente | generada) */
.images-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.image-card {
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 10px;
  background: white;
  display: flex;
  flex-direction: column;
}
.image-card h4 {
  margin: 0 0 8px 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
}
.image-card img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
}
.image-card.transparent-card img,
.image-card.transparent-card .empty-card {
  background: repeating-conic-gradient(#e5e5ea 0% 25%, white 0% 50%) 50% / 16px 16px;
}
.empty-card {
  width: 100%;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  border-radius: 4px;
  padding: 16px 8px;
}

#detail .actions-group { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
#detail .download-link {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 16px;
  background: var(--accent-success);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}
#detail .download-link:hover { background: var(--accent-success-dark); }

#detail #finalize-area button {
  margin-top: 8px;
  margin-right: 8px;
}
#detail #finalize-area #approve-btn {
  background: var(--accent-success);
  border-color: var(--accent-success);
}
#detail #finalize-area #approve-btn:hover { background: var(--accent-success-dark); border-color: var(--accent-success-dark); }

.separator {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
}

/* ============================================================ */
/* BADGES                                                         */
/* ============================================================ */
.type-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
}
.type-badge.template    { background: var(--brand-light); color: var(--brand-dark); }
.type-badge.image       { background: #fef3c7; color: #b45309; }
.type-badge.unknown     { background: var(--border-soft); color: var(--text-muted); }
.type-badge.processed   { background: #d1fae5; color: #047857; }
.type-badge.historico   { background: #e5e5ea; color: #3a3a3c; }
.type-badge.review      { background: #ffedd5; color: #c2410c; }

/* ============================================================ */
/* TRANSPARENCIA CHECKER (preview PNG sin fondo)                  */
/* ============================================================ */
.preview.transparent-bg {
  background: repeating-conic-gradient(#e5e5ea 0% 25%, white 0% 50%) 50% / 20px 20px;
  padding: 0;
  border-radius: 8px;
  overflow: hidden;
}

/* ============================================================ */
/* STATUS INFO (cuando pedido ya está en processing/review)       */
/* ============================================================ */
.status-info {
  margin-top: 20px;
  padding: 14px;
  background: var(--brand-ghost);
  border: 1px solid var(--brand-light);
  border-radius: 8px;
  font-size: 13px;
}
.status-info p { margin: 4px 0; }
.status-info a { color: var(--brand-dark); }

/* ============================================================ */
/* PENDING PAGE                                                   */
/* ============================================================ */
.pending-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin: 0 auto 12px auto;
  display: block;
  border: 3px solid var(--brand-light);
}
.pending-name {
  margin: 0 0 4px 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-strong);
}
.pending-email {
  margin: 0 0 24px 0;
  color: var(--text-muted);
  font-size: 13px;
}
.pending-box {
  padding: 16px 20px;
  border-radius: 12px;
  text-align: left;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.5;
}
.pending-box strong {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
}
.pending-box p { margin: 0; }
.pending-wait {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}
.pending-denied {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}
.logout-link {
  display: inline-block;
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
  padding: 8px 12px;
}
.logout-link:hover { color: var(--text-strong); }

/* ============================================================ */
/* ADMIN PAGE                                                     */
/* ============================================================ */
.admin-header {
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.admin-header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.admin-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}
.admin-back {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-strong);
  text-decoration: none;
  font-size: 14px;
}
.admin-logo { height: 28px; width: auto; }

.admin-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px;
}
.admin-section { margin-bottom: 40px; }
.admin-section h2 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 8px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 600;
}
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-approved { background: var(--brand-ghost); color: var(--brand-dark); }
.badge-denied   { background: #fee2e2; color: #991b1b; }

.user-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.user-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.user-list:empty::after {
  content: "Sin usuarios en esta categoría.";
  color: var(--text-muted);
  font-size: 13px;
  padding: 12px 0;
  text-align: center;
}
.user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}
.user-avatar-placeholder {
  background: var(--brand-light);
  color: var(--brand-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 18px;
}
.user-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-strong);
}
.user-email {
  font-size: 13px;
  color: var(--text-muted);
}
.user-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.user-actions {
  display: flex;
  gap: 8px;
}
.btn {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.05s;
}
.btn:hover { opacity: 0.9; }
.btn:active { transform: translateY(1px); }
.btn-approve { background: var(--brand); color: white; }
.btn-deny    { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.btn-ghost   { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }

/* ============================================================ */
/* AI VISION RESULT                                               */
/* ============================================================ */
.vision-result {
  margin-top: 16px;
  padding: 16px;
  background: linear-gradient(135deg, #faf8ff 0%, #f3eeff 100%);
  border: 1px solid #d8c8ff;
  border-radius: 12px;
}
.vision-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 14px;
}
.vision-meta { color: #786699; font-size: 11px; }
.vision-frase {
  font-size: 13px;
  color: #4a3a6e;
  margin-bottom: 12px;
}
.vision-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.vision-table th,
.vision-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid #e5dcf5;
}
.vision-table th {
  font-weight: 600;
  color: #4a3a6e;
  background: rgba(255,255,255,0.5);
}
.vision-table code {
  background: white;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
}
.vision-hint {
  font-size: 11px;
  color: #786699;
  margin: 8px 0 0 0;
  font-style: italic;
}
.vision-loading {
  padding: 16px;
  text-align: center;
  color: #786699;
  background: #faf8ff;
  border: 1px dashed #d8c8ff;
  border-radius: 8px;
  margin-top: 12px;
}
.vision-error {
  padding: 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 12px;
}
