/**
 * HuTraits - Global Custom CSS & Design System
 * 
 * This file provides:
 * - Design tokens (CSS custom properties)
 * - Base styles and resets
 * - Utility classes not in Tailwind
 * - Accessibility enhancements
 * - Animations and transitions
 * - Component-level styles
 * 
 * Complements: public/assets/tailwind.config.js
 */

/* ============================================================================
   1. DESIGN TOKENS & CSS CUSTOM PROPERTIES
   ============================================================================ */

 :root {
  /* Colors */
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-primary-light: #7cb7ff;
  --color-secondary: #475569;
  --color-accent: #f59e0b;
  --color-accent-dark: #d97706;
  --color-success: #15803d;
  --color-success-light: #22c55e;
  --color-danger: #b91c1c;
  --color-danger-light: #ef4444;
  --color-warning: #d97706;
  --color-warning-light: #fbbf24;
  --color-info: #2563eb;
  --color-info-light: #3b82f6;

  /* Backgrounds */
  --color-bg-primary: #ffffff;
  --color-bg-secondary: #f8fafc;
  --color-bg-tertiary: #eef4ff;
  --color-bg-dark: #0f172a;
  --color-bg-dark-secondary: #172033;

  /* Text */
  --color-text-primary: #0f172a;
  --color-text-secondary: #334155;
  --color-text-muted: #64748b;
  --color-text-disabled: #cbd5e1;
  --color-text-light: #ffffff;

  /* Borders */
  --color-border: #dbe5f1;
  --color-border-light: #edf2f7;
  --color-border-dark: #b6c3d4;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.08);
  --shadow-base: 0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.1);
  --shadow-xl: 0 28px 80px rgba(15, 23, 42, 0.14);
  --shadow-2xl: 0 40px 120px rgba(15, 23, 42, 0.18);
  --shadow-soft: 0 18px 50px rgba(15, 23, 42, 0.09);
  --shadow-glow: 0 20px 60px rgba(37, 99, 235, 0.22);
  --shadow-inset: inset 0 2px 4px 0 rgba(15, 23, 42, 0.05);

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --radius-2xl: 1.5rem;
  --radius-3xl: 1.875rem;
  --radius-4xl: 2rem;
  --radius-full: 9999px;

  /* Typography */
  --font-sans: 'Cairo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Space Grotesk', 'Cairo', system-ui, sans-serif;
  --font-heading: 'Cairo', system-ui, sans-serif;
  --font-mono: 'Courier New', monospace;

  /* Z-Index layers */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
  --z-notification: 9999;

  /* Transitions */
  --duration-75: 75ms;
  --duration-100: 100ms;
  --duration-150: 150ms;
  --duration-200: 200ms;
  --duration-300: 300ms;
  --duration-500: 500ms;
}

/* Dark mode overrides */
:root[data-theme="dark"],
body.dark,
body:is(.dark *) {
  --color-bg-primary: #1e293b;
  --color-bg-secondary: #0f172a;
  --color-bg-tertiary: #0b0f1a;
  --color-text-primary: #f1f5f9;
  --color-text-secondary: #cbd5e1;
  --color-text-muted: #94a3b8;
  --color-text-disabled: #64748b;
  --color-border: #334155;
  --color-border-dark: #475569;
}

/* ============================================================================
   2. BASE STYLES & RESETS
   ============================================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  transition: background-color var(--duration-300), color var(--duration-300);
  overflow-x: hidden;
}

/* RTL Support */
html[dir="rtl"] body {
  text-align: right;
}

html[dir="ltr"] body {
  text-align: left;
}

/* Selection */
::selection {
  background: var(--color-primary);
  color: white;
}

/* ============================================================================
   3. ACCESSIBILITY & INTERACTION - ENHANCED
   ============================================================================ */

/* Skip link */
.skip-link {
  position: fixed;
  top: 0.5rem;
  inset-inline-start: 0.5rem;
  z-index: var(--z-notification);
  padding: 0.5rem 0.75rem;
  background: var(--color-text-primary);
  color: var(--color-bg-primary);
  font-weight: 700;
  font-size: 0.875rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform var(--duration-200) ease;
}

.skip-link:focus {
  transform: translateY(0);
  box-shadow: var(--shadow-lg);
}

/* Enhanced focus visible - better visibility */
:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-md);
}

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-md);
}

/* Keyboard-only focus for buttons */
button:focus-visible,
a:focus-visible {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.25);
}

/* High contrast mode support */
@media (prefers-contrast: more) {
  :focus-visible {
    outline-width: 4px;
  }

  a {
    text-decoration: underline;
  }

  button {
    border-width: 2px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Disabled state */
button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  pointer-events: none;
}

/* ============================================================================
   4. TYPOGRAPHY
   ============================================================================ */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 1rem;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
  margin-bottom: 1rem;
}

strong, b {
  font-weight: 700;
}

em, i {
  font-style: italic;
}

