/* ═════════════════════════════════════════════════════════════
   components.css — کامپوننت‌های پایه
   ═════════════════════════════════════════════════════════════ */

/* ═════ Card ═════ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: var(--shadow);
  margin-bottom: var(--space-3);
}

.card-flat {
  background: var(--card);
  border-radius: var(--radius);
  padding: var(--space-4);
  border: 1px solid var(--border);
}

/* ═════ Button ═════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--fs-base);
  font-weight: 700;
  transition: background 0.15s, opacity 0.15s;
  text-align: center;
}

.btn:active { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  padding: var(--space-2);
}

.btn-danger {
  background: var(--err);
  color: white;
}

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-sm);
}

/* ═════ Input ═════ */
.input,
.textarea,
.select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: var(--fs-base);
  transition: border-color 0.15s;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
}

.textarea {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
}

.label {
  display: block;
  font-size: var(--fs-sm);
  color: var(--text-dim);
  margin-bottom: var(--space-2);
  font-weight: 700;
}

.field {
  margin-bottom: var(--space-4);
}

.field-error {
  color: var(--err);
  font-size: var(--fs-xs);
  margin-top: var(--space-1);
}

.field-ok {
  color: var(--ok);
  font-size: var(--fs-xs);
  margin-top: var(--space-1);
}

/* ═════ Bottom Nav ═════ */
.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--space-2);
  color: var(--text-dim);
  transition: color 0.15s;
  position: relative;
}

.nav-item.active {
  color: var(--accent);
}

.nav-icon {
  font-size: 20px;
  line-height: 1;
}

.nav-label {
  font-size: var(--fs-xs);
  line-height: 1;
}

.nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 18px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--err);
  color: white;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ═════ Toast ═════ */
#toast-container {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  width: 90%;
  max-width: 400px;
}

.toast {
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  text-align: center;
  animation: toastIn 0.2s ease;
  pointer-events: auto;
}

.toast-ok { background: var(--ok); }
.toast-err { background: var(--err); }
.toast-warn { background: var(--warn); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═════ Chip ═════ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  background: var(--border);
  color: var(--text);
  border-radius: var(--radius-full);
  font-size: var(--fs-sm);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s;
}

.chip.active {
  background: var(--accent);
  color: white;
}

.chip-row {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-2) 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar { display: none; }

/* ═════ Badge ═════ */
.badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.badge-ok { background: rgba(46, 125, 50, 0.15); color: var(--ok); }
.badge-warn { background: rgba(255, 160, 0, 0.15); color: var(--warn); }
.badge-err { background: rgba(183, 28, 28, 0.15); color: var(--err); }
.badge-info { background: rgba(25, 118, 210, 0.15); color: var(--info); }

/* ═════ Header ═════ */
.header {
  background: var(--card);
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--accent);
}

.header-sub {
  font-size: var(--fs-sm);
  color: var(--text-dim);
  margin-top: var(--space-1);
}

/* ═════ Empty state ═════ */
.empty {
  text-align: center;
  padding: var(--space-8) var(--space-4);
}

.empty-icon {
  font-size: 56px;
  margin-bottom: var(--space-3);
  opacity: 0.5;
}

.empty-title {
  font-size: var(--fs-md);
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.empty-desc {
  font-size: var(--fs-sm);
  color: var(--text-dim);
}

/* ═════ Spinner ═════ */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-center {
  display: flex;
  justify-content: center;
  padding: var(--space-8);
}

/* ═════ Divider ═════ */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-4) 0;
}

/* ═════ Modal ═════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn 0.2s;
}

.modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s;
}

.modal-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  margin-bottom: var(--space-3);
}

.modal-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.modal-actions .btn { flex: 1; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ═════ Avatar ═════ */
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-lg);
  font-weight: 700;
  flex-shrink: 0;
}

.avatar-lg {
  width: 80px;
  height: 80px;
  font-size: var(--fs-2xl);
}

/* ═════ Switch ═════ */
.switch {
  position: relative;
  width: 48px;
  height: 28px;
  background: var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.switch.on {
  background: var(--accent);
}

.switch.on::after {
  transform: translateX(20px);
}

/* ═════ List Item ═════ */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}

.list-item:last-child {
  border-bottom: none;
}

.list-item-body {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  font-weight: 700;
  font-size: var(--fs-base);
}

.list-item-sub {
  font-size: var(--fs-sm);
  color: var(--text-dim);
  margin-top: 2px;
}
