/* ============================================
   MyFinWell - Component Library
   Reusable UI Components
   ============================================ */

/* ===== Stepper ===== */
.stepper {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-8);
  position: relative;
  padding: 0 var(--space-4);
}

.stepper::before {
  content: '';
  position: absolute;
  top: 20px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border);
  z-index: 0;
}

.stepper-step {
  flex: 1;
  position: relative;
  z-index: 1;
  text-align: center;
}

.step-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-2);
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition);
}

.stepper-step.active .step-number {
  background: var(--secondary);
  border-color: var(--secondary);
  color: white;
}

.stepper-step.completed .step-number {
  background: var(--secondary);
  border-color: var(--secondary);
  color: white;
}

.stepper-step.completed .step-number::before {
  content: '✓';
  font-size: var(--font-size-lg);
}

.step-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.stepper-step.active .step-label {
  color: var(--secondary);
  font-weight: 600;
}

/* ===== Timeline ===== */
.timeline {
  position: relative;
  padding-left: var(--space-8);
}

.timeline::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: var(--space-8);
  padding-left: var(--space-6);
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--card);
  border: 3px solid var(--secondary);
  box-shadow: 0 0 0 2px var(--card);
}

.timeline-item.completed::before {
  background: var(--secondary);
}

.timeline-item.active::before {
  background: var(--accent);
  border-color: var(--accent);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.8; }
}

.timeline-date {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

.timeline-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.timeline-description {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

/* ===== KPI Cards ===== */
.kpi-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-material);
  border-left: 4px solid var(--secondary);
  transition: var(--transition);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.kpi-value {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.kpi-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-2);
}

.kpi-change {
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.kpi-change.positive {
  color: var(--secondary);
}

.kpi-change.negative {
  color: var(--danger);
}

/* ===== Status Indicators ===== */
.status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.active {
  background: var(--secondary);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2);
}

.status-dot.pending {
  background: var(--warning);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.status-dot.inactive {
  background: var(--text-light);
}

.status-dot.error {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* ===== Alerts ===== */
.alert {
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: start;
  gap: var(--space-3);
  border-left: 4px solid;
}

.alert-success {
  background: #D1FAE5;
  border-color: var(--secondary);
  color: #065F46;
}

.alert-warning {
  background: #FEF3C7;
  border-color: var(--warning);
  color: #92400E;
}

.alert-danger {
  background: #FEE2E2;
  border-color: var(--danger);
  color: #991B1B;
}

.alert-info {
  background: #DBEAFE;
  border-color: var(--accent);
  color: #1E40AF;
}

/* ===== Score Meter ===== */
.score-meter {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto;
}

.score-circle {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: conic-gradient(
    var(--secondary) 0deg 216deg,
    var(--warning) 216deg 288deg,
    var(--danger) 288deg 360deg
  );
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.score-circle::before {
  content: '';
  position: absolute;
  width: 80%;
  height: 80%;
  background: var(--card);
  border-radius: 50%;
}

.score-value {
  position: relative;
  z-index: 1;
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--text-primary);
}

.score-label {
  position: relative;
  z-index: 1;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

/* ===== Slider UI ===== */
.slider-container {
  margin: var(--space-6) 0;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  font-weight: 500;
}

.slider-track {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-full);
  position: relative;
  cursor: pointer;
}

.slider-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--secondary), var(--accent));
  border-radius: var(--radius-full);
  position: relative;
}

.slider-thumb {
  width: 20px;
  height: 20px;
  background: var(--card);
  border: 3px solid var(--secondary);
  border-radius: 50%;
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  box-shadow: var(--shadow-md);
  cursor: grab;
}

.slider-thumb:active {
  cursor: grabbing;
}

/* ===== Chat UI ===== */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 600px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-material);
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  padding: var(--space-6);
  overflow-y: auto;
  background: var(--background);
}

.message {
  margin-bottom: var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  flex-shrink: 0;
}

.message.user .message-avatar {
  background: var(--accent);
}

.message:not(.user) .message-avatar {
  background: var(--secondary);
}

.message-bubble {
  max-width: 70%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.message.user .message-bubble {
  background: var(--secondary);
  color: white;
}

.message-time {
  font-size: var(--font-size-xs);
  color: var(--text-light);
  margin-top: var(--space-1);
}

.chat-input-area {
  padding: var(--space-4);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--space-2);
}

.chip {
  display: inline-block;
  padding: var(--space-2) var(--space-4);
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  margin: var(--space-1);
  cursor: pointer;
  transition: var(--transition);
}

.chip:hover {
  background: var(--secondary);
  color: white;
  border-color: var(--secondary);
}

.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-4);
}

/* ===== Drop Zone ===== */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-12);
  text-align: center;
  background: var(--background);
  transition: var(--transition);
  cursor: pointer;
}

.drop-zone:hover {
  border-color: var(--secondary);
  background: rgba(22, 163, 74, 0.05);
}

.drop-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  color: var(--text-secondary);
}

/* ===== Accordion ===== */
.accordion {
  margin-bottom: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4);
  background: var(--card);
  cursor: pointer;
  transition: var(--transition);
}

.accordion-header:hover {
  background: var(--background);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  padding: 0 var(--space-4);
  background: var(--background);
}

.accordion-toggle:checked ~ .accordion-content {
  max-height: 1000px;
  padding: var(--space-4);
}

.accordion-toggle {
  display: none;
}

.accordion-icon {
  transition: transform 0.3s ease;
}

.accordion-toggle:checked ~ .accordion-header .accordion-icon {
  transform: rotate(180deg);
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: var(--space-12);
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: var(--space-4);
  color: var(--text-light);
}

.empty-state-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--text-primary);
}

.empty-state-description {
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-6);
}

/* ===== Loading Placeholder ===== */
.loading {
  background: linear-gradient(90deg, var(--border) 25%, var(--background) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.loading-text {
  height: 20px;
  width: 60%;
  margin-bottom: var(--space-2);
}

.loading-card {
  height: 200px;
}

/* ===== Progress Ring ===== */
.progress-ring {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto;
}

.progress-ring svg {
  transform: rotate(-90deg);
}

.progress-ring-circle {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
}

.progress-ring-bg {
  stroke: var(--border);
}

.progress-ring-fill {
  stroke: var(--secondary);
  stroke-dasharray: 283;
  transition: stroke-dashoffset 0.5s ease;
}

.progress-ring-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
}

/* ===== Achievement Badge ===== */
.achievement-badge {
  text-align: center;
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--background);
  transition: var(--transition);
}

.achievement-badge.earned {
  background: linear-gradient(135deg, var(--secondary), var(--accent));
  color: white;
}

.achievement-badge-icon {
  font-size: 3rem;
  margin-bottom: var(--space-2);
}

.achievement-badge-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.achievement-badge-description {
  font-size: var(--font-size-xs);
  opacity: 0.8;
}

/* ===== Task Checklist ===== */
.task-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--card);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  transition: var(--transition);
}

.task-item:hover {
  background: var(--background);
}

.task-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.task-item.completed .task-checkbox {
  background: var(--secondary);
  border-color: var(--secondary);
  color: white;
}

.task-item.completed .task-checkbox::before {
  content: '✓';
  font-size: var(--font-size-sm);
}

.task-item.completed .task-title {
  text-decoration: line-through;
  color: var(--text-light);
}

.task-title {
  flex: 1;
  font-weight: 500;
  color: var(--text-primary);
}

.task-reward {
  font-size: var(--font-size-sm);
  color: var(--secondary);
  font-weight: 600;
}
