/* ============================================================
   REUSABLE COMPONENTS — components.css
   Glass cards, buttons, badges, progress bars, checkboxes,
   sidebar, modals, and other shared UI elements.
   ============================================================ */

.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.glass-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-card-shine);
  pointer-events: none;
  border-radius: inherit;
}

.glass-card:hover {
  background: var(--bg-glass-hover);
  border-color: var(--glass-border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.glass-card.static:hover {
  transform: none;
}

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

.card-title {
  font-size: var(--font-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.card-title .icon {
  font-size: var(--font-lg);
}

.card-subtitle {
  font-size: var(--font-sm);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-weight: var(--weight-medium);
  font-size: var(--font-sm);
  white-space: nowrap;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.16);
  opacity: 0;
  transform: scale(0.96);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.btn:hover::after {
  opacity: 1;
  transform: scale(1);
}

.btn:active::after {
  animation: ripple 0.45s ease forwards;
}

@keyframes ripple {
  0% { opacity: 0.28; transform: scale(0.9); }
  100% { opacity: 0; transform: scale(1.8); }
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-glow-blue);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 30px var(--accent-blue-glow);
  filter: brightness(1.1);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--glass-border-hover);
  color: var(--text-primary);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: var(--glass-border);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

.btn-sm { padding: var(--space-2) var(--space-4); font-size: var(--font-xs); border-radius: var(--radius-sm); }

.checkbox-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  user-select: none;
}

.checkbox-item:hover { background: rgba(255, 255, 255, 0.03); }

.checkbox-custom {
  position: relative;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.checkbox-custom input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 2;
}

.checkbox-custom .checkmark {
  position: absolute;
  inset: 0;
  border: 2px solid var(--glass-border-hover);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
}

.checkbox-custom .checkmark::after {
  content: '';
  width: 12px;
  height: 12px;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 6L5 9L10 3' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0;
  transform: scale(0.5);
  transition: all var(--transition-fast);
}

.checkbox-custom input:checked + .checkmark {
  background: var(--gradient-primary);
  border-color: var(--accent-blue);
  box-shadow: var(--shadow-glow-blue);
}

.checkbox-custom input:checked + .checkmark::after {
  opacity: 1;
  transform: scale(1);
}

.checkbox-item.completed .task-label {
  color: var(--text-tertiary);
  text-decoration: line-through;
}

.task-label {
  font-size: var(--font-base);
  color: var(--text-primary);
  flex: 1;
}

.task-xp {
  font-size: var(--font-xs);
  color: var(--accent-purple);
  font-weight: var(--weight-medium);
  opacity: 0.7;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
  animation: shimmer 2s ease-in-out infinite;
  background-size: 200% 100%;
}

.progress-bar-container.lg { height: 12px; }
.progress-bar-fill.xp-fill { background: var(--gradient-accent); }

.circular-progress {
  position: relative;
  width: 120px;
  height: 120px;
}

.circular-progress svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.circular-progress .bg-circle {
  fill: none;
  stroke: rgba(255,255,255,0.06);
  stroke-width: 8;
}

.circular-progress .progress-circle {
  fill: none;
  stroke: url(#progressGradient);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 339.292;
  stroke-dashoffset: 339.292;
  transition: stroke-dashoffset 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.circular-progress .progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.circular-progress .progress-percentage {
  font-size: var(--font-2xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1;
}

.circular-progress .progress-label {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--font-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-primary { background: rgba(108, 99, 255, 0.15); color: var(--accent-blue); border: 1px solid rgba(108, 99, 255, 0.2); }
.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--accent-orange); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-level { background: var(--gradient-accent); color: #fff; border: none; padding: var(--space-1) var(--space-4); font-size: var(--font-sm); box-shadow: var(--shadow-glow-purple); }

.streak-fire { display: flex; align-items: center; gap: var(--space-2); }
.streak-fire .fire-icon { font-size: 1.5rem; animation: firePulse 1s ease-in-out infinite; }
.streak-fire .streak-count { font-size: var(--font-xl); font-weight: var(--weight-bold); background: var(--gradient-fire); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.streak-fire .streak-label { font-size: var(--font-xs); color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; }

.stat-value { font-size: var(--font-2xl); font-weight: var(--weight-bold); color: var(--text-primary); line-height: 1; }
.stat-label { font-size: var(--font-xs); color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; margin-top: var(--space-1); }

.input-field {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-base);
}

.input-field:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--accent-blue-glow); }
.input-field::placeholder { color: var(--text-tertiary); }

.textarea-field {
  width: 100%;
  padding: var(--space-4);
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-base);
  resize: vertical;
  min-height: 100px;
  font-family: var(--font-family);
}

.textarea-field:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--accent-blue-glow); }

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: transform var(--transition-base), width var(--transition-base);
  box-shadow: var(--shadow-md);
}

