/* ============================================================
   components.css - Reusable UI Components
   Glass Card, Buttons, Forms, Table, Modal, Toast, Credit Gauge
   ============================================================ */

/* ----- ۱. GLASS CARD (base) ----- */
.glass-card {
  background: var(--surface-glass);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--surface-glass-border);
  border-radius: var(--radius-card);
  padding: var(--space-6);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* خط روشن بالای کارت (نشان تجاری Liquid Glass) */
.glass-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--surface-glass-highlight),
    transparent
  );
  opacity: 0.7;
  pointer-events: none;
}

.glass-card:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
}

.glass-card:active {
  transform: scale(0.995);
}

/* ----- ۲. BUTTONS ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-button);
  font-family: var(--font-sans);
  font-weight: var(--font-weight-heading);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  white-space: nowrap;
  text-align: center;
  position: relative;
  overflow: hidden;
  user-select: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn .btn-icon {
  font-size: 1.2rem;
  line-height: 1;
  display: inline-flex;
}

/* Primary */
.btn-primary {
  background: var(--accent-primary);
  color: var(--text-on-accent);
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(15, 107, 92, 0.2);
}
.btn-primary:hover {
  background: var(--accent-primary-hover);
  box-shadow: 0 6px 20px rgba(15, 107, 92, 0.3);
}

/* Outline */
.btn-outline {
  background: transparent;
  border: 1px solid var(--surface-glass-border);
  color: var(--text-primary);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.btn-outline:hover {
  background: var(--accent-primary-soft);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--accent-primary-soft);
  color: var(--accent-primary);
}

/* Danger variant */
.btn-danger {
  background: rgba(199, 62, 58, 0.1);
  border: 1px solid rgba(199, 62, 58, 0.3);
  color: var(--danger);
}
.btn-danger:hover {
  background: rgba(199, 62, 58, 0.2);
}

/* Size variants */
.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-input);
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-base);
  border-radius: var(--radius-button);
}

/* Full width */
.btn-block {
  width: 100%;
  display: flex;
}

/* ----- ۳. FORMS ----- */
.input-glass,
.select-glass {
  background: var(--surface-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--surface-glass-border);
  border-radius: var(--radius-input);
  padding: var(--space-3) var(--space-4);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  outline: none;
  transition: all var(--transition-fast);
  width: 100%;
}

.input-glass::placeholder {
  color: var(--text-muted);
}

.input-glass:focus,
.select-glass:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-soft);
  background: rgba(255, 255, 255, 0.08);
}

/* Select آراسته */
.select-glass {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235C6B66' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 32px;
}

/* Checkbox & Radio */
.checkbox-label,
.radio-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent-primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ----- ۴. DATA TABLE ----- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.data-table th {
  text-align: right;
  padding: var(--space-3) var(--space-4);
  background: var(--accent-primary-soft);
  font-weight: var(--font-weight-heading);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--surface-glass-border);
  white-space: nowrap;
}

.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--surface-glass-border);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover td {
  background: var(--accent-primary-soft);
}

/* سلول‌های عددی */
.data-table .cell-num {
  font-family: var(--font-mono);
  font-weight: 700;
  direction: ltr;
  display: inline-block;
}

/* ----- ۵. MODAL ----- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-container {
  background: var(--bg-elevated);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid var(--surface-glass-border);
  border-radius: var(--radius-modal);
  padding: var(--space-8);
  max-width: 650px;
  width: 100%;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.96);
  transition: transform var(--transition-slow);
}

.modal-overlay.active .modal-container {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--surface-glass-border);
}

.modal-header h2 {
  font-size: var(--text-xl);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.modal-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-glass);
  border: 1px solid var(--surface-glass-border);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  background: var(--accent-primary-soft);
  color: var(--accent-primary);
}

/* ----- ۶. TOAST ----- */
.toast-container {
  position: fixed;
  top: var(--space-5);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
  width: auto;
}

.toast {
  background: var(--bg-elevated);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--surface-glass-border);
  border-radius: var(--radius-pill);
  padding: var(--space-3) var(--space-6);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-body);
  box-shadow: var(--shadow-md);
  animation: toastIn 0.4s ease, toastOut 0.4s ease 2.8s forwards;
  pointer-events: all;
  white-space: nowrap;
  text-align: center;
}

.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger); color: var(--danger); }
.toast.warning { border-color: var(--accent-warm); color: var(--accent-warm); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-20px); }
}

/* ----- ۷. CREDIT GAUGE (امضای محصول) ----- */
.credit-gauge {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.credit-gauge svg {
  transform: rotate(-90deg); /* شروع از بالای حلقه */
}

.credit-gauge .gauge-bg {
  fill: none;
  stroke: var(--surface-glass-border);
  stroke-width: 6;
}

.credit-gauge .gauge-fill {
  fill: none;
  stroke: var(--accent-warm);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* در حالت کاهش حرکت، انیمیشن پر شدن غیرفعال شود */
@media (prefers-reduced-motion: reduce) {
  .credit-gauge .gauge-fill {
    transition: none;
  }
}

.credit-gauge .gauge-text {
  position: absolute;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--text-primary);
}