code, pre, kbd, samp {
  font-family: var(--font-mono);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 0.125rem 0.375rem;
}

pre {
  overflow-x: auto;
  padding: 1rem;
  margin-bottom: 1rem;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--duration-200);
}

a:hover {
  color: var(--color-primary-dark);
}

a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ============================================================================
   5. FORMS & INPUTS - ENHANCED
   ============================================================================ */

input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  display: block;
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  transition: border-color var(--duration-200), box-shadow var(--duration-200), background-color var(--duration-200);
  font-weight: 500;
}

input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  outline: none;
  background-color: var(--color-bg-secondary);
}

input::placeholder,
textarea::placeholder {
  color: var(--color-text-muted);
  font-weight: 400;
}

/* Enhanced input styling */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
textarea,
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234b5563' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
  background-size: 1rem;
  padding-right: 2.5rem;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%232563eb' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

textarea {
  background-image: none;
  resize: vertical;
  min-height: 120px;
  padding-right: 0.875rem;
}

/* Form groups */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text-primary);
}

.form-label.required::after {
  content: '*';
  color: var(--color-danger);
  margin-left: 0.25rem;
}

.form-help {
  margin-top: 0.375rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.form-error {
  margin-top: 0.375rem;
  font-size: 0.85rem;
  color: var(--color-danger);
}

/* Form validation */
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.1);
}

input.is-valid,
select.is-valid,
textarea.is-valid {
  border-color: var(--color-success);
  box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.1);
}

/* ============================================================================
   6. BUTTONS - ENHANCED
   ============================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.625rem 1rem;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--duration-200);
  user-select: none;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width var(--duration-300), height var(--duration-300);
  pointer-events: none;
}

.btn:active::before {
  width: 300px;
  height: 300px;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Button variants */
.btn-primary {
  background: var(--color-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.4);
}

.btn-secondary {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  border-color: var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-border);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
  border-width: 2px;
}

.btn-outline:hover:not(:disabled) {
  background: rgba(37, 99, 235, 0.1);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-danger {
  background: var(--color-danger);
  color: white;
  box-shadow: 0 4px 12px rgba(185, 28, 28, 0.3);
}

.btn-danger:hover:not(:disabled) {
  background: var(--color-danger-light);
  box-shadow: 0 8px 24px rgba(185, 28, 28, 0.4);
}

.btn-success {
  background: var(--color-success);
  color: white;
  box-shadow: 0 4px 12px rgba(21, 128, 61, 0.3);
}

.btn-success:hover:not(:disabled) {
  background: var(--color-success-light);
  box-shadow: 0 8px 24px rgba(21, 128, 61, 0.4);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 0.875rem 1.5rem;
  font-size: 1.125rem;
}

.btn-block {
  width: 100%;
}

/* Loading state */
.btn-loading {
  position: relative;
  opacity: 0.8;
}

.btn-loading::after {
  content: '';
  position: absolute;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-inline-start: 0.5rem;
}

/* ============================================================================
   7. CARDS & CONTAINERS - ENHANCED
   ============================================================================ */

.card {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-200), transform var(--duration-200), border-color var(--duration-200);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-border), transparent);
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
  border-color: var(--color-primary);
}

.card.has-gradient {
  background: linear-gradient(135deg, var(--color-bg-primary) 0%, var(--color-bg-secondary) 100%);
  overflow: hidden;
  position: relative;
}

.card.has-gradient::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.1) 0%, transparent 70%);
  pointer-events: none;
}

.card-header {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.card-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--color-text-primary);
}

.card-body {
  margin-bottom: 1rem;
  position: relative;
  z-index: 1;
}

