/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Service Modal — Add / Edit Service
   Tabbed modal with panel integration
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* ── Modal shell ──
   Height & flex layout are set in style.css (.modal-box.svc-modal)
   to ensure centralized overrides take effect before this file loads. */

/* ── Tab system ─────────────────────────────────── */

.svc-tab-bar {
  display: flex;
  flex-shrink: 0;
  gap: 0;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
}

/*
 * Tabs must hard-override the global `button` reset
 * (border-radius:8px, padding:10px 20px, font-weight:600, etc.)
 */
button.svc-tab {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s;
  position: relative;
}
button.svc-tab:hover {
  color: var(--text);
}
button.svc-tab.svc-tab-active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

/* Tab icons */
button.svc-tab svg {
  opacity: 0.35;
  flex-shrink: 0;
  transition: opacity .2s, color .2s;
}
button.svc-tab:hover svg {
  opacity: 0.65;
}
button.svc-tab.svc-tab-active svg {
  opacity: 1;
  color: var(--accent);
}

/* Active-tab indicator dot (Panel tab when configured) */
.svc-tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  box-shadow: 0 0 6px rgba(16,185,129,0.4);
}

/* ── Tab pane ── */
/* Tab body fills all remaining modal height via flex.
   Panes overlay each other absolutely so only the active one
   is rendered — the container height never changes. */
.svc-tabs {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.svc-tab-body {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}
.svc-tab-pane {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 24px 20px;
}

/* ── Password field — eye toggle inside input ───── */
.svc-pw-wrap {
  position: relative;
}
.svc-pw-wrap input {
  padding-right: 44px !important;
}

button.svc-pw-toggle {
  all: unset;
  box-sizing: border-box;
  position: absolute;
  right: 1px;
  top: 1px;
  bottom: 1px;
  width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  border-radius: 0 8px 8px 0;
  transition: color .15s, background .15s;
}
button.svc-pw-toggle:hover {
  color: var(--text);
  background: rgba(255,255,255,0.04);
}

/* Eye icon swap via CSS class */
.svc-pw-toggle .svc-eye-open,
.svc-pw-toggle .svc-eye-closed {
  pointer-events: none;
  flex-shrink: 0;
}
.svc-pw-toggle .svc-eye-closed    { display: none  !important; }
.svc-pw-toggle .svc-eye-open      { display: block !important; }
.svc-pw-toggle.svc-pw-visible .svc-eye-open   { display: none  !important; }
.svc-pw-toggle.svc-pw-visible .svc-eye-closed  { display: block !important; }

/* ── Toggle switch rows ─────────────────────────── */
.svc-toggle-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.svc-toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.svc-toggle-label {
  font-size: 13px;
  color: var(--text);
  user-select: none;
}

/* ── Test connection ────────────────────────────── */
.svc-test-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}
.svc-test-btn {
  padding: 9px 18px;
  font-size: 12px;
  background: rgba(99,102,241,0.08);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 8px;
  color: var(--text);
}
.svc-test-btn:hover:not(:disabled) {
  background: rgba(99,102,241,0.14);
  border-color: rgba(99,102,241,0.35);
}
.svc-test-icon {
  display: flex;
  align-items: center;
}
@keyframes svc-spin {
  to { transform: rotate(360deg); }
}
.svc-test-spin svg {
  animation: svc-spin .8s linear infinite;
}
.svc-test-result {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
}
.svc-test-result-icon {
  display: flex;
  align-items: center;
}
.svc-test-result-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
.svc-test-ok {
  color: var(--green);
  background: rgba(34,197,94,0.08);
}
.svc-test-fail {
  color: var(--red);
  background: rgba(239,68,68,0.08);
}

/* ── Empty states ───────────────────────────────── */
.svc-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 44px 20px;
  gap: 10px;
}
.svc-empty-icon {
  color: var(--muted);
  opacity: 0.15;
}
.svc-empty-text {
  font-size: 13px;
  color: var(--muted);
}

/* ── Footer ─────────────────────────────────────── */
.svc-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}
.svc-btn-cancel {
  border-radius: 10px;
}

/* ── Sub-section divider ────────────────────────── */
.svc-sub-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.svc-sub-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 768px) {
  .svc-tab-pane {
    padding: 20px 18px 16px;
  }
}
@media (max-width: 640px) {
  .svc-tab-bar {
    padding: 0 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .svc-tab-bar::-webkit-scrollbar { display: none; }
  button.svc-tab {
    padding: 0 10px;
    height: 38px;
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  button.svc-tab svg {
    display: none;
  }
  .svc-tab-pane {
    padding: 16px 14px 12px;
  }
  .svc-modal-footer {
    padding: 12px 16px;
  }
  .svc-test-row {
    flex-wrap: wrap;
  }
}
