/* BENTO API Services — Modern UI v2 */

/* Ensure #main is positioned for absolute children */
#main { position: relative; }

/* ── Category accent colors (desaturated for dark theme) ── */
:root {
  --svc-cat-messaging: #60a5fa;
  --svc-cat-data: #34d399;
  --svc-cat-automation: #a78bfa;
  --svc-cat-ai: #fbbf24;
  --svc-cat-smart_home: #22d3ee;
}

.services-panel-container {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: var(--bg-base, #f9fafb);
  overflow-y: auto;
}

.services-page {
  padding: 24px 28px;
  max-width: 960px;
  margin: 0 auto;
}

/* ── Header ── */
.services-header {
  margin-bottom: 20px;
}
.services-header h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 6px 0;
  color: var(--text-primary, #111827);
  display: flex;
  align-items: center;
  gap: 8px;
}
.services-header p {
  font-size: 13px;
  color: var(--text-secondary, #6b7280);
  margin: 0;
}

/* ── Search bar ── */
.services-search-wrap {
  position: relative;
  margin-bottom: 14px;
}
.services-search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary, #9ca3af);
  pointer-events: none;
}
.services-search {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg-surface, #fff);
  color: var(--text-primary, #111827);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.services-search:focus {
  outline: none;
  border-color: var(--tesa-primary, #7239ea);
  box-shadow: 0 0 0 3px rgba(114, 57, 234, 0.1);
}
.services-search::placeholder {
  color: var(--text-tertiary, #9ca3af);
}

/* ── Filter chips ── */
.services-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.services-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-color, #e5e7eb);
  background: transparent;
  color: var(--text-secondary, #6b7280);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.services-chip:hover {
  background: var(--bg-surface-2, #f3f4f6);
  border-color: var(--text-tertiary, #9ca3af);
}
.services-chip.active {
  background: var(--tesa-primary, #7239ea);
  color: #fff;
  border-color: var(--tesa-primary, #7239ea);
}
.services-chip .chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Login required ── */
.services-login-required {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary, #6b7280);
}
.services-login-required .btn-primary {
  margin-top: 16px;
  background: var(--tesa-primary, #7239ea);
  color: #fff;
  border: none;
  padding: 10px 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: opacity 0.15s;
}
.services-login-required .btn-primary:hover { opacity: 0.9; }

/* ── Grid ── */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.services-loading, .services-error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
  color: var(--text-secondary, #6b7280);
}
.services-error { color: #dc2626; }

/* ── Empty state ── */
.services-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
}
.services-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.6;
}
.services-empty h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary, #111827);
  margin: 0 0 8px 0;
}
.services-empty p {
  font-size: 13px;
  color: var(--text-secondary, #6b7280);
  margin: 0 0 20px 0;
}
.services-empty-suggestions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.services-empty-suggestions .btn-suggest {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1.5px solid var(--border-color, #e5e7eb);
  background: var(--bg-surface, #fff);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #111827);
  transition: all 0.2s;
}
.services-empty-suggestions .btn-suggest:hover {
  border-color: var(--tesa-primary, #7239ea);
  box-shadow: 0 2px 8px rgba(114, 57, 234, 0.1);
}
.services-empty-suggestions .btn-suggest svg {
  width: 20px;
  height: 20px;
}

/* ── No results from search/filter ── */
.services-no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary, #6b7280);
  font-size: 13px;
}

/* ── Card ── */
.services-card {
  border: 1.5px solid var(--border-color, #e5e7eb);
  border-radius: 12px;
  padding: 16px 18px;
  background: var(--bg-surface, #fff);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.2s;
  border-left: 3.5px solid var(--border-color, #e5e7eb);
  position: relative;
  opacity: 0;
  animation: svc-card-in 0.3s ease forwards;
}
@keyframes svc-card-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* Stagger animation delay applied via inline style */

.services-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

/* Category left border colors */
.services-card[data-category="messaging"]  { border-left-color: var(--svc-cat-messaging); }
.services-card[data-category="data"]       { border-left-color: var(--svc-cat-data); }
.services-card[data-category="automation"] { border-left-color: var(--svc-cat-automation); }
.services-card[data-category="ai"]         { border-left-color: var(--svc-cat-ai); }
.services-card[data-category="smart_home"] { border-left-color: var(--svc-cat-smart_home); }

/* Connected card glow on hover */
.services-card.connected {
  border-color: rgba(34, 197, 94, 0.4);
}
.services-card.connected:hover {
  box-shadow: 0 4px 20px rgba(34, 197, 94, 0.12),
              0 2px 8px rgba(0,0,0,0.06);
}

.services-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}
.services-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg-surface-2, #f3f4f6);
  color: var(--text-secondary, #6b7280);
}
.services-card-icon svg {
  width: 20px;
  height: 20px;
}
.services-card-info {
  flex: 1;
  min-width: 0;
}
.services-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary, #111827);
  line-height: 1.3;
}
.services-card-desc {
  font-size: 11px;
  color: var(--text-secondary, #6b7280);
  margin-top: 2px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Status pill */
.services-card-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 12px;
  margin-bottom: 10px;
}
.services-card-status .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.services-card-status.online {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}
.services-card-status.online .status-dot { background: #22c55e; }
.services-card-status.offline {
  background: var(--bg-surface-2, #f3f4f6);
  color: var(--text-tertiary, #9ca3af);
}
.services-card-status.offline .status-dot { background: #9ca3af; }

/* Card actions */
.services-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.services-card-actions .btn-sm {
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--border-color, #d1d5db);
  background: transparent;
  color: var(--text-primary, #374151);
  transition: all 0.15s;
  font-weight: 500;
}
.services-card-actions .btn-sm:hover {
  background: var(--bg-surface-2, #f3f4f6);
}
.services-card-actions .btn-sm:active {
  transform: scale(0.97);
}
.services-card-actions .btn-sm.btn-primary-sm {
  background: var(--tesa-primary, #7239ea);
  color: #fff;
  border-color: var(--tesa-primary, #7239ea);
}
.services-card-actions .btn-sm.btn-primary-sm:hover {
  opacity: 0.9;
  background: var(--tesa-primary, #7239ea);
}
.services-card-actions .btn-success { background: #22c55e; color: #fff; border-color: #22c55e; }
.services-card-actions .btn-danger { background: #ef4444; color: #fff; border-color: #ef4444; }
.services-card-actions .btn-danger-outline { color: #ef4444; border-color: #fca5a5; }
.services-card-actions .btn-danger-outline:hover { background: rgba(239, 68, 68, 0.08); }

/* ── Modal ── */
.services-modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0);
  display: flex; align-items: center; justify-content: center;
  animation: svc-overlay-in 0.2s ease forwards;
}
@keyframes svc-overlay-in {
  to { background: rgba(0,0,0,0.5); }
}
.services-modal-overlay.closing {
  animation: svc-overlay-out 0.15s ease forwards;
}
@keyframes svc-overlay-out {
  from { background: rgba(0,0,0,0.5); }
  to   { background: rgba(0,0,0,0); }
}

.services-modal {
  background: var(--bg-surface, #fff);
  border-radius: 14px;
  width: 440px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  transform: scale(0.95);
  opacity: 0;
  animation: svc-modal-in 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes svc-modal-in {
  to { transform: scale(1); opacity: 1; }
}
.services-modal-overlay.closing .services-modal {
  animation: svc-modal-out 0.15s ease forwards;
}
@keyframes svc-modal-out {
  from { transform: scale(1); opacity: 1; }
  to   { transform: scale(0.95); opacity: 0; }
}

.services-modal-wide { width: 620px; }
.services-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}
.services-modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.services-modal-header h3 svg {
  width: 20px;
  height: 20px;
  color: var(--text-secondary, #6b7280);
}
.services-modal-close {
  background: none; border: none; font-size: 18px;
  cursor: pointer; color: var(--text-secondary, #6b7280);
  padding: 4px 8px; border-radius: 6px;
  transition: background 0.15s;
}
.services-modal-close:hover { background: var(--bg-surface-2, #f3f4f6); }
.services-modal-body { padding: 20px; }

/* ── Form fields ── */
.services-field {
  margin-bottom: 14px;
}
.services-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary, #374151);
}
.services-field label .required {
  color: #ef4444;
  margin-left: 2px;
}
.services-field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color, #d1d5db);
  border-radius: 6px;
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  background: var(--bg-surface, #fff);
  color: var(--text-primary, #111827);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.services-field input:focus {
  outline: none;
  border-color: var(--tesa-primary, #7239ea);
  box-shadow: 0 0 0 3px rgba(114, 57, 234, 0.1);
}
.services-field input.field-error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}
.services-field small {
  display: block;
  font-size: 10px;
  color: var(--text-tertiary, #9ca3af);
  margin-top: 3px;
}
.services-field .field-error-msg {
  font-size: 10px;
  color: #ef4444;
  margin-top: 3px;
}

/* ── Modal actions ── */
.services-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.services-modal-actions .btn-primary {
  background: var(--tesa-primary, #7239ea);
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: opacity 0.15s;
}
.services-modal-actions .btn-primary:hover { opacity: 0.9; }
.services-modal-actions .btn-outline {
  background: transparent;
  border: 1px solid var(--border-color, #d1d5db);
  padding: 8px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary, #374151);
  transition: background 0.15s;
}
.services-modal-actions .btn-outline:hover {
  background: var(--bg-surface-2, #f3f4f6);
}

/* ── Guide ── */
.services-guide {
  background: var(--bg-surface-2, #f0f4ff);
  border: 1px solid var(--border-color, #dbe4ff);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.services-guide-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--tesa-primary, #7239ea);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.services-guide-steps {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--text-primary, #374151);
  line-height: 1.6;
}
.services-guide-steps li {
  margin-bottom: 3px;
}
.services-guide-ref {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  color: var(--tesa-primary, #7239ea);
  text-decoration: none;
  font-weight: 600;
}
.services-guide-ref:hover {
  text-decoration: underline;
}

/* ── Code block ── */
.services-code-block {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 14px;
  border-radius: 8px;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  overflow-x: auto;
  max-height: 400px;
  line-height: 1.5;
}

/* ── Toast notifications ── */
.services-toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.services-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-surface, #fff);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  border-left: 3.5px solid #6b7280;
  pointer-events: auto;
  animation: svc-toast-in 0.25s ease forwards;
  max-width: 380px;
}
.services-toast.success { border-left-color: #22c55e; }
.services-toast.error   { border-left-color: #ef4444; }
.services-toast.info    { border-left-color: var(--tesa-primary, #7239ea); }

@keyframes svc-toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.services-toast.closing {
  animation: svc-toast-out 0.2s ease forwards;
}
@keyframes svc-toast-out {
  to { opacity: 0; transform: translateX(20px); }
}
.services-toast .toast-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}
.services-toast .toast-msg {
  flex: 1;
  color: var(--text-primary, #111827);
}

/* ── Confirm dialog ── */
.services-confirm-body {
  text-align: center;
  padding: 8px 0 4px;
}
.services-confirm-body .confirm-icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.8;
}
.services-confirm-body p {
  font-size: 14px;
  color: var(--text-primary, #111827);
  margin: 0 0 4px 0;
}
.services-confirm-body small {
  font-size: 12px;
  color: var(--text-secondary, #6b7280);
}
.services-confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 20px;
}
.services-confirm-actions .btn-danger {
  background: #ef4444;
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: opacity 0.15s;
}
.services-confirm-actions .btn-danger:hover { opacity: 0.9; }
.services-confirm-actions .btn-outline {
  background: transparent;
  border: 1px solid var(--border-color, #d1d5db);
  padding: 8px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary, #374151);
}

/* ── Loading skeleton ── */
.services-skeleton {
  border-radius: 12px;
  height: 140px;
  background: linear-gradient(90deg,
    var(--bg-surface-2, #f3f4f6) 25%,
    var(--bg-surface, #fff) 50%,
    var(--bg-surface-2, #f3f4f6) 75%);
  background-size: 200% 100%;
  animation: svc-shimmer 1.5s ease infinite;
}
@keyframes svc-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Spinner for test button ── */
.btn-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border-color, #d1d5db);
  border-top-color: var(--tesa-primary, #7239ea);
  border-radius: 50%;
  animation: svc-spin 0.6s linear infinite;
  vertical-align: middle;
}
@keyframes svc-spin {
  to { transform: rotate(360deg); }
}