.card-footer {
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Hero card (prominent card with gradient) */
.card-hero {
  background: linear-gradient(135deg, var(--color-primary) 0%, #1e40af 100%);
  color: white;
  border: none;
  box-shadow: var(--shadow-xl);
}

.card-hero:hover {
  transform: translateY(-8px);
  box-shadow: 0 25px 50px -12px rgba(37, 99, 235, 0.3);
}

/* ============================================================================
   8. BADGES & CHIPS - ENHANCED
   ============================================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  transition: all var(--duration-200);
}

.badge-primary { 
  background: rgba(37, 99, 235, 0.15);
  color: var(--color-primary);
  border: 1px solid rgba(37, 99, 235, 0.3);
}

.badge-primary:hover {
  background: rgba(37, 99, 235, 0.25);
  border-color: rgba(37, 99, 235, 0.5);
}

.badge-success { 
  background: rgba(21, 128, 61, 0.15);
  color: var(--color-success);
  border: 1px solid rgba(21, 128, 61, 0.3);
}

.badge-danger { 
  background: rgba(185, 28, 28, 0.15);
  color: var(--color-danger);
  border: 1px solid rgba(185, 28, 28, 0.3);
}

.badge-warning { 
  background: rgba(217, 119, 6, 0.15);
  color: var(--color-warning);
  border: 1px solid rgba(217, 119, 6, 0.3);
}

.badge-info { 
  background: rgba(37, 99, 235, 0.15);
  color: var(--color-info);
  border: 1px solid rgba(37, 99, 235, 0.3);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: default;
  transition: all var(--duration-200);
  position: relative;
  overflow: hidden;
}

.chip::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--color-primary);
  opacity: 0;
  transition: opacity var(--duration-200);
  pointer-events: none;
  z-index: -1;
}

.chip:hover {
  border-color: var(--color-primary);
  background: rgba(37, 99, 235, 0.08);
}

.chip.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

/* ============================================================================
   9. TOAST & NOTIFICATIONS - ENHANCED
   ============================================================================ */

.toast-wrapper {
  position: fixed;
  top: 1rem;
  inset-inline-end: 1rem;
  z-index: var(--z-notification);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 22rem;
  pointer-events: auto;
}

.toast {
  padding: 1rem;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: slideInLeft var(--duration-300) ease-out;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  border-left: 4px solid var(--color-info);
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--color-info);
}

.toast-close {
  margin-left: auto;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: color var(--duration-200);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.25rem;
}

.toast-close:hover {
  color: var(--color-text-primary);
}

.toast-close:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.toast-success {
  border-color: var(--color-success);
}

.toast-success::before {
  background: var(--color-success);
}

.toast-error {
  border-color: var(--color-danger);
}

.toast-error::before {
  background: var(--color-danger);
}

.toast-info {
  border-color: var(--color-info);
}

.toast-info::before {
  background: var(--color-info);
}

.toast-warning {
  border-color: var(--color-warning);
}

.toast-warning::before {
  background: var(--color-warning);
}

.alert {
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.alert-success {
  background: rgba(21, 128, 61, 0.1);
  border-color: var(--color-success);
  color: var(--color-success);
}

.alert-error {
  background: rgba(185, 28, 28, 0.1);
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.alert-warning {
  background: rgba(217, 119, 6, 0.1);
  border-color: var(--color-warning);
  color: var(--color-warning);
}

.alert-info {
  background: rgba(37, 99, 235, 0.1);
  border-color: var(--color-info);
  color: var(--color-info);
}

/* ============================================================================
   10. ANIMATIONS & EFFECTS
   ============================================================================ */

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}

/* ============================================================================
   11. SCROLLBAR STYLING
   ============================================================================ */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border-dark);
  border-radius: var(--radius-full);
  transition: background var(--duration-200);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-secondary);
}

/* ============================================================================
   12. UTILITY CLASSES
   ============================================================================ */

/* Direction utilities */
.dir-ltr {
  direction: ltr;
  unicode-bidi: isolate;
}

.dir-rtl {
  direction: rtl;
  unicode-bidi: isolate;
}

.bidi-plaintext {
  unicode-bidi: plaintext;
}

.wrap-anywhere {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Line clamp (CSS-only) */
.line-clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Gradient text */
.text-gradient {
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* Visually hidden but accessible */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  white-space: normal;
  margin: 0;
  padding: 0;
}

/* ============================================================================
   13. LAZY LOADING & PERFORMANCE
   ============================================================================ */

img[loading="lazy"] {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

/* Reduce CLS (Cumulative Layout Shift) */
img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Optimize animations for performance */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================================
   14. PRINT STYLES
   ============================================================================ */

@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  a,
  a:visited {
    text-decoration: underline;
  }

  pre {
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }

  img {
    max-width: 100% !important;
  }

  @page {
    margin: 0.5cm;
  }
}

/* ============================================================================
   15. MARKETPLACE SURFACES
   ============================================================================ */

.market-shell {
  position: relative;
}

.market-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.12), transparent 32%),
    radial-gradient(circle at bottom left, rgba(245, 158, 11, 0.10), transparent 28%);
  pointer-events: none;
  z-index: 0;
}

.surface-glass {
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.premium-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.45), transparent);
}

.site-toast-wrap {
  position: fixed;
  inset-inline-start: 1rem;
  bottom: 1rem;
  z-index: var(--z-notification);
  display: grid;
  gap: 0.75rem;
  max-width: min(92vw, 360px);
}

.site-toast {
  transform: translateY(12px);
  opacity: 0;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
  padding: 0.9rem 1rem;
  color: var(--color-text-primary);
  font-size: 0.92rem;
  font-weight: 700;
  transition: transform var(--duration-200), opacity var(--duration-200);
}

.site-toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.site-toast--success {
  border-color: rgba(34, 197, 94, 0.24);
}

.site-toast--error {
  border-color: rgba(239, 68, 68, 0.24);
}

.site-toast--info {
  border-color: rgba(37, 99, 235, 0.22);
}

.flash-message {
  transition: opacity var(--duration-200), transform var(--duration-200);
}

.flash-message.is-hiding,
[data-flash].is-hiding {
  opacity: 0;
  transform: translateY(-6px);
}
