/**
 * Free Tier widget — Overview tab (public/views/dashboard.php).
 * Reuses the shared .aiapi-card-block / .aiapi-ov-block shell, but is
 * intentionally kept plain/white (no green/amber/rose accent tint on
 * the card, and no tinted header) per the user's explicit request —
 * state is communicated only via the badge and the meter fill color.
 * Only the bits genuinely new to this card — the header icon/
 * subtitle, the meter, the mini stat pair, the "View free models"
 * footer link and the exhausted-state CTA — need their own rules
 * here. The full free-model list itself is intentionally not
 * rendered in this widget; the footer link sends the user to the
 * Models tab, which already lists them.
 */

.aiapi-ft-widget-body {
	display: flex;
	flex-direction: column;
	gap: 16px;
	padding: 4px 18px 18px;
}

.aiapi-ft-widget {
	margin-bottom: 16px;
}

/* ---------------------------------------------------------- head -- */

.aiapi-ft-widget-head { align-items: center; }

/* Plain white card by design (no green/amber/rose tint on the card
   background or border, and no header background at all) — overrides
   both the shared accent-card look (panel.css) and the Overview tab's
   own soft-gradient header (dashboard.css) specifically for this
   widget, per the user's explicit request. State is still communicated
   via the badge and the meter fill color only. */
.aiapi-overview-panel .aiapi-ft-widget-head {
	background: none;
}

.aiapi-ft-head-main {
	display: flex;
	align-items: center;
	gap: 11px;
	min-width: 0;
}

.aiapi-ft-head-icon {
	background: var(--aiapi-primary-soft);
    color: var(--aiapi-primary);
}

.aiapi-ft-widget-head .aiapi-card-block-title { margin: 0; }
.aiapi-ft-widget-head .aiapi-card-block-subtitle { white-space: normal; }

/* -------------------------------------------------- token meter -- */

.aiapi-ft-meter-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 10px;
	font-size: 12.5px;
	color: var(--aiapi-muted-foreground);
	margin-bottom: 9px;
}

.aiapi-ft-meter-head strong {
	font-size: 13.5px;
	color: var(--aiapi-foreground);
	font-weight: 700;
}

/* Numbers always read left-to-right ("0 / 10,000,000") while the word next
 * to them ("tokens" / "توکن") follows the page direction. */
.aiapi-ft-num {
	direction: ltr;
	unicode-bidi: isolate;
	white-space: nowrap;
}

.aiapi-ft-meter-track {
	width: 100%;
	height: 13px;
	border-radius: 999px;
	background: var(--aiapi-muted);
	box-shadow: inset 0 1px 2px rgba(0, 0, 0, .07);
	overflow: hidden;
	position: relative;
}

.aiapi-ft-meter-fill {
	height: 100%;
	width: 0;
	min-width: 13px;
	border-radius: 999px;
	background: linear-gradient(90deg, var(--aiapi-primary), color-mix(in oklch, var(--aiapi-primary) 70%, white));
	box-shadow: 0 0 0 1px color-mix(in oklch, var(--aiapi-primary) 35%, transparent);
	transition: width .7s cubic-bezier(.4, 0, .2, 1);
	position: relative;
	overflow: hidden;
}

/* Soft diagonal sheen across the fill — the bit that reads as
   "premium" rather than a flat color block. Purely decorative, so it
   is excluded from prefers-reduced-motion users below along with the
   pulse. */
.aiapi-ft-meter-fill::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(180deg, rgba(255, 255, 255, .35), rgba(255, 255, 255, 0) 55%);
	pointer-events: none;
}

/* Bright leading edge "cap" — a small glowing dot at the current
   progress position, like a live gauge rather than a static bar. */
.aiapi-ft-meter-fill::before {
	content: "";
	position: absolute;
	inset-block: 0;
	inset-inline-end: 0;
	width: 6px;
	border-radius: 999px;
	background: #fff;
	opacity: .85;
	box-shadow: 0 0 6px 1px color-mix(in oklch, var(--aiapi-primary) 60%, white);
}

