/* ==========================================================================
   DARK THEME SHARED CARDS, CHIPS, BADGES, BUTTONS, MODALS & TOASTS
   ========================================================================== */
.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 15px;
  box-shadow: var(--shadow-card);
  min-width: 0;
  transition: border-color 0.2s var(--ease-smooth), background-color 0.2s var(--ease-smooth);
}

.card-compact { padding: 12px 14px; }

.card-clickable {
  cursor: pointer;
  transition: border-color 0.2s var(--ease-smooth), transform 0.16s var(--ease-smooth), box-shadow 0.2s var(--ease-smooth), background-color 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
  .card-clickable:hover {
    border-color: rgba(96, 165, 250, 0.35);
    background-color: var(--surface-elevated);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

.card-clickable:active {
  background-color: var(--surface-elevated);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.section-title {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--text-primary);
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--text-primary);
  word-break: break-word;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0 0;
}

.link-btn {
  font-size: 13px;
  font-weight: 600;
  color: #60A5FA;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background-color 0.18s ease, transform 0.15s ease;
}
.link-btn:hover { background-color: var(--chip-bg); }
.link-btn:active { transform: scale(0.96); }

/* Stack helpers */
.stack-xs { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.stack-md { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.text-xs { font-size: 11.5px; }
.text-sm { font-size: 13px; }
.muted { color: var(--text-muted); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 15px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  transition: all 0.2s var(--ease-smooth);
  text-align: center;
}
.btn:active:not(:disabled) { transform: scale(0.97); }

.btn-full { width: 100%; }

.btn-sm {
  padding: 8px 12px;
  font-size: 12.5px;
  border-radius: 10px;
}

.btn-primary {
  background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
  color: #FFFFFF;
  box-shadow: 0 4px 16px var(--primary-glow);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled {
  background: #1E3A5F;
  color: rgba(255, 255, 255, 0.45);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-soft {
  background-color: var(--chip-bg);
  color: var(--chip-text);
  border: 1px solid var(--chip-border);
}
.btn-soft:hover { background-color: rgba(59, 130, 246, 0.22); }

.btn-outline {
  background-color: var(--surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}
.btn-outline:hover { background-color: var(--surface-elevated); color: var(--text-primary); }

.btn-success { background: linear-gradient(135deg, #22C55E 0%, #16A34A 100%); color: #FFFFFF; }
.btn-success:hover { filter: brightness(1.08); }

.btn-warning { background: linear-gradient(135deg, #F97316 0%, #EA580C 100%); color: #FFFFFF; }
.btn-warning:hover { filter: brightness(1.08); }

.btn-danger { background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%); color: #FFFFFF; }
.btn-danger:hover { filter: brightness(1.08); }

.btn-danger-soft {
  background-color: var(--badge-red-bg);
  color: var(--badge-red-text);
  border: 1px solid var(--badge-red-border);
}

.btn-success-soft {
  background-color: var(--badge-green-bg);
  color: var(--badge-green-text);
  border: 1px solid var(--badge-green-border);
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-row > .btn {
  flex: 1;
  min-width: 0;
}

/* Inputs & Search */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 13px;
  width: 17px;
  height: 17px;
  color: var(--text-muted);
  pointer-events: none;
}

.input, .textarea, .select {
  width: 100%;
  background-color: var(--surface-subtle);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 10px 13px;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s var(--ease-smooth), box-shadow 0.2s var(--ease-smooth), background-color 0.2s ease;
}

.input::placeholder, .textarea::placeholder {
  color: var(--text-muted);
}

.search-box .input {
  padding-left: 38px;
  padding-right: 34px;
}

.search-clear {
  position: absolute;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 16px;
}
.search-clear:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--primary);
  background-color: var(--surface);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.select option {
  background-color: #151C28;
  color: #F1F5F9;
}

.textarea {
  resize: vertical;
  min-height: 84px;
  line-height: 1.45;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.field-error {
  font-size: 12px;
  color: #FCA5A5;
  min-height: 16px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-green {
  background-color: var(--badge-green-bg);
  color: var(--badge-green-text);
  border-color: var(--badge-green-border);
}

.badge-amber {
  background-color: var(--badge-amber-bg);
  color: var(--badge-amber-text);
  border-color: var(--badge-amber-border);
}

.badge-coral {
  background-color: var(--badge-coral-bg);
  color: var(--badge-coral-text);
  border-color: var(--badge-coral-border);
}

.badge-red {
  background-color: var(--badge-red-bg);
  color: var(--badge-red-text);
  border-color: var(--badge-red-border);
}

.badge-sky {
  background-color: var(--badge-sky-bg);
  color: var(--badge-sky-text);
  border-color: var(--badge-sky-border);
}

.badge-gray {
  background-color: rgba(148, 163, 184, 0.12);
  color: var(--text-secondary);
  border-color: var(--border);
}

/* Option Chips */
.chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 600;
  background-color: var(--surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  transition: all 0.18s var(--ease-smooth);
  text-align: center;
  line-height: 1.25;
}
.chip:active { transform: scale(0.95); }

.chip:hover {
  border-color: rgba(96, 165, 250, 0.45);
  background-color: var(--surface-elevated);
}

.chip.active {
  background-color: var(--chip-bg);
  color: var(--chip-text);
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.18);
}

.chip-neutral {
  background-color: var(--surface-subtle);
  color: var(--text-secondary);
  border-color: var(--border);
}

.chip-sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 9px;
}

.chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: rgba(147, 197, 253, 0.18);
  color: var(--chip-text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

/* Stars (fractional fill support) */
.stars-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  flex-shrink: 0;
}

.stars {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.stars-fg {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  overflow: hidden;
  pointer-events: none;
}

.star-svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--star-inactive);
  fill: var(--star-inactive);
  transition: transform 0.15s var(--ease-smooth), fill 0.15s ease;
}

.star-svg.filled {
  color: var(--star-active);
  fill: var(--star-active);
}

.star-btn {
  padding: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.14s var(--ease-smooth);
}
.star-btn:hover .star-svg { transform: scale(1.14); }
.star-btn:active { transform: scale(1.22); }

.star-btn-lg .star-svg {
  width: 30px;
  height: 30px;
}

/* Callout & Empty states */
.callout-box {
  background-color: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.28);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 12.5px;
  color: #BFDBFE;
  line-height: 1.45;
}

.empty-state {
  text-align: center;
  padding: 26px 16px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Modal Sheet */
.modal-overlay {
  position: fixed;
  top: var(--vv-offset-top, 0px);
  left: 0;
  right: 0;
  bottom: auto;
  height: var(--app-viewport-height, 100dvh);
  z-index: 60;
  background: rgba(5, 8, 15, 0.72);
  backdrop-filter: blur(6px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: calc(var(--tg-top-inset, 0px) + 12px) 12px 12px;
}

.modal-overlay.open {
  display: flex;
  animation: fadeOverlay 0.2s ease both;
}

.modal-sheet {
  width: 100%;
  max-width: 420px;
  max-height: calc(var(--app-viewport-height, 100dvh) - var(--tg-top-inset, 0px) - 24px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 13px;
  animation: modalSlideUp 0.26s var(--ease-smooth) both;
}

@keyframes fadeOverlay {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(22px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}
.modal-close:hover { background: #2A364E; color: var(--text-primary); }

/* Toast & Interactive Popup Notifications */
.toast-container {
  position: fixed;
  top: calc(14px + var(--tg-top-inset, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 390px;
  pointer-events: none;
}

.toast {
  background: #1E293B;
  color: #F8FAFC;
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.52);
  animation: toastIn 0.22s var(--ease-smooth);
}

.toast.info {
  background: rgba(24, 34, 54, 0.96);
  border-color: rgba(96, 165, 250, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.toast.toast-clickable {
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.toast-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #93C5FD;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.toast-action-hint {
  font-size: 11px;
  font-weight: 600;
  color: #60A5FA;
}

.toast-body {
  font-size: 13px;
  color: #F1F5F9;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.toast.success { background: #14532D; border-color: rgba(74, 222, 128, 0.35); }
.toast.error { background: #7F1D1D; border-color: rgba(252, 165, 165, 0.35); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Progress bar (Wizard) */
.wizard-progress-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wizard-step-label {
  font-size: 11.5px;
  font-weight: 700;
  color: #60A5FA;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.wizard-progress-bars {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.wizard-bar {
  height: 4px;
  border-radius: 999px;
  background-color: rgba(255, 255, 255, 0.1);
  transition: background-color 0.28s var(--ease-smooth), box-shadow 0.28s ease;
}

.wizard-bar.active {
  background-color: var(--primary);
  box-shadow: 0 0 8px var(--primary-glow);
}
