/* ============================================================
   Ubongo Cloud 2.1 — Components
   Pills, cards, chips, model switcher, modals, gradient AI box
   ============================================================ */

/* ---------- Pill buttons ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  border: none;
  border-radius: var(--radius-pill);
  padding: 12px 22px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--fs-body);
  line-height: 1;
  min-height: 44px;
  cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
  text-decoration: none;
  white-space: nowrap;
}
.pill:hover { transform: translateY(-2px); text-decoration: none; }
.pill:active { transform: translateY(0); }
.pill .cost { opacity: .75; font-weight: 500; }

/* primary = ink black */
.pill--primary { background: var(--ink); color: #fff; box-shadow: var(--shadow-soft); }
.pill--primary:hover { box-shadow: var(--shadow-lift); }

/* money = green */
.pill--money { background: var(--green); color: #fff; box-shadow: var(--shadow-soft); }
.pill--money:hover { background: var(--green-dark); }

/* secondary = white + mist border */
.pill--secondary { background: var(--paper); color: var(--ink); border: 1.5px solid var(--mist); }
.pill--secondary:hover { border-color: var(--ink); }

/* indigo = secondary action / link emphasis */
.pill--indigo { background: var(--indigo); color: #fff; }
.pill--indigo:hover { background: var(--indigo-dark); }

.pill--sm { padding: 8px 16px; min-height: 36px; font-size: var(--fs-small); }
.pill--lg { padding: 16px 30px; font-size: 18px; min-height: 56px; }
.pill--block { width: 100%; justify-content: center; }
.pill:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- Sparkle chip ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: .45em;
  background: var(--paper);
  border: 1.5px solid var(--mist);
  border-radius: var(--radius-pill);
  padding: 9px 16px;
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: border-color .15s var(--ease), transform .15s var(--ease);
  min-height: 40px;
}
.chip:hover { border-color: var(--indigo); transform: translateY(-1px); }
.chip .spark { color: var(--indigo); }
.chip--active { border-color: var(--ink); background: var(--ink); color: #fff; }
.chip--active .spark { color: var(--lavender); }

/* tab pills */
.tabs { display: inline-flex; gap: 8px; background: var(--cloud); padding: 5px; border-radius: var(--radius-pill); }
.tab { border: none; background: transparent; border-radius: var(--radius-pill); padding: 8px 18px; font-weight: 600; font-size: var(--fs-small); cursor: pointer; color: var(--muted); min-height: 38px; }
.tab--active { background: var(--paper); color: var(--ink); box-shadow: var(--shadow-soft); }

/* ---------- Cards ---------- */
.card {
  background: var(--paper);
  border: 1px solid var(--mist);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
}
.card--pad { padding: 22px; }
.card--lift { transition: transform .18s var(--ease), box-shadow .18s var(--ease); }
.card--lift:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }

.section { background: var(--cloud); border-radius: var(--radius-card); padding: 24px; }

/* ---------- Workspace tile ---------- */
.ws-tile {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: var(--paper);
  border: 1px solid var(--mist);
  border-radius: var(--radius-tile);
  padding: 20px 12px;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.ws-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); text-decoration: none; }
.ws-tile .mark { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; }
.ws-tile .mark svg { width: 32px; height: 32px; }
.ws-tile .label { font-weight: 600; font-size: var(--fs-small); }

/* ---------- Credit pill ---------- */
.credit-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--green); color: #fff;
  border: none; border-radius: var(--radius-pill);
  padding: 10px 16px; font-weight: 700; cursor: pointer; min-height: 44px;
  transition: transform .15s var(--ease);
}
.credit-pill:hover { transform: translateY(-1px); }
.credit-pill.flash { animation: creditFlash .6s var(--ease); }
@keyframes creditFlash { 0%{ transform: scale(1);} 40%{ transform: scale(1.12); background: var(--green-dark);} 100%{ transform: scale(1);} }

/* ---------- Gradient AI input ---------- */
.ai-box-wrap { position: relative; padding: 3px; border-radius: var(--radius-input); }
.ai-box-wrap::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 3px;
  background: linear-gradient(120deg, var(--indigo), var(--lavender), var(--coral), var(--indigo));
  background-size: 300% 300%;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: gradientMove 6s linear infinite;
}
@keyframes gradientMove { 0%{ background-position: 0% 50%; } 100%{ background-position: 300% 50%; } }
.ai-box {
  display: flex; align-items: center; gap: 12px;
  background: var(--paper); border-radius: calc(var(--radius-input) - 2px);
  padding: 16px 18px;
}
.ai-box .spark { color: var(--indigo); font-size: 22px; flex: none; }
.ai-box input, .ai-box textarea {
  flex: 1; border: none; outline: none; font-family: var(--font-body);
  font-size: 18px; background: transparent; color: var(--ink); resize: none;
}
.ai-box .send {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  background: var(--ink); color: #fff; border: none; cursor: pointer;
  display: grid; place-items: center; font-size: 18px; transition: transform .15s var(--ease);
}
.ai-box .send:hover { transform: scale(1.06); }

/* ---------- Model switcher ---------- */
.model-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--paper); border: 1.5px solid var(--mist);
  border-radius: var(--radius-pill); padding: 9px 16px; font-weight: 600;
  cursor: pointer; min-height: 44px;
}
.model-pill:hover { border-color: var(--ink); }
.model-pill .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); }

