/* ============================================================
   CALCULADORA FLUTUANTE GLOBAL — Solo Finances
   Botão no canto inferior direito, arrastável, teclado numérico.
============================================================ */

.sfc {
  --sfc-bg:        rgba(15, 23, 42, 0.78);
  --sfc-edge:      rgba(255, 255, 255, 0.09);
  --sfc-edge-hi:   rgba(255, 255, 255, 0.16);
  --sfc-key:       #1B2438;
  --sfc-key-top:   #24304A;
  --sfc-key-txt:   #E2E8F0;
  --sfc-fn:        #2A3550;
  --sfc-op-a:      rgba(99, 102, 241, 0.22);
  --sfc-op-b:      rgba(139, 92, 246, 0.14);
  --sfc-op-txt:    #C7D2FE;
  --sfc-eq-a:      #6366F1;
  --sfc-eq-b:      #8B5CF6;
  --sfc-danger:    #FB7185;
  --sfc-ring:      0 0 0 3px rgba(129, 140, 248, 0.55);
  --sfc-ease:      cubic-bezier(0.22, 1, 0.36, 1);
  --sfc-spring:    cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: var(--font-family, 'Inter', system-ui, sans-serif);
}

/* ── Botão flutuante (FAB) ─────────────────────────────────── */
.sfc-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1500;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 18px;
  padding: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  color: #fff;
  background:
    radial-gradient(120% 120% at 30% 15%, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0) 45%),
    linear-gradient(145deg, #6366F1 0%, #7C3AED 55%, #9333EA 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.35),
    inset 0 -2px 0 rgba(0,0,0,0.18),
    0 10px 24px -6px rgba(99, 102, 241, 0.65),
    0 4px 10px rgba(0,0,0,0.35);
  display: grid;
  place-items: center;
  transition: transform 260ms var(--sfc-spring), box-shadow 200ms ease, opacity 200ms ease, border-radius 260ms var(--sfc-ease);
  isolation: isolate;
}
/* anel de luz girando por trás */
.sfc-fab::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 21px;
  z-index: -1;
  background: conic-gradient(from var(--sfc-angle, 0deg), #818CF8, #C084FC, #22D3EE, #818CF8);
  filter: blur(8px);
  opacity: 0.45;
  animation: sfc-spin 6s linear infinite;
  transition: opacity 200ms ease;
}
.sfc-fab:hover { transform: translateY(-2px) scale(1.04); }
.sfc-fab:hover::before { opacity: 0.8; }
.sfc-fab:active { transform: scale(0.94); }
.sfc-fab:focus-visible { outline: none; box-shadow: var(--sfc-ring), 0 10px 24px -6px rgba(99,102,241,.65); }
.sfc-fab.is-dragging { cursor: grabbing; transform: scale(1.08); transition: none; }
.sfc-fab.is-dragging::before { opacity: 1; }
.sfc-fab svg { width: 26px; height: 26px; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.25)); pointer-events: none; }
.sfc-fab[aria-expanded="true"] { opacity: 0; transform: scale(0.6); pointer-events: none; }

@property --sfc-angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
@keyframes sfc-spin { to { --sfc-angle: 360deg; } }

/* ── Painel ────────────────────────────────────────────────── */
.sfc-panel {
  position: fixed;
  z-index: 1501;
  width: 300px;
  max-width: calc(100vw - 16px);
  border-radius: 24px;
  padding: 10px 14px 14px;
  color: var(--sfc-key-txt);
  background:
    radial-gradient(140% 70% at 0% 0%, rgba(99,102,241,0.16), transparent 60%),
    radial-gradient(120% 60% at 100% 100%, rgba(168,85,247,0.12), transparent 60%),
    var(--sfc-bg);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--sfc-edge);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.07),
    0 30px 60px -20px rgba(0,0,0,0.75),
    0 12px 24px -12px rgba(0,0,0,0.6),
    0 0 0 1px rgba(0,0,0,0.25);
  transform-origin: var(--sfc-origin, 100% 100%);
  opacity: 0;
  transform: scale(0.85) translateY(10px);
  pointer-events: none;
  visibility: hidden;
  transition:
    opacity 180ms ease,
    transform 320ms var(--sfc-spring),
    visibility 0s linear 320ms;
  outline: none;
}
.sfc-panel.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  visibility: visible;
  transition: opacity 180ms ease, transform 320ms var(--sfc-spring), visibility 0s;
}
.sfc-panel.is-dragging { transition: none; box-shadow: inset 0 1px 0 rgba(255,255,255,0.07), 0 40px 80px -20px rgba(0,0,0,0.85), 0 0 0 1px rgba(129,140,248,0.35); }
/* indica quando o teclado está "preso" na calculadora */
.sfc-panel.has-focus { border-color: rgba(129, 140, 248, 0.45); }

