/* ===================================
   COMPONENTS - Reusable UI Elements
   =================================== */

/* ===================================
   BUTTONS
   =================================== */

/* Base Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  line-height: 1;
  border: none;
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary Button - Solid with gradient */
.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(20, 184, 166, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Secondary Button - Outlined */
.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
  box-shadow: none;
}

.btn-secondary:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Accent Button - Coral gradient */
.btn-accent {
  background: var(--gradient-accent);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-accent:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(255, 107, 107, 0.3);
}

/* Ghost Button - Minimal */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  box-shadow: none;
  padding: var(--space-sm) var(--space-md);
}

.btn-ghost:hover {
  background: var(--background);
  color: var(--primary);
}

/* Success Button */
.btn-success {
  background: var(--gradient-success);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Button Sizes */
.btn-sm {
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--text-sm);
}

.btn-lg {
  padding: var(--space-lg) var(--space-2xl);
  font-size: var(--text-lg);
  border-radius: var(--radius-2xl);
}

.btn-full {
  width: 100%;
}

/* Icon Button - Circular */
.btn-icon {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.btn-icon:hover {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-md);
}

/* Auth Button - For login/signup forms */
.auth-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-lg) var(--space-2xl);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  line-height: 1;
  border: none;
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.auth-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(20, 184, 166, 0.3);
}

.auth-button:active {
  transform: translateY(0);
}

.auth-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ===================================
   CARDS
   =================================== */

/* Base Card */
.card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transition: all var(--transition-base);
}

.card-hover:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-2xl);
}

/* Card with Border Accent */
.card-bordered {
  border-left: 4px solid var(--primary);
}

.card-bordered-accent {
  border-left: 4px solid var(--accent);
}

/* Card Header */
.card-header {
  padding: var(--space-xl);
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  margin-bottom: 0;
  color: var(--primary);
}

/* Card Body */
.card-body {
  padding: var(--space-xl);
}

/* Card Footer */
.card-footer {
  padding: var(--space-xl);
  border-top: 1px solid var(--border);
  background: var(--background);
}

/* Stat Card */
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  box-shadow: var(--shadow-lg);
  text-align: center;
  transition: all var(--transition-base);
  border: 2px solid transparent;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-2xl);
  border-color: var(--primary-light);
}

.stat-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-lg);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-4xl);
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-base);
}

.stat-card:nth-child(even) .stat-icon {
  background: var(--gradient-accent);
}

.stat-card:hover .stat-icon {
  transform: scale(1.1) rotate(5deg);
}

.stat-value {
  font-size: var(--text-5xl);
  font-weight: var(--font-black);
  color: var(--primary);
  line-height: 1;
  margin-bottom: var(--space-sm);
}

.stat-card:nth-child(even) .stat-value {
  color: var(--accent);
}

