/**
 * DevCraft Studio - UI Components Library v2
 * Glassmorphism Cards, Buttons, Badges, and Animations
 */

/* ==================== Glassmorphism Cards ==================== */
.glass-card {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
}

[data-theme="dark"] .glass-card {
  background: rgba(31, 20, 61, 0.7);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.glass-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
  border-color: rgba(59, 130, 246, 0.4);
}

/* Glass Card Variants */
.glass-card-subtle {
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(8px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .glass-card-subtle {
  background: rgba(31, 20, 61, 0.5);
  border: 1px solid rgba(59, 130, 246, 0.15);
}

.glass-card-solid {
  background: var(--entry);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.glass-card-elevated {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px) saturate(200%);
  box-shadow: var(--shadow-xl);
}

[data-theme="dark"] .glass-card-elevated {
  background: rgba(31, 20, 61, 0.85);
}

/* ==================== Button System ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  line-height: 1.5;
  text-decoration: none;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn svg {
  width: 20px;
  height: 20px;
  transition: transform 0.2s ease;
}

.btn:hover svg {
  transform: translateX(2px);
}

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

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

.btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

/* Secondary Button */
.btn-secondary {
  background: var(--code-bg);
  color: var(--primary);
  border: 2px solid var(--border);
}

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

/* Ghost Button */
.btn-ghost {
  background: transparent;
  color: var(--secondary);
  border: 2px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(59, 130, 246, 0.05);
}

/* Outline Button */
.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}

.btn-outline:hover {
  background: var(--accent);
  color: white;
}

/* Button Sizes */
.btn-sm {
  padding: 8px 16px;
  font-size: var(--text-sm);
}

.btn-sm svg {
  width: 16px;
  height: 16px;
}

.btn-lg {
  padding: 16px 32px;
  font-size: var(--text-lg);
}

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

/* Button States */
.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ==================== Badges and Tags ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  border-radius: var(--radius-full);
  transition: all 0.2s ease;
}

.badge-primary {
  background: var(--gradient-primary);
  color: white;
}

.badge-secondary {
  background: var(--code-bg);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.badge-success {
  background: rgba(34, 197, 94, 0.1);
  color: #16A34A;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: #D97706;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-info {
  background: rgba(59, 130, 246, 0.1);
  color: #2563EB;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

/* Tag System (for article tags) */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--code-bg);
  color: var(--accent);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.tag:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.tag::before {
  content: '#';
  opacity: 0.6;
}

/* ==================== Animations ==================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* Animation Utility Classes */
.animate-fade-in {
  animation: fadeIn 0.6s ease-out forwards;
}

.animate-fade-in-scale {
  animation: fadeInScale 0.5s ease-out forwards;
}

.animate-slide-up {
  animation: slideInUp 0.6s ease-out forwards;
}

.animate-slide-right {
  animation: slideInRight 0.6s ease-out forwards;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* Staggered Animation Delays */
.animate-delay-100 { animation-delay: 0.1s; }
.animate-delay-200 { animation-delay: 0.2s; }
.animate-delay-300 { animation-delay: 0.3s; }
.animate-delay-400 { animation-delay: 0.4s; }
.animate-delay-500 { animation-delay: 0.5s; }

/* ==================== Loading States ==================== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--code-bg) 0%,
    var(--border) 50%,
    var(--code-bg) 100%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 1em;
  margin: 8px 0;
}

.skeleton-title {
  height: 2em;
  width: 60%;
  margin: 16px 0;
}

.skeleton-button {
  height: 44px;
  width: 120px;
  border-radius: var(--radius-md);
}

.skeleton-card {
  height: 200px;
  border-radius: var(--radius-lg);
}

/* ==================== Dividers ==================== */
.divider {
  height: 1px;
  background: var(--border);
  margin: calc(var(--gap) * 2) 0;
}

.divider-gradient {
  height: 2px;
  background: var(--gradient-primary);
  margin: calc(var(--gap) * 2) 0;
  opacity: 0.3;
}

.divider-text {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: calc(var(--gap) * 2) 0;
  color: var(--tertiary);
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ==================== Tooltips ==================== */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 6px 12px;
  background: var(--primary);
  color: var(--theme);
  font-size: var(--text-xs);
  white-space: nowrap;
  border-radius: var(--radius-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1000;
}

[data-tooltip]::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--primary);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
  opacity: 1;
}

[data-tooltip]:hover::before {
  transform: translateX(-50%) translateY(-4px);
}

/* ==================== Alert Boxes ==================== */
.alert {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  border-left: 4px solid;
  margin: var(--gap) 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.alert-info {
  background: rgba(59, 130, 246, 0.1);
  border-color: #2563EB;
  color: var(--content);
}

.alert-success {
  background: rgba(34, 197, 94, 0.1);
  border-color: #16A34A;
  color: var(--content);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: #D97706;
  color: var(--content);
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border-color: #DC2626;
  color: var(--content);
}

.alert-title {
  font-weight: var(--font-semibold);
  margin-bottom: 4px;
}

/* ==================== Progress Indicators ==================== */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--code-bg);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

/* ==================== Responsive Utilities ==================== */
@media (max-width: 768px) {
  .btn {
    padding: 10px 20px;
    font-size: var(--text-sm);
  }

  .btn-lg {
    padding: 12px 24px;
    font-size: var(--text-base);
  }

  .btn-sm {
    padding: 6px 14px;
    font-size: var(--text-xs);
  }

  .btn svg {
    width: 18px;
    height: 18px;
  }

  .glass-card {
    border-radius: var(--radius);
    padding: var(--gap);
  }

  .glass-card-elevated {
    padding: calc(var(--gap) * 1.2);
  }

  .badge,
  .tag {
    font-size: var(--text-xs);
    padding: 4px 10px;
  }
}

@media (max-width: 480px) {
  .btn {
    padding: 10px 16px;
  }

  .glass-card {
    padding: 16px;
  }
}

/* ==================== Print Styles ==================== */
@media print {
  .glass-card {
    background: white;
    backdrop-filter: none;
    border: 1px solid #e5e7eb;
  }

  .btn {
    color: #000;
    border: 1px solid #000;
  }
}

/* ==================== Accessibility ==================== */
.btn:focus-visible,
.tag:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

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

  .btn:hover {
    transform: none;
  }

  .tag:hover {
    transform: none;
  }
}
