/* =============================================================
   JySerai.bf — Reusable Components
   ============================================================= */

/* ---------- BUTTON ---------- */
.btn {
  --btn-bg: transparent;
  --btn-fg: var(--text);
  --btn-border: transparent;
  --btn-hover-bg: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--r-md);
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-border);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn:hover { background: var(--btn-hover-bg); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  --btn-bg: linear-gradient(135deg, var(--brand-3) 0%, var(--brand) 100%);
  --btn-fg: #1a1108;
  --btn-hover-bg: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 32px rgba(244,196,48,.35); }
[data-theme="light"] .btn-primary { --btn-fg: #fdf6d8; }

.btn-ghost {
  --btn-bg: var(--accent-soft);
  --btn-fg: var(--accent);
  --btn-border: var(--border-strong);
  --btn-hover-bg: var(--accent-soft-strong);
}

.btn-outline {
  --btn-bg: transparent;
  --btn-border: var(--border-strong);
  --btn-hover-bg: var(--surface);
}

.btn-subtle {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-border: var(--border);
  --btn-hover-bg: var(--surface-2);
}

.btn-danger {
  --btn-bg: var(--danger-soft);
  --btn-fg: var(--danger);
  --btn-border: transparent;
  --btn-hover-bg: rgba(239,68,68,.2);
}

.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: var(--r-sm); }
.btn-lg { padding: 15px 26px; font-size: 15px; border-radius: var(--r-md); }
.btn-block { width: 100%; }
.btn-icon { padding: 10px; aspect-ratio: 1; }

/* ---------- CARD ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  transition: border-color var(--dur-med) var(--ease-out),
              transform var(--dur-med) var(--ease-out),
              box-shadow var(--dur-med) var(--ease-out);
}
.card-interactive { cursor: pointer; }
.card-interactive:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.card-elevated {
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}
.card-flush { padding: 0; overflow: hidden; }

/* ---------- BADGE / CHIP ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--border);
}
.chip-success { background: var(--success-soft); color: var(--success); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-dot::before {
  content: '';
  width: 6px; height: 6px;
  background: currentColor;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ---------- INPUT ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.field .hint {
  font-size: 12px;
  color: var(--text-subtle);
  line-height: 1.4;
}
.input, .textarea, .select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
  outline: none;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--border-focus);
  background: var(--surface);
}
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.textarea { min-height: 80px; resize: vertical; }

/* Slider */
.slider {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: var(--r-pill);
  appearance: none;
  outline: none;
  cursor: pointer;
}
.slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  cursor: pointer;
}
.slider::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  cursor: pointer;
}

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px; height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: var(--r-pill);
  transition: background var(--dur-fast);
  cursor: pointer;
}
.switch .track::before {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: var(--bg);
  border-radius: 50%;
  transition: transform var(--dur-fast) var(--ease-out);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::before { transform: translateX(20px); }

/* ---------- MODAL ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  opacity: 0;
  transition: opacity var(--dur-med) var(--ease-out);
}
.modal-backdrop.open { display: flex; opacity: 1; }
.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: var(--s-8);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(.96);
  transition: transform var(--dur-med) var(--ease-out);
}
.modal-backdrop.open .modal { transform: none; }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: var(--s-5);
}
.modal-title { font-size: 22px; margin-bottom: 4px; }
.modal-sub { color: var(--text-muted); font-size: 14px; }
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: var(--s-6);
  flex-wrap: wrap;
}

/* ---------- TOAST ---------- */
.toast-wrap {
  position: fixed;
  top: 88px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  pointer-events: none;
}
.toast {
  padding: 14px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  font-size: 14px;
  box-shadow: var(--shadow-md);
  animation: toast-in .3s var(--ease-out);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toast-in {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ---------- THEME TOGGLE ---------- */
.theme-toggle {
  width: 40px; height: 40px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
  color: var(--text);
}
.theme-toggle:hover { background: var(--surface-2); border-color: var(--border-strong); }
.theme-toggle .sun { display: none; }
.theme-toggle .moon { display: block; }
[data-theme="light"] .theme-toggle .sun { display: block; }
[data-theme="light"] .theme-toggle .moon { display: none; }

/* ---------- LOGO ---------- */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -.02em;
  color: var(--text-strong);
}
.logo-mark {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand-3), var(--brand-2));
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-brand);
}
.logo-mark svg { width: 22px; height: 22px; color: #1a1108; }
.logo-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.4), transparent 50%);
}
.logo-text .tld { color: var(--accent); font-weight: 500; }

/* ---------- QUOTA / PROGRESS ---------- */
.progress {
  width: 100%;
  height: 8px;
  background: var(--bg-sunken);
  border-radius: var(--r-pill);
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--brand-soft));
  border-radius: var(--r-pill);
  transition: width var(--dur-slow) var(--ease-out);
}
.progress-fill.warn { background: linear-gradient(90deg, var(--warn), #f97316); }
.progress-fill.full { background: linear-gradient(90deg, var(--danger), #dc2626); }

/* ---------- TABLE ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-2); }

/* ---------- TABS ---------- */
.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.tab {
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--bg-elevated);
  color: var(--text-strong);
  box-shadow: var(--shadow-sm);
}
