/* ============================================================
   WhatsApp Manager — Shared Components
   public/components.css
   Requires design-system.css to be loaded first.
   ============================================================ */

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-family: var(--font-base);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--text-on-accent);
  width: 100%;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  width: 100%;
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-default);
}

.btn-danger {
  background: var(--danger-muted);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
}

.btn-icon {
  background: transparent;
  border: none;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
  line-height: 0;
}
.btn-icon:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* ─── Form Elements ───────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--text-base);
  font-family: var(--font-base);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-disabled);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent-border);
  background: var(--bg-surface);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238696a0' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
  padding-left: 36px;
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: var(--leading-normal);
}

/* Search input with icon */
.search-wrap {
  position: relative;
}
.search-wrap .search-icon {
  position: absolute;
  top: 50%;
  right: var(--space-3);
  transform: translateY(-50%);
  color: var(--text-disabled);
  pointer-events: none;
  line-height: 0;
}
.search-wrap .form-input {
  padding-right: 38px;
}

/* ─── Loading Spinner ─────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-overlay);
}
.loading-overlay.active {
  display: flex;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border-default);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Inline (small) spinner */
.spinner-sm {
  width: 22px;
  height: 22px;
  border-width: 2px;
}

/* ─── Chat List ───────────────────────────────────────────── */
.chat-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 340px;
  overflow-y: auto;
  padding: var(--space-1);

  /* custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.chat-list::-webkit-scrollbar { width: 4px; }
.chat-list::-webkit-scrollbar-track { background: transparent; }
.chat-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.chat-list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  user-select: none;
}
.chat-list-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-default);
}
.chat-list-item.selected {
  background: var(--accent-muted);
  border-color: var(--accent-border);
}

.chat-list-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.chat-list-item .chat-name {
  font-size: var(--text-sm);
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

/* ─── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-overlay);
  padding: var(--space-4);
}
.modal-overlay.visible {
  display: flex;
}

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-3);
  direction: rtl;
  text-align: right;
}

.modal-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-5);
  direction: rtl;
  text-align: right;
  line-height: var(--leading-loose);
}

.modal-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  direction: rtl;
}

.modal-actions .btn {
  width: auto;
  padding: var(--space-2) var(--space-5);
}

/* ─── Section / Page titles ───────────────────────────────── */
.page-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-6);
  direction: rtl;
  text-align: right;
}

.section-title {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  direction: rtl;
  text-align: right;
}

.hint-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-loose);
  direction: rtl;
  text-align: right;
}

/* ─── Panel card ──────────────────────────────────────────── */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
}

@media (min-width: 768px) {
  .panel {
    padding: var(--space-8);
  }
}

.panel + .panel {
  margin-top: var(--space-4);
}

.panel-title {
  font-size: var(--text-base);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  direction: rtl;
  text-align: right;
}

/* ─── Info / Note Card ────────────────────────────────────── */
.info-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-right: 3px solid var(--tg-primary);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  direction: rtl;
  text-align: right;
}
.info-card p, .info-card li {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-loose);
}
.info-card h3 {
  font-size: var(--text-base);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}
.info-card ol, .info-card ul {
  padding-right: var(--space-5);
}
