/* ============================================================
 * Skin Suite — CF Admin Panel
 * Gear-icon overlay for editing products + services live.
 * Loaded only on the Cloudflare deploy via Pages middleware.
 * ============================================================ */

/* Gear button — top-right, fixed. */
.ssp-admin-gear {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 9999;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #4a5660;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.18s ease, background 0.18s ease;
}

.ssp-admin-gear:hover,
.ssp-admin-gear:focus {
  background: #fff;
  transform: rotate(40deg);
  outline: none;
}

.ssp-admin-gear:active {
  transform: rotate(60deg) scale(0.95);
}

/* Hide gear ONLY on the capture/intro screen — we add a body class
 * conditionally via the JS. The default state (no class) keeps it hidden,
 * and `.ssp-admin-gear-show` reveals it. This guarantees we don't taunt
 * users with a button that won't work mid-scan. */
.ssp-admin-gear {
  display: none;
}
body.ssp-admin-gear-show .ssp-admin-gear {
  display: flex;
}

/* Full-screen overlay when admin panel is open. */
.ssp-admin-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(20, 25, 35, 0.55);
  backdrop-filter: blur(2px);
  display: none;
  align-items: stretch;
  justify-content: center;
  padding: 0;
}
.ssp-admin-overlay.ssp-open {
  display: flex;
}

.ssp-admin-panel {
  background: #fafbfc;
  width: 100%;
  max-width: 1280px;
  margin: 0;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #1f2630;
  overflow: hidden;
}

.ssp-admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #e3e7ec;
  background: #fff;
  flex-shrink: 0;
}

.ssp-admin-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.ssp-admin-meta {
  font-size: 12px;
  color: #687482;
  margin-left: 12px;
}

.ssp-admin-close {
  background: transparent;
  border: 1px solid #d2d8df;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  color: #4a5660;
}
.ssp-admin-close:hover {
  background: #f1f4f7;
}

.ssp-admin-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 20px 100px;
  -webkit-overflow-scrolling: touch;
}

.ssp-admin-section {
  background: #fff;
  border: 1px solid #e3e7ec;
  border-radius: 8px;
  margin-bottom: 18px;
  overflow: hidden;
}

.ssp-admin-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #eef1f4;
  background: #f7f9fb;
}
.ssp-admin-section-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.ssp-admin-count {
  font-size: 12px;
  color: #687482;
}

.ssp-admin-table-wrap {
  overflow-x: auto;
}

.ssp-admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ssp-admin-table thead th {
  text-align: left;
  background: #fafbfc;
  font-weight: 600;
  color: #4a5660;
  padding: 10px 12px;
  border-bottom: 1px solid #e3e7ec;
  position: sticky;
  top: 0;
  z-index: 1;
}

.ssp-admin-table tbody tr {
  border-bottom: 1px solid #eef1f4;
}
.ssp-admin-table tbody tr:hover {
  background: #fafbfc;
}

.ssp-admin-table td {
  padding: 8px 12px;
  vertical-align: top;
}

.ssp-admin-table td input,
.ssp-admin-table td textarea,
.ssp-admin-table td select {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  font-family: inherit;
  color: inherit;
  padding: 6px 8px;
  border-radius: 4px;
  resize: vertical;
}

.ssp-admin-table td input:focus,
.ssp-admin-table td textarea:focus,
.ssp-admin-table td select:focus {
  outline: 2px solid #6c9bd1;
  background: #fff;
  border-color: #6c9bd1;
}

.ssp-admin-table td.col-name { min-width: 200px; }
.ssp-admin-table td.col-category { min-width: 160px; }
.ssp-admin-table td.col-description { min-width: 240px; }
.ssp-admin-table td.col-price { width: 110px; }
.ssp-admin-table td.col-actions { width: 64px; text-align: right; }

.ssp-admin-table td textarea {
  min-height: 36px;
  line-height: 1.4;
}

.ssp-admin-row-disabled-price {
  color: #aab3bc;
  font-style: italic;
  font-size: 12px;
  padding: 6px 8px;
  text-align: center;
}

/* Add row button */
.ssp-admin-add-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ecf2f8;
  border: 1px dashed #97aac0;
  color: #344a63;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
}
.ssp-admin-add-row:hover {
  background: #dfe9f3;
}

.ssp-admin-row-action {
  background: transparent;
  border: 1px solid #e3c4c4;
  color: #b04545;
  border-radius: 4px;
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
}
.ssp-admin-row-action:hover {
  background: #fbeded;
}

/* Sticky footer with Save */
.ssp-admin-footer {
  position: sticky;
  bottom: 0;
  background: #fff;
  border-top: 1px solid #e3e7ec;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.06);
}

.ssp-admin-status {
  font-size: 13px;
  color: #4a5660;
  flex: 1 1 auto;
  min-width: 0;
}
.ssp-admin-status.ssp-error { color: #b04545; }
.ssp-admin-status.ssp-success { color: #2d7a4d; }

.ssp-admin-save {
  background: #2d7a4d;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.3px;
}
.ssp-admin-save:hover { background: #246138; }
.ssp-admin-save:disabled {
  background: #9bb3a4;
  cursor: not-allowed;
}

/* Responsive — drop padding on small screens */
@media (max-width: 600px) {
  .ssp-admin-header { padding: 10px 12px; }
  .ssp-admin-body { padding: 12px 8px 100px; }
  .ssp-admin-footer { padding: 10px 12px; }
  .ssp-admin-meta { display: none; }
  .ssp-admin-table td { padding: 6px 6px; }
  .ssp-admin-table thead th { padding: 8px 6px; font-size: 12px; }
}

/* Loading state */
.ssp-admin-loading {
  text-align: center;
  padding: 40px 20px;
  color: #687482;
  font-size: 14px;
}
