/* =====================================================
   Django Blog Plus Unified Components
   Consistent component library for the entire website
   ===================================================== */

/* =====================================================
   LEGACY CLASS ALIASES
   Maps old button classes to new unified system
   ===================================================== */

/* Legacy CTA classes - inherit from new button system */
.cta-primary,
.cta-secondary,
.tps-btn,
.button.w-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--btn-height-md);
  padding: 0 var(--space-6);
  font-family: var(--font-family-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  border: var(--border-width-medium) solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition-all);
  position: relative;
  overflow: hidden;
}

.cta-primary,
.tps-btn-main,
.button.w-button {
  background: var(--gradient-primary);
  color: white !important;
  border-color: transparent;
  box-shadow: var(--shadow-primary-sm);
}

.cta-primary:hover,
.tps-btn-main:hover,
.button.w-button:hover {
  background: var(--gradient-primary-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-primary-md);
  color: white !important;
}

.cta-primary:active,
.tps-btn-main:active,
.button.w-button:active {
  transform: translateY(0) scale(0.98);
  box-shadow: var(--shadow-primary-sm);
}

.cta-secondary,
.tps-btn-outline {
  background: white;
  color: var(--color-primary-500) !important;
  border-color: var(--color-primary-500);
}

.cta-secondary:hover,
.tps-btn-outline:hover {
  background: var(--color-primary-50);
  color: var(--color-primary-600) !important;
  border-color: var(--color-primary-600);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.cta-secondary:active,
.tps-btn-outline:active {
  transform: translateY(0);
}

/* Legacy tps-btn-danger */
.tps-btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--btn-height-md);
  padding: 0 var(--space-6);
  font-family: var(--font-family-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition-all);
  background: var(--color-error-500);
  color: white !important;
  border: var(--border-width-medium) solid transparent;
}

.tps-btn-danger:hover {
  background: var(--color-error-600);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(239, 68, 68, 0.3);
}

/* =====================================================
   1. BUTTON SYSTEM
   ===================================================== */

/* Base button styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--btn-height-md);
  padding: 0 var(--space-6);
  font-family: var(--font-family-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  border: var(--border-width-medium) solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition-all);
  position: relative;
  overflow: hidden;
}

.btn:focus {
  outline: none;
  box-shadow: var(--shadow-focus);
}

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

/* Button Sizes */
.btn-sm {
  height: var(--btn-height-sm);
  padding: 0 var(--space-4);
  font-size: var(--font-size-sm);
  border-radius: var(--radius-md);
}

.btn-lg {
  height: var(--btn-height-lg);
  padding: 0 var(--space-8);
  font-size: var(--font-size-lg);
}

.btn-xl {
  height: var(--btn-height-xl);
  padding: 0 var(--space-10);
  font-size: var(--font-size-lg);
}

/* Primary Button - Gradient */
.btn-primary {
  background: var(--gradient-primary);
  color: white !important;
  border-color: transparent;
  box-shadow: var(--shadow-primary-sm);
}

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

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

/* Shimmer effect on primary button */
.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.btn-primary:hover::before {
  left: 100%;
}

/* Secondary Button - Outline */
.btn-secondary {
  background: white;
  color: var(--color-primary-500);
  border-color: var(--color-primary-500);
}

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

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

/* Ghost Button - Text only with border */
.btn-ghost {
  background: transparent;
  color: var(--color-primary-500);
  border: var(--border-width-thin) solid var(--border-color-light);
}

.btn-ghost:hover {
  background: var(--color-primary-50);
  color: var(--color-primary-600);
  border-color: var(--border-color-default);
}

/* Danger Button */
.btn-danger {
  background: var(--color-error-500);
  color: white !important;
  border-color: transparent;
}

.btn-danger:hover {
  background: var(--color-error-600);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(239, 68, 68, 0.3);
}

.btn-danger:focus {
  box-shadow: var(--shadow-focus-error);
}

/* Success Button */
.btn-success {
  background: var(--color-success-500);
  color: white !important;
  border-color: transparent;
}