.switcher-panel {
  position: absolute; z-index: 60; top: calc(100% + 8px); left: 0;
  width: 360px; max-width: 92vw; max-height: 70vh; overflow-y: auto;
  background: var(--paper); border: 1px solid var(--mist);
  border-radius: var(--radius-tile); box-shadow: var(--shadow-lift); padding: 16px;
}
.switcher-panel h4 { font-weight: 700; font-size: 15px; margin-bottom: 12px; display:flex; justify-content:space-between; align-items:center; }
.tier-head { font-weight: 700; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; margin: 14px 0 8px; display: flex; align-items: center; gap: 6px; }
.tier-head.cheap { color: var(--tier-cheap); }
.tier-head.balanced { color: var(--tier-balanced); }
.tier-head.premium { color: var(--tier-premium); }
.model-card {
  border: 1.5px solid var(--mist); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px;
  cursor: pointer; transition: border-color .15s var(--ease), background .15s var(--ease);
}
.model-card:hover { background: var(--cloud); }
.model-card.selected.cheap { border-color: var(--tier-cheap); box-shadow: 0 0 0 2px var(--tier-cheap) inset; }
.model-card.selected.balanced { border-color: var(--tier-balanced); box-shadow: 0 0 0 2px var(--tier-balanced) inset; }
.model-card.selected.premium { border-color: var(--tier-premium); box-shadow: 0 0 0 2px var(--tier-premium) inset; }
.model-card .row1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.model-card .name { font-weight: 700; }
.model-card .cost { font-weight: 600; font-size: var(--fs-small); white-space: nowrap; }
.model-card .row2 { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); margin-top: 4px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-live { background: var(--green); }
.status-busy { background: #E8A33D; }
.status-down { background: var(--danger); }
.star { color: var(--coral); }

/* ---------- Modal / overlay ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(16,17,20,.45);
  display: grid; place-items: center; z-index: 100; padding: 16px;
  animation: fadeIn .2s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--paper); border-radius: var(--radius-tile);
  width: 440px; max-width: 96vw; padding: 26px; box-shadow: var(--shadow-lift);
  animation: popIn .25s var(--ease);
}
@keyframes popIn { from { opacity:0; transform: translateY(10px) scale(.98);} to { opacity:1; transform: none;} }
.modal h3 { display: flex; justify-content: space-between; align-items: center; }
.modal .close { background: none; border: none; font-size: 24px; cursor: pointer; line-height: 1; color: var(--muted); }
.amount-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin: 16px 0; }
.amount-opt {
  border: 1.5px solid var(--mist); border-radius: var(--radius-card); padding: 14px 8px;
  text-align: center; cursor: pointer; position: relative; background: var(--paper);
}
.amount-opt.selected { border-color: var(--green); box-shadow: 0 0 0 2px var(--green) inset; }
.amount-opt .kes { font-weight: 700; font-size: 18px; }
.amount-opt .uc { font-size: 13px; color: var(--muted); }
.amount-opt .best { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: var(--coral); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-pill); white-space: nowrap; }
.field { width: 100%; border: 1.5px solid var(--mist); border-radius: var(--radius-input); padding: 13px 14px; font-family: inherit; font-size: 16px; }
.field:focus { outline: none; border-color: var(--indigo); }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; display: block; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lift); font-size: var(--fs-small); font-weight: 500;
  animation: toastIn .25s var(--ease);
}
.toast.success { background: var(--green); }
.toast.error { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px);} to { opacity: 1; transform: none;} }

/* ---------- Credit quick panel ---------- */
.quick-panel {
  position: absolute; z-index: 60; top: calc(100% + 8px); right: 0;
  width: 300px; background: var(--paper); border: 1px solid var(--mist);
  border-radius: var(--radius-tile); box-shadow: var(--shadow-lift); padding: 18px;
}
.spend-row { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; border-bottom: 1px dashed var(--mist); }
.spend-row:last-child { border-bottom: none; }

/* ---------- Low balance banner ---------- */
.low-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: #FBEFD9; border: 1.5px solid #E8C98A; border-radius: var(--radius-card);
  padding: 14px 18px; margin-bottom: 16px;
}
.low-banner .msg { font-weight: 600; }

/* ---------- Shimmer / skeleton ---------- */
.shimmer {
  background: linear-gradient(100deg, var(--cloud) 30%, #f5f1e8 50%, var(--cloud) 70%);
  background-size: 200% 100%; animation: shimmerMove 1.4s infinite linear;
}
@keyframes shimmerMove { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* typing dots */
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2){ animation-delay: .2s; } .typing span:nth-child(3){ animation-delay: .4s; }
@keyframes blink { 0%,60%,100%{ opacity:.3; } 30%{ opacity:1; } }

.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: var(--radius-pill); }
.badge--indigo { background: rgba(91,91,230,.12); color: var(--indigo); }
.badge--coral { background: rgba(247,108,94,.14); color: var(--coral); }
.badge--green { background: rgba(0,168,107,.12); color: var(--green-dark); }

.fade-in { animation: fadeUp .35s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px) scale(.99);} to { opacity: 1; transform: none; } }
