/* DailyQuest — Base Utilities & Layout */

/* ── Utility: display ─────────────────────────────────────────────── */
.flex      { display: flex; }
.flex-col  { display: flex; flex-direction: column; }
.grid      { display: grid; }
.hidden    { display: none !important; }
.block     { display: block; }
.inline    { display: inline; }
.inline-flex { display: inline-flex; }

/* ── Utility: alignment ───────────────────────────────────────────── */
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.items-end     { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.gap-1  { gap: var(--space-1); }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-6  { gap: var(--space-6); }
.gap-8  { gap: var(--space-8); }
.flex-wrap   { flex-wrap: wrap; }
.flex-1      { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

/* ── Utility: spacing ─────────────────────────────────────────────── */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.p-4  { padding: var(--space-4); }
.p-6  { padding: var(--space-6); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }

/* ── Utility: text ────────────────────────────────────────────────── */
.text-xs    { font-size: var(--text-xs); }
.text-sm    { font-size: var(--text-sm); }
.text-base  { font-size: var(--text-base); }
.text-md    { font-size: var(--text-md); }
.text-lg    { font-size: var(--text-lg); }
.text-xl    { font-size: var(--text-xl); }
.text-2xl   { font-size: var(--text-2xl); }
.text-3xl   { font-size: var(--text-3xl); }
.font-500   { font-weight: 500; }
.font-600   { font-weight: 600; }
.font-700   { font-weight: 700; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--color-text-muted); }
.text-primary { color: var(--color-primary); }
.text-success { color: var(--color-success); }
.text-danger  { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.text-coin    { color: #B07A00; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uppercase    { text-transform: uppercase; letter-spacing: 0.05em; }
.label        { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); }

/* ── Utility: colours ─────────────────────────────────────────────── */
.bg-primary      { background: var(--color-primary); color: var(--color-text-on-primary); }
.bg-surface      { background: var(--color-surface); }
.bg-surface-alt  { background: var(--color-surface-alt); }
.bg-primary-light { background: var(--color-primary-light); }
.bg-accent-light  { background: var(--color-accent-light); }
.bg-coin          { background: var(--color-coin-bg); }

/* ── Utility: border + radius ─────────────────────────────────────── */
.rounded-sm   { border-radius: var(--radius-sm); }
.rounded-md   { border-radius: var(--radius-md); }
.rounded-lg   { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }
.border       { border: 1px solid var(--color-border); }

/* ── Utility: shadows ─────────────────────────────────────────────── */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }

/* ── Utility: width/overflow ──────────────────────────────────────── */
.w-full       { width: 100%; }
.max-w-sm     { max-width: 400px; }
.max-w-md     { max-width: 580px; }
.max-w-lg     { max-width: 760px; }
.overflow-hidden { overflow: hidden; }
.relative     { position: relative; }
.absolute     { position: absolute; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 12px 20px;
  border-radius: var(--radius-full);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1;
  transition: all var(--transition-fast);
  white-space: nowrap;
  cursor: pointer;
  border: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(108,60,225,.3);
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-dark); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-accent  { background: var(--color-accent); color: #fff; }
.btn-accent:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}
.btn-outline:hover:not(:disabled) { background: var(--color-primary-light); }
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
}
.btn-ghost:hover:not(:disabled) { background: var(--color-surface-alt); color: var(--color-text); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }
.btn-sm { padding: 8px 14px; font-size: var(--text-sm); }
.btn-lg { padding: 16px 28px; font-size: var(--text-md); }
.btn-full { width: 100%; }
.btn-loading { position: relative; color: transparent !important; }
.btn-loading::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Form Elements ────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--space-2); }
.form-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}
/* Text-like controls: classed + native (bare inputs in templates) */
.form-input,
input:where(:not([type]), [type="text"], [type="email"], [type="password"], [type="number"], [type="tel"], [type="url"], [type="search"], [type="date"], [type="time"], [type="datetime-local"]),
textarea,
select {
  width: 100%;
  max-width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
select,
.form-input.form-select,
.form-select {
  appearance: none;
  background-color: var(--color-surface);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236B6388' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
  padding-right: 36px;
}
.form-input:focus,
input:where(:not([type]), [type="text"], [type="email"], [type="password"], [type="number"], [type="tel"], [type="url"], [type="search"], [type="date"], [type="time"], [type="datetime-local"]):focus,
textarea:focus,
select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(108,60,225,.15);
  outline: none;
}
.form-input::placeholder,
input::placeholder,
textarea::placeholder { color: var(--color-text-muted); }
.form-input.is-error,
input.is-error,
textarea.is-error,
select.is-error { border-color: var(--color-danger); }
.form-input.is-success,
input.is-success,
textarea.is-success,
select.is-success { border-color: var(--color-success); }
.form-error { font-size: var(--text-sm); color: var(--color-danger); }
.form-hint  { font-size: var(--text-sm); color: var(--color-text-muted); }
.form-textarea {
  resize: vertical;
  min-height: 80px;
}
textarea:not([rows]) { min-height: 80px; resize: vertical; }
input[type="color"] {
  min-height: 44px;
  padding: 4px 8px;
  cursor: pointer;
}
input[type="checkbox"],
input[type="radio"] {
  width: 1.15em;
  height: 1.15em;
  accent-color: var(--color-primary);
  cursor: pointer;
  vertical-align: middle;
}
.input-icon-wrap { position: relative; }
.input-icon-wrap .form-input { padding-left: 42px; }
.input-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); pointer-events: none; }

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
.card-body { padding: var(--space-5); }
.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  font-size: var(--text-md);
}