/* ── Cabeçalho / alça ──────────────────────────────────────── */
.sfc-head {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  margin: 0 -4px 6px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.sfc-head:active { cursor: grabbing; }
.sfc-grip {
  display: grid;
  grid-template-columns: repeat(3, 3px);
  gap: 3px;
  padding: 0 4px;
  opacity: 0.45;
}
.sfc-grip i { width: 3px; height: 3px; border-radius: 50%; background: currentColor; }
.sfc-title {
  flex: 1;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94A3B8;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sfc-kbd-hint {
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  color: #64748B;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--sfc-edge);
  transition: color 200ms ease, border-color 200ms ease, background 200ms ease;
}
.sfc-panel.has-focus .sfc-kbd-hint { color: #C7D2FE; border-color: rgba(129,140,248,0.4); background: rgba(99,102,241,0.12); }
.sfc-icon-btn {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #94A3B8;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}
.sfc-icon-btn svg { width: 16px; height: 16px; }
.sfc-icon-btn:hover { background: rgba(255,255,255,0.07); color: #F1F5F9; }
.sfc-icon-btn:active { transform: scale(0.9); }
.sfc-icon-btn:focus-visible { outline: none; box-shadow: var(--sfc-ring); }
.sfc-icon-btn[aria-pressed="true"] { color: #C7D2FE; background: rgba(99,102,241,0.18); }

/* ── Visor ─────────────────────────────────────────────────── */
.sfc-screen {
  position: relative;
  border-radius: 16px;
  padding: 12px 14px 10px;
  margin-bottom: 12px;
  background:
    linear-gradient(180deg, rgba(2,6,23,0.65), rgba(2,6,23,0.35));
  box-shadow:
    inset 0 2px 6px rgba(0,0,0,0.55),
    inset 0 0 0 1px rgba(255,255,255,0.04),
    0 1px 0 rgba(255,255,255,0.05);
  text-align: right;
  overflow: hidden;
  cursor: copy;
}
.sfc-expr {
  min-height: 18px;
  font-size: 13px;
  font-weight: 500;
  color: #64748B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: rtl;
  font-variant-numeric: tabular-nums;
}
.sfc-expr bdi { direction: ltr; unicode-bidi: isolate; }
.sfc-value {
  font-size: 36px;
  line-height: 1.15;
  font-weight: 300;
  letter-spacing: -0.02em;
  color: #F8FAFC;
  white-space: nowrap;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
  transition: font-size 120ms ease;
}
.sfc-value.is-md { font-size: 28px; }
.sfc-value.is-sm { font-size: 21px; }
.sfc-value.is-xs { font-size: 16px; }
.sfc-value.is-error { color: var(--sfc-danger); font-size: 20px; font-weight: 500; }
.sfc-value.is-pop { animation: sfc-pop 260ms var(--sfc-spring); }
@keyframes sfc-pop { 0% { transform: translateY(4px); opacity: 0.4; } 100% { transform: none; opacity: 1; } }
.sfc-preview {
  min-height: 16px;
  font-size: 12px;
  font-weight: 600;
  color: #818CF8;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}
.sfc-copied {
  position: absolute;
  left: 12px;
  top: 10px;
  font-size: 11px;
  font-weight: 700;
  color: #34D399;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}
.sfc-copied.is-on { opacity: 1; transform: none; }

/* ── Histórico ─────────────────────────────────────────────── */
.sfc-history {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 280ms var(--sfc-ease), margin 280ms var(--sfc-ease);
}
.sfc-history.is-open { grid-template-rows: 1fr; margin-bottom: 10px; }
.sfc-history > div { overflow: hidden; }
.sfc-history ul {
  list-style: none;
  max-height: 132px;
  overflow-y: auto;
  padding: 2px;
  margin: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(148,163,184,0.3) transparent;
}
.sfc-history li button {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: right;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-variant-numeric: tabular-nums;
  transition: background 150ms ease;
}
.sfc-history li button:hover, .sfc-history li button:focus-visible { background: rgba(255,255,255,0.06); outline: none; }
.sfc-history .h-expr { display: block; font-size: 11px; color: #64748B; }
.sfc-history .h-res  { display: block; font-size: 14px; font-weight: 700; color: #E2E8F0; }
.sfc-history .h-empty { font-size: 12px; color: #64748B; text-align: center; padding: 10px; }

/* ── Teclado ───────────────────────────────────────────────── */
.sfc-keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}
.sfc-k {
  --k-bg: linear-gradient(180deg, var(--sfc-key-top), var(--sfc-key));
  --k-txt: var(--sfc-key-txt);
  --k-glow: rgba(148, 163, 184, 0.0);
  position: relative;
  height: 52px;
  border: 0;
  border-radius: 15px;
  font: inherit;
  font-size: 20px;
  font-weight: 500;
  color: var(--k-txt);
  background: var(--k-bg);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    inset 0 -2px 0 rgba(0,0,0,0.28),
    0 3px 0 rgba(0,0,0,0.35),
    0 6px 12px -6px rgba(0,0,0,0.6);
  transition: transform 90ms ease, box-shadow 90ms ease, filter 150ms ease, background 150ms ease;
  overflow: hidden;
  isolation: isolate;
}
/* brilho que segue o ponteiro */
.sfc-k::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(80px circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,0.14), transparent 60%);
  opacity: 0;
  transition: opacity 200ms ease;
  z-index: -1;
}
.sfc-k:hover::before { opacity: 1; }
.sfc-k:hover { filter: brightness(1.12); }
.sfc-k:active, .sfc-k.is-pressed {
  transform: translateY(3px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    inset 0 -1px 0 rgba(0,0,0,0.2),
    0 0 0 rgba(0,0,0,0.35),
    0 2px 6px -4px rgba(0,0,0,0.6);
  filter: brightness(1.25);
}
.sfc-k:focus-visible { outline: none; box-shadow: var(--sfc-ring), inset 0 1px 0 rgba(255,255,255,0.08); }

/* onda ao clicar */
.sfc-k .sfc-ripple {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 140%;
  aspect-ratio: 1;
  background: rgba(255,255,255,0.22);
  animation: sfc-ripple 480ms ease-out forwards;
  pointer-events: none;
  z-index: -1;
}
@keyframes sfc-ripple { to { transform: translate(-50%, -50%) scale(1); opacity: 0; } }

.sfc-k.fn {
  --k-bg: linear-gradient(180deg, #313D5A, var(--sfc-fn));
  --k-txt: #CBD5E1;
  font-size: 17px;
  font-weight: 600;
}
.sfc-k.clear { --k-txt: var(--sfc-danger); }
.sfc-k.op {
  --k-bg: linear-gradient(180deg, var(--sfc-op-a), var(--sfc-op-b)), linear-gradient(180deg, var(--sfc-key-top), var(--sfc-key));
  --k-txt: var(--sfc-op-txt);
  font-size: 22px;
  box-shadow:
    inset 0 1px 0 rgba(165,180,252,0.18),
    inset 0 0 0 1px rgba(129,140,248,0.18),
    inset 0 -2px 0 rgba(0,0,0,0.28),
    0 3px 0 rgba(0,0,0,0.35),
    0 6px 12px -6px rgba(0,0,0,0.6);
}
.sfc-k.op.is-active {
  --k-bg: linear-gradient(180deg, rgba(129,140,248,0.55), rgba(99,102,241,0.4));
  --k-txt: #fff;
}
.sfc-k.eq {
  grid-row: span 2;
  height: auto;
  font-size: 26px;
  font-weight: 600;
  color: #fff;
  background:
    radial-gradient(120% 80% at 30% 0%, rgba(255,255,255,0.25), transparent 55%),
    linear-gradient(160deg, var(--sfc-eq-a), var(--sfc-eq-b));
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.3),
    inset 0 -2px 0 rgba(0,0,0,0.2),
    0 3px 0 #3730A3,
    0 10px 22px -8px rgba(124, 58, 237, 0.75);
}
.sfc-k.eq:active, .sfc-k.eq.is-pressed {
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 0 0 #3730A3, 0 4px 12px -6px rgba(124,58,237,.75);
}
.sfc-k.zero { grid-column: span 2; }

/* ── Rodapé ───────────────────────────────────────────────── */
.sfc-foot {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.sfc-foot button {
  flex: 1;
  height: 34px;
  border-radius: 11px;
  border: 1px solid var(--sfc-edge);
  background: rgba(255,255,255,0.03);
  color: #CBD5E1;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 100ms ease;
}
.sfc-foot button svg { width: 14px; height: 14px; }
.sfc-foot button:hover:not(:disabled) { background: rgba(99,102,241,0.14); border-color: rgba(129,140,248,0.4); color: #fff; }
.sfc-foot button:active:not(:disabled) { transform: scale(0.97); }
.sfc-foot button:focus-visible { outline: none; box-shadow: var(--sfc-ring); }
.sfc-foot button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Captura de valores do site ───────────────────────────── */
.sfc-pick-hl {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1499;
  pointer-events: none;
  border-radius: 7px;
  background: rgba(99, 102, 241, 0.16);
  box-shadow:
    0 0 0 1.5px rgba(129, 140, 248, 0.85),
    0 0 18px -2px rgba(129, 140, 248, 0.55);
  opacity: 0;
  transition:
    transform 120ms cubic-bezier(0.22, 1, 0.36, 1),
    width 120ms cubic-bezier(0.22, 1, 0.36, 1),
    height 120ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 120ms ease;
}
.sfc-pick-hl.is-on { opacity: 1; }
/* selo "+" no canto, indicando que o valor vai para a calculadora */
.sfc-pick-hl::after {
  content: '+';
  position: absolute;
  top: -8px;
  right: -8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 800 11px/1 var(--font-family, 'Inter', system-ui, sans-serif);
  color: #fff;
  background: linear-gradient(145deg, #6366F1, #9333EA);
  box-shadow: 0 2px 6px rgba(0,0,0,0.45);
  transform: scale(0.4);
  transition: transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.sfc-pick-hl.is-on::after { transform: scale(1); }
html.sfc-pick-hover, html.sfc-pick-hover * { cursor: copy !important; }

.sfc-fly {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1502;
  pointer-events: none;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  font: 700 13px/1.2 var(--font-family, 'Inter', system-ui, sans-serif);
  font-variant-numeric: tabular-nums;
  color: #fff;
  background: linear-gradient(145deg, #6366F1, #8B5CF6);
  box-shadow: 0 8px 20px -6px rgba(124, 58, 237, 0.8), inset 0 1px 0 rgba(255,255,255,0.3);
}

.sfc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* toasts sobem para não ficarem por baixo do botão */
#screen-app:has(.sfc-fab) ~ .toast-container,
body:has(.sfc-fab) .toast-container { bottom: 96px; }

@media (max-width: 480px) {
  .sfc-fab { right: 16px; bottom: 16px; width: 54px; height: 54px; }
  .sfc-panel { width: min(300px, calc(100vw - 16px)); }
  .sfc-k { height: 50px; }
}

@media (prefers-reduced-motion: reduce) {
  .sfc-fab::before { animation: none; }
  .sfc-fab, .sfc-panel, .sfc-k, .sfc-history { transition-duration: 1ms !important; }
  .sfc-value.is-pop, .sfc-k .sfc-ripple { animation: none; }
}

@media print { .sfc-fab, .sfc-panel, .sfc-pick-hl { display: none !important; } }

/* A mesma calculadora permanece acima do lançador durante o cálculo. */
.sfc-panel.is-linked { z-index: 12050; }