.sidebar-header { padding: var(--space-6); border-bottom: 1px solid var(--divider); }
.sidebar-logo { display: flex; align-items: center; gap: var(--space-3); }
.sidebar-logo .logo-icon { width: 36px; height: 36px; border-radius: var(--radius-md); background: var(--gradient-primary); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.sidebar-logo .logo-text { font-size: var(--font-lg); font-weight: var(--weight-bold); background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.sidebar-nav { flex: 1; padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-1); }
.nav-link { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); color: var(--text-secondary); font-size: var(--font-base); font-weight: var(--weight-medium); transition: all var(--transition-fast); text-decoration: none; }
.nav-link:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.nav-link.active { background: rgba(139, 92, 246, 0.14); color: var(--accent-blue); }
.nav-link .nav-icon { width: 20px; text-align: center; font-size: 1.1rem; flex-shrink: 0; }
.sidebar-footer { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--divider); }
.sidebar-user { display: flex; align-items: center; gap: var(--space-3); }
.sidebar-user .user-avatar { width: 36px; height: 36px; border-radius: var(--radius-full); object-fit: cover; border: 2px solid var(--glass-border); }
.sidebar-user .user-name { font-size: var(--font-sm); font-weight: var(--weight-medium); color: var(--text-primary); }
.sidebar-user .user-email { font-size: var(--font-xs); color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: calc(var(--z-sidebar) - 1); }

.menu-toggle {
  display: none;
  position: fixed;
  top: var(--space-4);
  left: var(--space-4);
  z-index: calc(var(--z-sidebar) + 1);
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--text-primary);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  background: var(--bg-glass);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-weight: var(--weight-semibold);
  font-size: var(--font-sm);
  box-shadow: var(--shadow-sm);
}

.theme-toggle:hover { border-color: var(--glass-border-hover); transform: translateY(-1px); }
.theme-toggle .theme-toggle-icon { font-size: 1rem; }
.theme-toggle .theme-toggle-label { font-size: 0.8rem; }
.theme-toggle-inline { margin-left: auto; }

.achievement-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--bg-glass);
  border: 1px solid var(--glass-border);
  text-align: center;
  transition: all var(--transition-base);
  min-width: 100px;
}

.achievement-badge .badge-icon { font-size: 2rem; line-height: 1; }
.achievement-badge .badge-name { font-size: var(--font-xs); font-weight: var(--weight-medium); color: var(--text-secondary); }
.achievement-badge.earned { border-color: var(--accent-purple); box-shadow: var(--shadow-glow-purple); }
.achievement-badge.earned .badge-name { color: var(--text-primary); }
.achievement-badge.locked { opacity: 0.4; filter: grayscale(0.8); }

.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text { height: 14px; margin-bottom: var(--space-2); }
.skeleton-title { height: 24px; width: 60%; margin-bottom: var(--space-3); }
.skeleton-circle { border-radius: var(--radius-full); }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--space-12); text-align: center; }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: var(--space-4); opacity: 0.3; }
.empty-state .empty-title { font-size: var(--font-lg); font-weight: var(--weight-semibold); margin-bottom: var(--space-2); }
.empty-state .empty-description { font-size: var(--font-sm); color: var(--text-tertiary); max-width: 300px; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.active { display: block; }
  .menu-toggle { display: flex; }
}