/* ── Chips/Pills ──────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  background: var(--color-primary-light);
  color: var(--color-primary);
}
.chip-coin     { background: var(--color-coin-bg); color: #8B6800; }
.chip-minutes  { background: var(--color-minutes-bg); color: #0369A1; }
.chip-success  { background: #DCFCE7; color: #15803D; }
.chip-warning  { background: #FEF9C3; color: #A16207; }
.chip-danger   { background: #FEE2E2; color: #B91C1C; }
.chip-muted    { background: var(--color-surface-alt); color: var(--color-text-muted); }

/* ── Divider ──────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-4) 0;
}
.divider-text {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.divider-text::before, .divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* ── Tabs ─────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  background: var(--color-surface-alt);
  border-radius: var(--radius-full);
  padding: 3px;
}
.tab-item {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--color-text-muted);
  background: transparent;
  border: none;
}
.tab-item.active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}
.tab-item .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  margin-left: 4px;
}

/* ── Section heading ──────────────────────────────────────────────── */
.section-title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

/* ── Empty state ──────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
  color: var(--color-text-muted);
  gap: var(--space-3);
}
.empty-state-icon { font-size: 48px; }
.empty-state h3   { font-size: var(--text-lg); color: var(--color-text); }

/* ── FAB ──────────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height, 80px) + 16px);
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-base);
  z-index: var(--z-sticky);
  border: none;
  cursor: pointer;
  font-size: 24px;
}
.fab:hover { transform: scale(1.05); background: var(--color-primary-dark); }
.fab:active { transform: scale(0.97); }

/* ── Skeleton loader ──────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--color-border) 25%, var(--color-surface-alt) 50%, var(--color-border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ── Balance delta animation ──────────────────────────────────────── */
@keyframes floatUp {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-40px); }
}
.balance-delta {
  position: fixed;
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--color-success);
  pointer-events: none;
  animation: floatUp .8s ease-out forwards;
  z-index: var(--z-toast);
}

/* ── Alert banner ─────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
}
.alert-warning { background: #FEF9C3; color: #92400E; border-left: 3px solid var(--color-warning); }
.alert-danger  { background: #FEE2E2; color: #991B1B; border-left: 3px solid var(--color-danger); }
.alert-success { background: #DCFCE7; color: #14532D; border-left: 3px solid var(--color-success); }
.alert-info    { background: #EFF6FF; color: #1E40AF; border-left: 3px solid var(--color-info); }
.alert-accent  { background: var(--color-accent-light); color: #9A3412; border-left: 3px solid var(--color-accent); }

/* ── Pulse animation ──────────────────────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}
.pulse { animation: pulse 2s ease-in-out infinite; }

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}
.bounce { animation: bounce 1s ease infinite; }
