/* ==========================================================================
   TGSIMS  -  Components
   Reusable UI primitives shared across every page.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  line-height: 1;
  padding: 0.75rem 1.25rem;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: background-color var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              color var(--dur) var(--ease),
              transform var(--dur-fast) var(--ease),
              box-shadow var(--dur) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }

.btn-primary {
  background: var(--brand-500);
  color: var(--on-brand);
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover { background: var(--brand-600); }

.btn-dark {
  background: var(--surface-inv);
  color: #eaf6ff;
}
.btn-dark:hover { background: #0a1830; }
/* In dark mode a near-black fill vanishes against dark surfaces, so the
   high-contrast "dark" button becomes the brand blue to stay a clear CTA. */
[data-theme="dark"] .btn-dark { background: var(--brand-500); color: #fff; box-shadow: var(--shadow-brand); }
[data-theme="dark"] .btn-dark:hover { background: var(--brand-600); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-3); border-color: var(--text-dim); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-success {
  background: var(--hue-success);
  color: #fff;
}
.btn-success:hover { filter: brightness(0.95); }

.btn-outline-brand {
  background: transparent;
  color: var(--brand);
  border-color: var(--brand);
}
.btn-outline-brand:hover { background: var(--brand-soft); }

.btn-block { width: 100%; }
.btn-sm { padding: 0.5rem 0.85rem; font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn-lg { padding: 0.95rem 1.6rem; font-size: var(--fs-base); border-radius: var(--r-md); }
.btn-icon { padding: 0.6rem; width: 40px; height: 40px; }

/* --------------------------------------------------------------------------
   Cards & surfaces
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: var(--sp-6); }
.card-lg { border-radius: var(--r-xl); }

.card-hover {
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
}
.card-hover:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.panel-dark {
  background: var(--surface-inv);
  color: var(--text-inv);
  border-radius: var(--r-xl);
}

.section-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
}

/* --------------------------------------------------------------------------
   Icon tiles (feature/topic icons)
   -------------------------------------------------------------------------- */
.icon-tile {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  background: var(--brand-soft);
  color: var(--brand);
  flex-shrink: 0;
}
.icon-tile svg { width: 22px; height: 22px; }
.icon-tile-lg { width: 54px; height: 54px; border-radius: var(--r-lg); }
.icon-tile-round { border-radius: var(--r-full); }
.icon-tile-dark { background: var(--surface-inv); color: #eaf6ff; }

/* --------------------------------------------------------------------------
   Badges & status pills
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  padding: 0.3rem 0.65rem;
  border-radius: var(--r-full);
  line-height: 1;
}
.badge-dot::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-success { color: var(--success); background: var(--success-bg); }
.badge-warning { color: var(--warning); background: var(--warning-bg); }
.badge-danger  { color: var(--danger);  background: var(--danger-bg); }
.badge-info    { color: var(--info);    background: var(--info-bg); }
.badge-neutral { color: var(--text-muted); background: var(--surface-3); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.4rem 0.8rem;
  border-radius: var(--r-full);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0.5rem 0.9rem;
  border-radius: var(--r-full);
  font-weight: var(--fw-semi);
  font-size: var(--fs-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.field { margin-bottom: var(--sp-5); }
.label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  color: var(--text);
  margin-bottom: var(--sp-2);
}
.label-muted { color: var(--text-muted); font-weight: var(--fw-medium); }

.input,
.select,
.textarea {
  width: 100%;
  font-size: var(--fs-sm);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 0.8rem 1rem;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              background-color var(--dur) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-dim); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--ring);
}
.textarea { resize: vertical; min-height: 96px; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235a6b86' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.5rem;
  cursor: pointer;
}
[data-theme="dark"] .select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239aa8c2' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

/* Input with leading/trailing adornment */
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-left: 2.6rem; }
.input-group .input-icon {
  position: absolute;
  left: 0.9rem;
  color: var(--text-dim);
  pointer-events: none;
  display: grid; place-items: center;
}
.input-group .input-icon svg { width: 18px; height: 18px; }
.input-group .input-affix-right { padding-right: 3rem; }
.input-toggle {
  position: absolute;
  right: 0.75rem;
  color: var(--text-dim);
  display: grid; place-items: center;
  padding: 4px;
  border-radius: var(--r-xs);
}
.input-toggle:hover { color: var(--text); }
.input-toggle svg { width: 18px; height: 18px; }
.input-toggle .i-eye-off { display: none; }
.input-toggle.is-showing .i-eye { display: none; }
.input-toggle.is-showing .i-eye-off { display: block; }

/* Checkbox */
.check {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box {
  width: 18px; height: 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  display: grid; place-items: center;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all var(--dur) var(--ease);
}
.check .box svg { width: 12px; height: 12px; color: #fff; opacity: 0; transform: scale(0.6); transition: all var(--dur) var(--ease); }
.check input:checked + .box { background: var(--brand-500); border-color: var(--brand-500); }
.check input:checked + .box svg { opacity: 1; transform: scale(1); }
.check input:focus-visible + .box { box-shadow: 0 0 0 3px var(--ring); }

/* Segmented control / preset chips */
.chip-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  padding: 0.55rem 1rem;
  border-radius: var(--r-full);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: var(--fw-semi);
  font-size: var(--fs-sm);
  transition: all var(--dur) var(--ease);
}
.chip:hover { border-color: var(--brand-400); }
.chip.is-active {
  border-color: var(--brand-500);
  color: var(--brand);
  background: var(--brand-soft);
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.table thead th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 0 var(--sp-4) var(--sp-3);
  white-space: nowrap;
}
.table tbody td {
  padding: var(--sp-4);
  border-top: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.table tbody tr { transition: background-color var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table .td-strong { font-weight: var(--fw-semi); }
.table .td-mono { font-family: var(--font-mono); letter-spacing: 0.02em; }
.table .td-dim { color: var(--text-muted); }
.strike { text-decoration: line-through; color: var(--text-dim); }

/* Service cell (icon + name) */
.svc {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  font-weight: var(--fw-semi);
}
.svc-badge {
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  color: #fff;
  font-weight: var(--fw-bold);
  font-size: var(--fs-xs);
}

/* Country flag chip (placeholder-safe: shows ISO code) */
.flag {
  display: inline-grid;
  place-items: center;
  min-width: 26px; height: 18px;
  padding: 0 4px;
  border: 1px dashed var(--border-strong);
  border-radius: 4px;
  font-size: 10px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* OTP code chip + copy */
.code-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-weight: var(--fw-bold);
  letter-spacing: 0.12em;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: var(--r-sm);
  padding: 0.4rem 0.7rem;
}
.copy-btn { color: var(--text-dim); display: grid; place-items: center; }
.copy-btn:hover { color: var(--brand); }
.copy-btn svg { width: 15px; height: 15px; }

/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */
.pagination { display: flex; align-items: center; gap: var(--sp-2); }
.page-btn {
  min-width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  transition: all var(--dur) var(--ease);
}
.page-btn:hover { border-color: var(--brand-400); color: var(--text); }
.page-btn.is-active { background: var(--brand-500); border-color: var(--brand-500); color: #fff; }
.page-btn svg { width: 16px; height: 16px; }

/* --------------------------------------------------------------------------
   Tabs
   -------------------------------------------------------------------------- */
.tabs { display: flex; flex-direction: column; gap: var(--sp-1); }
.tab {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0.7rem 0.9rem;
  border-radius: var(--r-md);
  color: var(--text-muted);
  font-weight: var(--fw-semi);
  font-size: var(--fs-sm);
  transition: all var(--dur) var(--ease);
}
.tab svg { width: 18px; height: 18px; }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.is-active { background: var(--brand-soft); color: var(--brand); }

/* --------------------------------------------------------------------------
   Accordion (FAQ)
   -------------------------------------------------------------------------- */
.accordion { display: flex; flex-direction: column; gap: var(--sp-3); }
.acc-item {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.acc-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  font-weight: var(--fw-semi);
  color: var(--text);
  text-align: left;
  font-size: var(--fs-sm);
}
.acc-head .chevron {
  transition: transform var(--dur) var(--ease);
  color: var(--text-dim);
  flex-shrink: 0;
}
.acc-head svg { width: 18px; height: 18px; }
.acc-item.is-open .chevron { transform: rotate(180deg); }
.acc-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--dur-slow) var(--ease);
}
.acc-body-inner {
  padding: 0 var(--sp-5) var(--sp-5);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: var(--lh-base);
}

/* --------------------------------------------------------------------------
   Dropdown menu
   -------------------------------------------------------------------------- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), visibility var(--dur);
  z-index: var(--z-dropdown);
}
.dropdown.is-open .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0.6rem 0.75rem;
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  width: 100%;
  text-align: left;
}
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-item svg { width: 16px; height: 16px; color: var(--text-muted); }
.dropdown-sep { height: 1px; background: var(--border); margin: var(--sp-2) 0; }

/* --------------------------------------------------------------------------
   Avatar
   -------------------------------------------------------------------------- */
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-3);
  display: grid; place-items: center;
  color: var(--text-muted);
  font-weight: var(--fw-bold);
  font-size: var(--fs-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.avatar-sm { width: 32px; height: 32px; font-size: var(--fs-xs); }
.avatar-lg { width: 72px; height: 72px; font-size: var(--fs-lg); }

/* --------------------------------------------------------------------------
   Toggle switch
   -------------------------------------------------------------------------- */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--border-strong);
  border-radius: var(--r-full);
  transition: background-color var(--dur) var(--ease);
}
.switch .track::before {
  content: "";
  position: absolute;
  height: 18px; width: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--dur) var(--ease);
  box-shadow: var(--shadow-xs);
}
.switch input:checked + .track { background: var(--brand-500); }
.switch input:checked + .track::before { transform: translateX(20px); }

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  background: rgba(6, 12, 24, 0.6);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease), visibility var(--dur);
}
.modal.is-open { opacity: 1; visibility: visible; }
.modal-box {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  transform: translateY(16px) scale(0.98);
  transition: transform var(--dur-slow) var(--ease-out);
  max-height: 90vh;
  overflow-y: auto;
}
.modal.is-open .modal-box { transform: translateY(0) scale(1); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: var(--fs-md); font-weight: var(--fw-bold); }
.modal-body { padding: var(--sp-6); }
.modal-close {
  color: var(--text-dim);
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  font-size: 1.4rem;
  line-height: 1;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */
.toast-stack {
  position: fixed;
  top: var(--sp-6);
  right: var(--sp-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  max-width: 360px;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand-500);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  color: var(--text);
  animation: toastIn var(--dur-slow) var(--ease-out) both;
}
.toast.is-success { border-left-color: var(--success); }
.toast.is-error { border-left-color: var(--danger); }
.toast .toast-ico { flex-shrink: 0; display: grid; place-items: center; }
.toast .toast-ico svg { width: 20px; height: 20px; }
.toast.is-success .toast-ico { color: var(--success); }
.toast.is-error .toast-ico { color: var(--danger); }
.toast.is-info .toast-ico { color: var(--brand); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast.leaving { animation: toastOut var(--dur) var(--ease) forwards; }
@keyframes toastOut {
  to { opacity: 0; transform: translateX(24px); }
}

/* --------------------------------------------------------------------------
   Theme toggle & currency switch (topbar controls)
   -------------------------------------------------------------------------- */
.icon-btn {
  position: relative;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: var(--r-full);
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all var(--dur) var(--ease);
}
.icon-btn:hover { color: var(--text); background: var(--surface-3); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .dot {
  position: absolute; top: 9px; right: 10px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--surface);
}

/* Theme toggle icon swap */
.theme-toggle .i-sun { display: none; }
.theme-toggle .i-moon { display: block; }
[data-theme="dark"] .theme-toggle .i-sun { display: block; }
[data-theme="dark"] .theme-toggle .i-moon { display: none; }

/* Currency segmented switch */
.cur-switch {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.cur-switch button {
  min-width: 38px;
  padding: 0.35rem 0.6rem;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--text-muted);
  transition: all var(--dur) var(--ease);
}
.cur-switch button.is-active {
  background: var(--brand-500);
  color: #fff;
  box-shadow: var(--shadow-xs);
}

/* --------------------------------------------------------------------------
   Misc
   -------------------------------------------------------------------------- */
.divider { height: 1px; background: var(--border); border: 0; margin: var(--sp-6) 0; }
.dot-sep { color: var(--text-dim); }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* Placeholder image box (used until real assets are dropped in) */
.img-ph {
  position: relative;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, var(--surface-2), var(--surface-3));
  color: var(--text-dim);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.img-ph svg { width: 34px; height: 34px; opacity: 0.6; }
.img-ph .img-ph-label {
  position: absolute;
  bottom: 8px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
/* When a real <img> is present inside, it covers the placeholder */
.img-ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