.btn-success:hover {
  background: var(--color-success-600);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.3);
}

.btn-success:focus {
  box-shadow: var(--shadow-focus-success);
}

/* Full width button */
.btn-block {
  width: 100%;
}

/* Icon-only button */
.btn-icon {
  padding: 0;
  width: var(--btn-height-md);
}

.btn-icon.btn-sm {
  width: var(--btn-height-sm);
}

.btn-icon.btn-lg {
  width: var(--btn-height-lg);
}

/* Button with icon */
.btn i,
.btn svg {
  font-size: 1em;
  flex-shrink: 0;
}

/* =====================================================
   2. CARD SYSTEM
   ===================================================== */

/* Base card */
.card {
  background: var(--bg-primary);
  border: var(--border-width-thin) solid var(--border-color-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-shadow), var(--transition-transform);
}

/* Card with elevation */
.card-elevated {
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}

/* Interactive card (hovers) */
.card-interactive {
  cursor: pointer;
}

.card-interactive:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
  border-color: var(--color-primary-200);
}

/* Featured card */
.card-featured {
  border-color: var(--color-primary-500);
  background: linear-gradient(135deg, var(--color-primary-50) 0%, var(--bg-primary) 100%);
  position: relative;
}

.card-featured::before {
  content: attr(data-badge);
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gradient-primary);
  color: white;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
}

/* Card sections */
.card-header {
  padding: var(--space-6);
  border-bottom: var(--border-width-thin) solid var(--border-color-light);
}

.card-header h2,
.card-header h3 {
  margin: 0 0 0.25rem 0;
  font-size: 1.125rem;
  font-weight: var(--font-weight-semibold);
  color: var(--color-gray-800);
  font-family: var(--font-family-primary);
}

.card-header p {
  margin: 0;
  color: var(--color-gray-500);
  font-size: 0.875rem;
  font-family: var(--font-family-primary);
}

.card-body {
  padding: var(--space-6);
}

.card-footer {
  padding: var(--space-6);
  border-top: var(--border-width-thin) solid var(--border-color-light);
  background: var(--bg-secondary);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Card padding variants */
.card-compact .card-header,
.card-compact .card-body,
.card-compact .card-footer {
  padding: var(--space-4);
}

.card-spacious .card-header,
.card-spacious .card-body,
.card-spacious .card-footer {
  padding: var(--space-8);
}

/* =====================================================
   3. FORM COMPONENTS
   ===================================================== */

/* Form group */
.form-group {
  margin-bottom: var(--space-5);
}

/* Form label */
.form-label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-gray-700);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
}

.form-label-optional {
  font-weight: var(--font-weight-normal);
  color: var(--color-gray-400);
  text-transform: none;
  margin-left: var(--space-1);
}

/* Base input styles */
.form-input,
.form-select,
.form-textarea {
  display: block;
  width: 100%;
  height: var(--input-height-md);
  padding: 0 var(--space-4);
  font-family: var(--font-family-primary);
  font-size: var(--font-size-base);
  color: var(--color-gray-900);
  background: var(--bg-primary);
  border: var(--border-width-medium) solid var(--border-color-light);
  border-radius: var(--radius-md);
  transition: var(--transition-colors), var(--transition-shadow);
  box-sizing: border-box;
}

.form-textarea {
  height: auto;
  min-height: 120px;
  padding: var(--space-3) var(--space-4);
  resize: vertical;
}

/* Input states */
.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--border-color-default);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary-500);
  box-shadow: var(--shadow-focus);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-gray-400);
}

/* Input sizes */
.form-input-sm {
  height: var(--input-height-sm);
  font-size: var(--font-size-sm);
  padding: 0 var(--space-3);
}

.form-input-lg {
  height: var(--input-height-lg);
  font-size: var(--font-size-lg);
  padding: 0 var(--space-5);
}

.form-input-xl {
  height: var(--input-height-xl);
  font-size: var(--font-size-lg);
  padding: var(--space-5) var(--space-6);
  border-radius: var(--radius-lg);
}

/* Select dropdown */
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  padding-right: var(--space-12);
  cursor: pointer;
}

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