.aiapi-ft-widget--warning .aiapi-ft-meter-fill { background: linear-gradient(90deg, var(--aiapi-warning), color-mix(in oklch, var(--aiapi-warning) 70%, white)); box-shadow: 0 0 0 1px color-mix(in oklch, var(--aiapi-warning) 35%, transparent); }
.aiapi-ft-widget--warning .aiapi-ft-meter-fill::before { box-shadow: 0 0 6px 1px color-mix(in oklch, var(--aiapi-warning) 60%, white); }
.aiapi-ft-widget--exhausted .aiapi-ft-meter-fill { background: linear-gradient(90deg, var(--aiapi-danger), color-mix(in oklch, var(--aiapi-danger) 70%, white)); box-shadow: 0 0 0 1px color-mix(in oklch, var(--aiapi-danger) 35%, transparent); }
.aiapi-ft-widget--exhausted .aiapi-ft-meter-fill::before { box-shadow: 0 0 6px 1px color-mix(in oklch, var(--aiapi-danger) 60%, white); }

@media (prefers-reduced-motion: reduce) {
	.aiapi-ft-meter-fill { transition: none; }
	.aiapi-ft-meter-fill::after,
	.aiapi-ft-meter-fill::before { display: none; }
}

.aiapi-ft-meter-foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-top: 7px;
	font-size: 11.5px;
	color: var(--aiapi-muted-foreground);
}

/* ------------------------------------------------------ mini grid -- */

.aiapi-ft-mini-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 10px;
}

.aiapi-ft-mini-card {
	display: flex;
	align-items: center;
	justify-content: center; /* icon + text sit in the middle of the card, no empty gap on one side */
	gap: 10px;
	padding: 10px 12px;
	border-radius: var(--aiapi-radius-sm);
	background: var(--aiapi-muted);
	border: 1px solid var(--aiapi-card-border);
}

.aiapi-ft-mini-card > div { text-align: center; }

.aiapi-ft-mini-icon {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 8px;
	flex-shrink: 0;
	background: var(--aiapi-accent-blue-bg);
	color: var(--aiapi-accent-blue);
}

.aiapi-ft-mini-card strong {
	display: block;
	font-size: 13px;
	font-weight: 700;
	color: var(--aiapi-foreground);
}

.aiapi-ft-mini-card strong:not(.aiapi-ft-rate) {
	direction: ltr;
	unicode-bidi: isolate;
}

.aiapi-ft-mini-card span {
	display: block;
	font-size: 11px;
	color: var(--aiapi-muted-foreground);
	margin-top: 1px;
}

/* --------------------------------------------------------- footer -- */

.aiapi-ft-footer {
	display: flex;
	justify-content: flex-end;
	padding-top: 13px;
	margin-top: 2px;
}

.aiapi-ft-models-link {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font-size: 12.5px;
	font-weight: 600;
	color: var(--aiapi-primary);
	text-decoration: none;
	transition: gap .15s ease, opacity .15s ease;
}

.aiapi-ft-models-link:hover {
	gap: 8px;
	opacity: .85;
}

.aiapi-ft-models-link svg {
	flex-shrink: 0;
	transition: transform .15s ease;
}

[dir="rtl"] .aiapi-ft-models-link svg {
	transform: scaleX(-1);
}

/* ----------------------------------------------------------- cta -- */

.aiapi-ft-cta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 10px;
	padding: 11px 14px;
	border-radius: var(--aiapi-radius-sm);
	background: var(--aiapi-danger-bg);
	border: 1px solid var(--aiapi-danger-border);
}

.aiapi-ft-cta > span {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 12.5px;
	color: var(--aiapi-danger);
	font-weight: 600;
}

.aiapi-ft-cta-actions {
	display: flex;
	gap: 8px;
	flex-shrink: 0;
}

@media (max-width: 640px) {
	.aiapi-ft-mini-grid { grid-template-columns: 1fr; }
	.aiapi-ft-cta { flex-direction: column; align-items: stretch; }
	.aiapi-ft-cta-actions { justify-content: flex-end; }
}
