/* ==========================================================================
   FinXure components  (fx-components.css)
   Every reusable piece of UI. Pages are built from these — never restyle a
   component inside a page. If something is missing, add it HERE and to the
   style guide first, then use it.
   Buttons/cards/badges/progress/dialog/toast come from the approved
   dashboard-v4 design; form fields, tables, tabs, alerts, page headers and
   empty states extend the same tokens.
   ========================================================================== */

/* ---- Buttons ---- */
.fx-btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; height: 40px; padding: 0 1.1rem;
  border-radius: var(--r-element); border: 1px solid transparent; font-weight: 600; font-size: .9rem; line-height: 1;
  transition: transform .15s var(--ease), box-shadow .15s, background .15s; white-space: nowrap; text-decoration: none; }
.fx-btn:active { transform: scale(.97); }
.fx-btn[disabled], .fx-btn.is-disabled { opacity: .5; pointer-events: none; }
.fx-btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-low); }
.fx-btn-primary:hover { box-shadow: var(--shadow-med); transform: translateY(-1px); }
.fx-btn-secondary { background: var(--bg-surface); border-color: var(--border-strong); }
.fx-btn-secondary:hover { background: var(--bg-muted); }
.fx-btn-ghost { background: transparent; }
.fx-btn-ghost:hover { background: rgba(127,127,127,.12); }
.fx-btn-danger { background: var(--error); color: #fff; }
.fx-btn-danger:hover { box-shadow: var(--shadow-med); }
.fx-btn-lg { height: 48px; padding: 0 1.5rem; font-size: 1rem; border-radius: var(--r-container); }
.fx-btn-sm { height: 32px; padding: 0 .8rem; font-size: .8125rem; border-radius: var(--r-inner); }
.fx-btn-block { display: flex; width: 100%; }
.fx-icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: var(--r-element);
  border: 1px solid var(--border-strong); background: var(--bg-surface); color: var(--text); }
.fx-icon-btn:hover { background: var(--bg-muted); }

/* ---- Surfaces ---- */
.fx-card { background: var(--bg-card); border-radius: var(--r-container); box-shadow: var(--shadow-low); padding: 1.25rem; }
.fx-card-quiet { background: var(--bg-body); box-shadow: none; }
.fx-card-hover { transition: transform .25s var(--ease), box-shadow .25s var(--ease); }
.fx-card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-med); }
.fx-card-title { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin-bottom: .5rem; }
.fx-stack { display: grid; gap: 1rem; }
.fx-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.fx-divider { height: 1px; background: var(--border); border: 0; margin: 1rem 0; }

/* ---- Badges / chips ---- */
.fx-badge { display: inline-flex; align-items: center; gap: .3rem; height: 22px; padding: 0 .55rem; border-radius: var(--r-full);
  font-size: .72rem; font-weight: 700; background: var(--bg-muted); color: var(--text-2); white-space: nowrap; }
.fx-badge-success { background: var(--success-bg); color: var(--success-text); }
.fx-badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.fx-badge-error   { background: var(--error-bg);   color: var(--error-text); }
.fx-badge-info    { background: var(--info-bg);    color: var(--info-text); }
.fx-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ---- Progress ---- */
.fx-progress { height: 8px; background: var(--bg-muted); border-radius: var(--r-full); overflow: hidden; }
.fx-progress > i { display: block; height: 100%; border-radius: var(--r-full); background: var(--accent); transition: width 1s var(--ease); }
.fx-progress.ok > i { background: var(--success); } .fx-progress.warn > i { background: var(--warning); }
.fx-progress.bad > i { background: var(--error); }  .fx-progress.info > i { background: var(--info); }
.fx-pace { position: relative; height: 12px; background: var(--bg-surface); border-radius: var(--r-full); }
.fx-pace > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: var(--r-full); transition: width .8s var(--ease), background .3s; }
.fx-pace > u { position: absolute; top: -5px; bottom: -5px; width: 2px; background: var(--text); border-radius: 1px; text-decoration: none; }

/* ---- Forms ---- */
.fx-field { display: grid; gap: .35rem; margin-bottom: 1rem; }
.fx-label { font-size: .8125rem; font-weight: 600; color: var(--text-2); }
.fx-hint  { font-size: .75rem; color: var(--text-3); }
.fx-error-text { font-size: .75rem; color: var(--error-text); font-weight: 600; }
.fx-input, .fx-select, .fx-textarea {
  width: 100%; min-height: 42px; padding: .55rem .8rem; border: 1px solid var(--border-strong); border-radius: var(--r-element);
  background: var(--bg-surface); color: var(--text); transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none; }
.fx-textarea { min-height: 96px; resize: vertical; }
.fx-input::placeholder, .fx-textarea::placeholder { color: var(--text-3); }
.fx-input:focus, .fx-select:focus, .fx-textarea:focus { outline: none; border-color: var(--info); box-shadow: 0 0 0 3px var(--info-bg); }
.fx-input[disabled], .fx-select[disabled], .fx-textarea[disabled] { background: var(--bg-body); color: var(--text-3); }
.fx-field.has-error .fx-input, .fx-field.has-error .fx-select, .fx-field.has-error .fx-textarea { border-color: var(--error); box-shadow: 0 0 0 3px var(--error-bg); }
.fx-select { padding-right: 2.2rem; background-repeat: no-repeat; background-position: right .8rem center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%23777' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1l4 4 4-4'/%3E%3C/svg%3E"); }
.fx-amount { position: relative; }
.fx-amount::before { content: "₹"; position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--text-3); font-weight: 600; pointer-events: none; }
.fx-amount .fx-input { padding-left: 1.8rem; font-variant-numeric: tabular-nums; }
.fx-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 480px) { .fx-form-row { grid-template-columns: 1fr; } }
.fx-check { display: flex; gap: .6rem; align-items: flex-start; font-size: .875rem; cursor: pointer; }
.fx-check input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--accent); flex: none; }