.input-group .form-input {
  padding-left: var(--space-12);
}

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

/* Input validation states */
.form-input-error,
.form-input.is-invalid {
  border-color: var(--color-error-500);
}

.form-input-error:focus,
.form-input.is-invalid:focus {
  box-shadow: var(--shadow-focus-error);
}

.form-input-success,
.form-input.is-valid {
  border-color: var(--color-success-500);
}

.form-input-success:focus,
.form-input.is-valid:focus {
  box-shadow: var(--shadow-focus-success);
}

/* Form helper text */
.form-helper {
  margin-top: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-gray-500);
}

.form-error {
  margin-top: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-error-500);
}

/* Checkbox and radio */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.form-check-input {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--color-primary-500);
}

.form-check-label {
  font-size: var(--font-size-sm);
  color: var(--color-gray-700);
  cursor: pointer;
}

/* =====================================================
   4. TYPOGRAPHY SYSTEM
   ===================================================== */

/* Heading styles */
.heading-1 {
  font-family: var(--font-family-primary);
  font-size: var(--heading-1);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
  color: var(--color-gray-900);
  margin: 0 0 var(--space-6) 0;
}

.heading-2 {
  font-family: var(--font-family-primary);
  font-size: var(--heading-2);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-snug);
  letter-spacing: var(--letter-spacing-tight);
  color: var(--color-gray-900);
  margin: 0 0 var(--space-5) 0;
}

.heading-3 {
  font-family: var(--font-family-primary);
  font-size: var(--heading-3);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-snug);
  color: var(--color-gray-800);
  margin: 0 0 var(--space-4) 0;
}

.heading-4 {
  font-family: var(--font-family-primary);
  font-size: var(--heading-4);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-normal);
  color: var(--color-gray-800);
  margin: 0 0 var(--space-3) 0;
}

/* Text styles */
.text-body {
  font-size: var(--font-size-lg);
  line-height: var(--line-height-relaxed);
  color: var(--color-gray-600);
}

.text-body-sm {
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  color: var(--color-gray-600);
}

.text-body-lg {
  font-size: var(--font-size-xl);
  line-height: var(--line-height-relaxed);
  color: var(--color-gray-700);
}

/* Text gradient */
.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: var(--font-weight-bold);
}

/* Text utilities */
.text-primary {
  color: var(--color-primary-500);
}

.text-success {
  color: var(--color-success-500);
}

.text-warning {
  color: var(--color-warning-500);
}

.text-error {
  color: var(--color-error-500);
}

.text-muted {
  color: var(--color-gray-500);
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

/* =====================================================
   5. ALERT/MESSAGE SYSTEM
   ===================================================== */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  border: var(--border-width-thin) solid transparent;
}

.alert i {
  font-size: var(--font-size-lg);
  flex-shrink: 0;
  margin-top: 2px;
}

.alert-success {
  background: linear-gradient(135deg, var(--color-success-50) 0%, var(--color-success-100) 100%);
  color: var(--color-success-700);
  border-color: var(--color-success-500);
}

.alert-success i {
  color: var(--color-success-500);
}

.alert-error {
  background: linear-gradient(135deg, var(--color-error-50) 0%, var(--color-error-100) 100%);
  color: var(--color-error-700);
  border-color: var(--color-error-500);
}

.alert-error i {
  color: var(--color-error-500);
}

.alert-warning {
  background: linear-gradient(135deg, var(--color-warning-50) 0%, var(--color-warning-100) 100%);
  color: var(--color-warning-700);
  border-color: var(--color-warning-500);
}

.alert-warning i {
  color: var(--color-warning-500);
}

.alert-info {
  background: linear-gradient(135deg, var(--color-info-50) 0%, var(--color-info-100) 100%);
  color: var(--color-info-700);
  border-color: var(--color-info-500);
}

.alert-info i {
  color: var(--color-info-500);
}

/* =====================================================
   6. BADGE SYSTEM
   ===================================================== */

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

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

.badge-secondary {
  background: var(--color-gray-100);
  color: var(--color-gray-700);
}

