/* ─── Modal Overlay ───────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

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

/* ─── Modal ───────────────────────────────────────────── */
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  animation: slideUp 0.25s ease;
}

@media (max-width: 520px) {
  .modal {
    padding: 24px 20px;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

/* ─── Modal Tabs ─────────────────────────────────────── */
.modal-tabs {
  display: flex;
  gap: 0;
  background: var(--bg);
  border-radius: 8px;
  padding: 3px;
}

.modal-tab {
  padding: 8px 18px;
  font-size: 0.825rem;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.modal-tab:hover {
  color: var(--text);
}

.modal-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ─── Tab Content ────────────────────────────────────── */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

/* ─── Modal Close Button ─────────────────────────────── */
.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

/* ─── Provider Fields Toggle ──────────────────────────── */
.provider-fields[hidden] {
  display: none;
}

.provider-fields {
  animation: fadeIn 0.2s ease;
}

/* ─── Test Connection Button ──────────────────────────── */
.btn-test {
  width: 100%;
  padding: 12px 14px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font);
  color: #2563eb;
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.btn-test:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

.btn-test:active {
  transform: scale(0.99);
}

.btn-test:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* ─── Connection Status ──────────────────────────────── */
.connection-status {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 0.825rem;
  line-height: 1.6;
}

.connection-status[hidden] {
  display: none;
}

.connection-status.success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-text);
}

.connection-status.error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
}

.connection-status .status-title {
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.connection-status .status-detail {
  font-size: 0.78rem;
  opacity: 0.9;
}

.connection-status .phone-list {
  margin-top: 8px;
  padding: 0;
  list-style: none;
}

.connection-status .phone-list li {
  padding: 6px 10px;
  margin-top: 4px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background 0.15s;
}

.connection-status .phone-list li:hover {
  background: rgba(255, 255, 255, 0.9);
}

.connection-status .phone-list li.selected {
  background: rgba(6, 95, 70, 0.1);
  outline: 1.5px solid var(--success-border);
}

.connection-status .phone-tag {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(6, 95, 70, 0.1);
}

.connection-status .phone-tag.selected-tag {
  background: var(--success-text);
  color: #fff;
}

/* ─── Modal Actions ───────────────────────────────────── */
.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.modal-actions .btn-primary,
.modal-actions .btn-secondary {
  flex: 1;
}

@media (max-width: 520px) {
  .modal-actions {
    flex-direction: column;
  }
}

.modal-hint {
  margin-top: 16px;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}