/* ---- Tables ---- */
.fx-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.fx-table { width: 100%; font-size: .875rem; }
.fx-table th { text-align: left; padding: .6rem .8rem; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3); border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
.fx-table td { padding: .7rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.fx-table tbody tr:hover td { background: var(--bg-body); }
.fx-table tr:last-child td { border-bottom: 0; }
.fx-table .num, .fx-table .fx-num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Tabs / segmented ---- */
.fx-tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; scrollbar-width: none; }
.fx-tab { padding: .65rem .9rem; font-weight: 600; font-size: .9rem; color: var(--text-3); border: 0; background: none; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.fx-tab:hover { color: var(--text); }
.fx-tab.on, .fx-tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.fx-seg { display: inline-flex; background: var(--bg-surface); padding: 3px; border-radius: var(--r-full); }
.fx-seg button { border: 0; background: transparent; padding: .18rem .6rem; border-radius: var(--r-full); font-weight: 700; font-size: .75rem; color: var(--text-2); }
.fx-seg button.on { background: var(--accent); color: var(--on-accent); }

/* ---- Alerts (inline messages, flash) ---- */
.fx-alert { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--r-container); font-size: .875rem;
  background: var(--info-bg); color: var(--info-text); margin-bottom: 1rem; line-height: 1.5; }
.fx-alert b, .fx-alert strong { font-weight: 700; }
.fx-alert-success { background: var(--success-bg); color: var(--success-text); }
.fx-alert-warning { background: var(--warning-bg); color: var(--warning-text); }
.fx-alert-error   { background: var(--error-bg);   color: var(--error-text); }

/* ---- Page header, sections, rows ---- */
.fx-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.fx-page-head h1 { font-size: 1.75rem; line-height: 1.15; font-weight: 800; letter-spacing: -.03em; }
.fx-page-head p { color: var(--text-3); margin-top: .25rem; }
.fx-page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.fx-section { margin-top: 2.5rem; }
.fx-section-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: .9rem;
  font-size: .75rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); }
.fx-section-label a, .fx-link { color: var(--info-text); text-transform: none; letter-spacing: 0; font-size: .82rem; font-weight: 700; }
.fx-kv { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-top: 1px solid var(--border); font-weight: 600; }
.fx-kv:first-child { border-top: 0; } .fx-kv > span:first-child { color: var(--text-2); font-weight: 500; }
.fx-row { display: flex; align-items: center; gap: .9rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); background: transparent;
  width: 100%; text-align: left; color: var(--text); border-top: 0; border-left: 0; border-right: 0; }
.fx-row:last-child { border-bottom: 0; }
.fx-row-link { cursor: pointer; transition: background .15s; } .fx-row-link:hover { background: var(--bg-surface); }
.fx-list { background: var(--bg-body); border-radius: var(--r-container); overflow: hidden; }

/* ---- Empty state ---- */
.fx-empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-3); }
.fx-empty .fx-empty-icon { width: 52px; height: 52px; margin: 0 auto .9rem; border-radius: 16px; background: var(--bg-body); display: grid; place-items: center; color: var(--text-3); }
.fx-empty b { display: block; color: var(--text); font-size: 1rem; margin-bottom: .25rem; }

/* ---- Stat tile ---- */
.fx-stat { display: grid; gap: .15rem; }
.fx-stat .t { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.fx-stat .v { font-size: 1.5rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.fx-stat .d { font-size: .8rem; color: var(--text-2); }

/* ---- Dialog (native <dialog>), popover, toast ---- */
.fx-dialog { margin: auto; border: 0; border-radius: var(--r-page); padding: 0; width: min(520px, 92vw); background: var(--bg-card); color: var(--text); box-shadow: var(--shadow-high); }
.fx-dialog::backdrop { background: rgba(0,0,0,.5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.fx-dialog-h { padding: 1.6rem 1.6rem 1rem; } .fx-dialog-b { padding: 0 1.6rem 1rem; } .fx-dialog-f { padding: .5rem 1.6rem 1.6rem; display: flex; gap: .5rem; justify-content: flex-end; }
.fx-dialog-x { float: right; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--bg-muted); color: var(--text); }
.fx-pop { position: absolute; z-index: var(--z-popover); width: 270px; background: var(--bg-card); border-radius: var(--r-container); box-shadow: var(--shadow-high);
  padding: 1rem 1.1rem; border: 1px solid var(--border); display: none; font-size: .88rem; }
.fx-pop.show { display: block; }
.fx-toast { position: fixed; left: 50%; bottom: 36px; transform: translate(-50%, 20px); background: var(--accent); color: var(--on-accent);
  padding: .7rem 1.1rem; border-radius: var(--r-full); font-weight: 600; box-shadow: var(--shadow-high); opacity: 0; pointer-events: none;
  transition: .3s var(--ease); z-index: var(--z-toast); max-width: 92vw; }
.fx-toast.show { opacity: 1; transform: translate(-50%, 0); }
.fx-toast code { font-family: var(--font-mono); font-size: .85em; opacity: .8; }

/* ---- Avatar / plan chip ---- */
.fx-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex: none; }
.fx-plan { font-size: .6rem; font-weight: 800; letter-spacing: .04em; background: var(--success); color: #fff; padding: .1rem .38rem; border-radius: 5px; }
.fx-plan-free { background: var(--bg-muted); color: var(--text-2); }
.fx-plan-pro  { background: var(--warning-bg); color: var(--warning-text); }