.stat-label {
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===================================
   FORMS & INPUTS
   =================================== */

.form-group {
  margin-bottom: var(--space-xl);
}

.form-label {
  display: block;
  margin: 0;
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.form-input {
  width: 100%;
  padding: var(--space-lg) var(--space-xl);
  font-size: var(--text-base);
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  transition: all var(--transition-base);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.1);
}

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

.form-input:disabled {
  background: var(--background);
  cursor: not-allowed;
  opacity: 0.6;
}

/* Input with Icon */
.input-group {
  position: relative;
}

.input-icon-left {
  padding-left: 3.5rem;
}

.input-group-icon {
  position: absolute;
  left: var(--space-lg);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* Textarea */
textarea.form-input {
  min-height: 120px;
  resize: vertical;
}

/* Form Hint */
.form-hint {
  display: block;
  margin-top: var(--space-sm);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* Form Error */
.form-error {
  display: block;
  margin-top: var(--space-sm);
  font-size: var(--text-sm);
  color: var(--error);
  font-weight: var(--font-medium);
}

.form-input.error {
  border-color: var(--error);
}

.form-input.error:focus {
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

/* Form Success */
.form-success {
  display: block;
  margin-top: var(--space-sm);
  font-size: var(--text-sm);
  color: var(--success);
  font-weight: var(--font-medium);
}

.form-input.success {
  border-color: var(--success);
}

/* Checkbox & Radio */
.form-checkbox,
.form-radio {
  width: 20px;
  height: 20px;
  margin-right: var(--space-sm);
  cursor: pointer;
  accent-color: var(--primary);
}

.form-check-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  font-size: var(--text-base);
  color: var(--text-secondary);
}

/* Toggle Switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-dark);
  transition: var(--transition-base);
  border-radius: var(--radius-full);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: var(--transition-base);
  border-radius: 50%;
}

.toggle input:checked + .toggle-slider {
  background: var(--gradient-primary);
}

.toggle input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

/* ===================================
   BADGES & PILLS
   =================================== */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xs) var(--space-md);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  line-height: 1;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.badge-accent {
  background: var(--accent-light);
  color: var(--accent-dark);
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-error {
  background: #fee2e2;
  color: #991b1b;
}

.badge-lg {
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--text-base);
}

/* ===================================
   PROGRESS BARS
   =================================== */

.progress-container {
  margin-bottom: var(--space-lg);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.progress-label {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.progress-percentage {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--primary);
}

.progress-bar-wrapper {
  position: relative;
  width: 100%;
  height: 16px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width 800ms cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow: 0 0 10px rgba(20, 184, 166, 0.5);
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Thick Progress Bar for Lessons */
.progress-bar-thick {
  height: 20px;
}

.progress-bar-wrapper.thick {
  height: 20px;
}

/* ===================================
   ALERTS & MESSAGES
   =================================== */

.alert {
  padding: var(--space-lg) var(--space-xl);
  border-radius: var(--radius-xl);
  border-left: 4px solid;
  margin-bottom: var(--space-lg);
  font-size: var(--text-base);
  animation: slideIn 0.3s ease;
}

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

.alert-success {
  background: #d1fae5;
  border-color: var(--success);
  color: #065f46;
}

.alert-error {
  background: #fee2e2;
  border-color: var(--error);
  color: #991b1b;
}

.alert-warning {
  background: #fef3c7;
  border-color: var(--warning);
  color: #92400e;
}

.alert-info {
  background: #dbeafe;
  border-color: var(--info);
  color: #1e40af;
}

/* ===================================
   AVATARS
   =================================== */

.avatar {
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 3px solid var(--primary);
  box-shadow: var(--shadow-md);
}

.avatar-sm {
  width: 40px;
  height: 40px;
}

.avatar-md {
  width: 60px;
  height: 60px;
}

.avatar-lg {
  width: 100px;
  height: 100px;
  border-width: 4px;
}

.avatar-xl {
  width: 150px;
  height: 150px;
  border-width: 5px;
}

.avatar-2xl {
  width: 200px;
  height: 200px;
  border-width: 6px;
}

/* ===================================
   DIVIDERS
   =================================== */

.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-2xl) 0;
}

.divider-dashed {
  border-top: 2px dashed var(--border);
}

/* ===================================
   EMPTY STATES
   =================================== */

.empty-state {
  text-align: center;
  padding: var(--space-4xl) var(--space-2xl);
}

.empty-state-icon {
  font-size: 5rem;
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
  opacity: 0.5;
}

.empty-state h3 {
  color: var(--text-primary);
  margin-bottom: var(--space-md);
}

.empty-state p {
  color: var(--text-secondary);
  font-size: var(--text-lg);
  margin-bottom: var(--space-xl);
}

/* ===================================
   LOADING SPINNER
   =================================== */

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.spinner-lg {
  width: 60px;
  height: 60px;
  border-width: 6px;
}

/* ===================================
   DROPDOWN
   =================================== */

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: var(--space-sm);
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  min-width: 200px;
  padding: var(--space-sm);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--transition-base);
}

.dropdown-menu.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: block;
  padding: var(--space-md) var(--space-lg);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  cursor: pointer;
}

.dropdown-item:hover {
  background: var(--background);
  color: var(--primary);
}

/* ===================================
   TABS
   =================================== */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0;
  background: var(--background);
  padding: 0;
}

.tab {
  flex: 1;
  padding: var(--space-lg) var(--space-md);
  background: transparent;
  border: none;
  font-size: var(--text-base);
  font-weight: var(--font-bold);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  border-radius: 0;
  text-align: center;
  white-space: nowrap;
}

.tab:hover {
  color: var(--primary);
  background: rgba(20, 184, 166, 0.05);
}

.tab.active {
  color: var(--primary);
  background: var(--surface);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-primary);
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===================================
   XP BADGE (Navbar)
   =================================== */

.xp-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  background: var(--gradient-accent);
  border-radius: 16px;
  color: white;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  font-size: var(--text-sm);
}

.xp-level {
  font-size: 0.9rem;
}

.xp-divider {
  opacity: 0.8;
  font-size: 0.9rem;
}

.xp-amount {
  font-size: 0.85rem;
}