.badge-success {
  background: var(--color-success-100);
  color: var(--color-success-700);
}

.badge-warning {
  background: var(--color-warning-100);
  color: var(--color-warning-700);
}

.badge-error {
  background: var(--color-error-100);
  color: var(--color-error-700);
}

/* Larger badge */
.badge-lg {
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
}

/* =====================================================
   7. ICON CONTAINER
   ===================================================== */

.icon-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--gradient-primary);
  border-radius: var(--radius-lg);
  color: white;
  font-size: var(--font-size-xl);
}

.icon-box-sm {
  width: 36px;
  height: 36px;
  font-size: var(--font-size-base);
}

.icon-box-lg {
  width: 64px;
  height: 64px;
  font-size: var(--font-size-2xl);
}

.icon-box-outline {
  background: transparent;
  border: var(--border-width-medium) solid var(--color-primary-500);
  color: var(--color-primary-500);
}

/* =====================================================
   8. DIVIDERS
   ===================================================== */

.divider {
  height: 1px;
  background: var(--border-color-light);
  margin: var(--space-8) 0;
}

.divider-vertical {
  width: 1px;
  height: 100%;
  background: var(--border-color-light);
  margin: 0 var(--space-4);
}

.divider-with-text {
  display: flex;
  align-items: center;
  margin: var(--space-6) 0;
}

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

.divider-with-text span {
  padding: 0 var(--space-4);
  color: var(--color-gray-500);
  font-size: var(--font-size-sm);
}

/* =====================================================
   9. LOADING STATES
   ===================================================== */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.spinner-sm {
  width: 16px;
  height: 16px;
}

.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

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

/* Skeleton loading */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-gray-200) 25%,
    var(--color-gray-100) 50%,
    var(--color-gray-200) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* =====================================================
   10. UTILITY CLASSES
   ===================================================== */

/* Spacing utilities */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

/* Padding utilities */
.p-0 { padding: 0; }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

.pt-0 { padding-top: 0; }
.pt-4 { padding-top: var(--space-4); }
.pb-0 { padding-bottom: 0; }
.pb-4 { padding-bottom: var(--space-4); }

/* Color utilities - extends text-* from typography section */
.text-gray-500 { color: var(--color-gray-500); }
.text-gray-600 { color: var(--color-gray-600); }
.text-gray-700 { color: var(--color-gray-700); }
.text-gray-800 { color: var(--color-gray-800); }
.text-gray-900 { color: var(--color-gray-900); }
.text-white { color: white; }

/* Background utilities */
.bg-white { background: var(--bg-primary); }
.bg-gray-50 { background: var(--bg-secondary); }
.bg-gray-100 { background: var(--bg-tertiary); }
.bg-transparent { background: transparent; }

/* Border utilities */
.border-0 { border: none; }
.border { border: var(--border-width-thin) solid var(--border-color-light); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

/* Flex utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

/* Width utilities */
.w-full { width: 100%; }
.w-auto { width: auto; }

/* Visibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Hover effects */
.hover-lift {
  transition: var(--transition-transform);
}

.hover-lift:hover {
  transform: translateY(-2px);
}

/* Focus visible for accessibility */
.focus-visible:focus-visible {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 2px;
}

/* =====================================================
   11. DASHBOARD LAYOUT PRIMITIVES
   Shared by dashboard, profile, billing, usage, etc.
   ===================================================== */

/* Dashboard page body */
.dashboard-body {
  background-color: var(--bg-secondary);
  margin: 0;
  padding: 0;
}

/* App wrapper for sidebar + main */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
}

.page-header h1 {
  margin: 0;
  font-size: var(--font-size-2xl);
  color: var(--color-gray-700);
  font-weight: var(--font-weight-semibold);
}

.header-content h1 {
  margin: 0;
  font-size: var(--font-size-2xl);
  color: var(--color-gray-700);
  font-weight: var(--font-weight-semibold);
}

.header-subtitle {
  margin: var(--space-1) 0 0;
  color: var(--color-gray-500);
  font-size: var(--font-size-base);
}

/* Content grid for dashboard pages */
.content-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

