/**
 * Master UI Codex - CSS Layer
 * Persuasive Design & High-Performance UX
 * All classes prefixed with .cdx- for isolation
 */

/* ========================================
   PART 2: THE POLISH LAYER (50 Items)
   ======================================== */

/* 1. Hover Lift - Buttons rise on hover */
.cdx-hover-lift,
button:not([disabled]),
[role="button"] {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cdx-hover-lift:hover,
button:not([disabled]):hover,
[role="button"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 2. Click Press - Buttons compress on click */
.cdx-click-press:active,
button:not([disabled]):active,
[role="button"]:active {
  transform: scale(0.98) translateY(0);
  transition: transform 0.05s ease;
}

/* 3. Focus Glow - Inputs glow on focus */
.cdx-focus-glow:focus,
input:focus,
textarea:focus,
select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.3);
  border-color: rgb(249, 115, 22);
}

/* 4. Skeleton Screen - Loading animation */
.cdx-skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: cdx-skeleton-shimmer 1.5s infinite;
  border-radius: 4px;
}
@keyframes cdx-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 5. Menu Slide - Dropdown transitions */
.cdx-menu-slide {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.cdx-menu-slide.cdx-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* 6. Cursor Hand - Pointer on clickables */
.cdx-clickable,
[data-clickable],
[onclick] {
  cursor: pointer;
}

/* 7. Link Fade - Smooth color transitions */
.cdx-link-fade,
a {
  transition: color 0.2s ease, opacity 0.2s ease;
}
.cdx-link-fade:hover,
a:hover {
  opacity: 0.85;
}

/* 8. Sticky Header - Fixed top navigation */
.cdx-sticky-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

/* 9. Toast Pop - Toast entrance animation */
.cdx-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: rgba(30, 30, 30, 0.95);
  color: white;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 2147483647;
  animation: cdx-toast-pop 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 400px;
}
@keyframes cdx-toast-pop {
  0% { transform: translateY(100px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}
.cdx-toast-success { border-left: 4px solid #22c55e; }
.cdx-toast-error { border-left: 4px solid #ef4444; }
.cdx-toast-info { border-left: 4px solid #3b82f6; }
.cdx-toast-warning { border-left: 4px solid #f59e0b; }

/* 10. Progress Bar - Scroll indicator */
.cdx-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #f97316, #fb923c);
  z-index: 2147483647;
  transition: width 0.1s ease;
}

/* 11-14. Typography improvements */
.cdx-readable {
  line-height: 1.6;
  max-width: 75ch;
}
.cdx-heading {
  letter-spacing: -0.02em;
  font-weight: 600;
}

/* 15. Contrast Fix - Ensure readable text */
.cdx-high-contrast {
  color: rgba(255, 255, 255, 0.95);
}

/* 21. Auto-Focus indicator */
.cdx-auto-focus {
  animation: cdx-focus-pulse 0.5s ease;
}
@keyframes cdx-focus-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(249, 115, 22, 0); }
}

/* 25. Password Toggle Eye */
.cdx-pass-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.cdx-pass-toggle:hover { opacity: 1; }

/* 28. Button Hierarchy */
.cdx-btn-primary {
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: white;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
}
.cdx-btn-secondary {
  background: transparent;
  color: #f97316;
  border: 1px solid #f97316;
  padding: 10px 20px;
  border-radius: 8px;
}
.cdx-btn-ghost {
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
}
.cdx-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* 29. Touch Targets - Mobile friendly */
.cdx-touch-target {
  min-height: 44px;
  min-width: 44px;
}

/* 30. Label Float - Floating labels */
.cdx-label-float {
  position: relative;
}
.cdx-label-float label {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  transition: all 0.2s ease;
  pointer-events: none;
  color: rgba(255, 255, 255, 0.5);
}
.cdx-label-float input:focus + label,
.cdx-label-float input:not(:placeholder-shown) + label {
  top: 0;
  font-size: 0.75rem;
  background: var(--background, #0a0a0a);
  padding: 0 4px;
}

/* 37. Back-to-Top Button */
.cdx-back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(249, 115, 22, 0.9);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 1000;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.cdx-back-to-top.cdx-visible {
  opacity: 1;
  transform: translateY(0);
}
.cdx-back-to-top:hover {
  background: #f97316;
  transform: translateY(-2px);
}

/* 40. Modal Close - Backdrop styling */
.cdx-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 2147483646;
  animation: cdx-fade-in 0.2s ease;
}
@keyframes cdx-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 46. Fast Click - Touch optimization */
.cdx-fast-click {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* 50. Clipboard Copy Button */
.cdx-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all 0.2s;
}
.cdx-copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}
.cdx-copy-btn.cdx-copied {
  background: rgba(34, 197, 94, 0.2);
  border-color: #22c55e;
  color: #22c55e;
}

/* ========================================
   PART 1: EFFICIENCY LAYER (CSS Parts)
   ======================================== */

/* 3. Command Palette */
.cdx-cmd-palette {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 600px;
  background: rgba(20, 20, 20, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
  z-index: 2147483647;
  overflow: hidden;
  animation: cdx-cmd-slide 0.2s ease;
}
@keyframes cdx-cmd-slide {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.cdx-cmd-input {
  width: 100%;
  padding: 16px 20px;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 1.1rem;
  outline: none;
}
.cdx-cmd-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}
.cdx-cmd-results {
  max-height: 400px;
  overflow-y: auto;
}
.cdx-cmd-item {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.cdx-cmd-item:hover,
.cdx-cmd-item.cdx-selected {
  background: rgba(249, 115, 22, 0.15);
}
.cdx-cmd-item-icon {
  width: 20px;
  height: 20px;
  opacity: 0.6;
}
.cdx-cmd-item-title {
  flex: 1;
  color: white;
}
.cdx-cmd-item-shortcut {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

/* 13. Skeleton Loader */
.cdx-skeleton-text {
  height: 1em;
  border-radius: 4px;
}
.cdx-skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}
.cdx-skeleton-card {
  height: 120px;
  border-radius: 8px;
}

/* 28. Quick Add FAB */
.cdx-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.4);
  z-index: 1000;
  border: none;
  font-size: 24px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.cdx-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(249, 115, 22, 0.5);
}

/* 45. Celebration Confetti Container */
.cdx-confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2147483647;
  overflow: hidden;
}
.cdx-confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  animation: cdx-confetti-fall 3s ease-out forwards;
}
@keyframes cdx-confetti-fall {
  0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* 46. Progress Ring */
.cdx-progress-ring {
  transform: rotate(-90deg);
}
.cdx-progress-ring-circle {
  transition: stroke-dashoffset 0.5s ease;
  stroke-linecap: round;
}

/* 49. Zen Mode */
.cdx-zen-mode .cdx-hideable {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.cdx-zen-mode main {
  max-width: 800px;
  margin: 0 auto;
}

/* ========================================
   PART 3: ANTICIPATORY LAYER (CSS Parts)
   ======================================== */

/* 6. Circadian Background */
.cdx-circadian-morning { background-color: #1a1a2e; }
.cdx-circadian-day { background-color: #16213e; }
.cdx-circadian-evening { background-color: #1a1a2e; }
.cdx-circadian-night { background-color: #0f0f1a; }

/* 7. Focus Tunnel */
.cdx-focus-tunnel::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 100;
}
.cdx-focus-tunnel.cdx-focused::before {
  opacity: 1;
}
.cdx-focus-tunnel.cdx-focused input:focus,
.cdx-focus-tunnel.cdx-focused textarea:focus {
  position: relative;
  z-index: 101;
}

/* 8. Rage Click Indicator */
.cdx-rage-indicator {
  position: fixed;
  padding: 12px 20px;
  background: rgba(239, 68, 68, 0.95);
  color: white;
  border-radius: 8px;
  z-index: 2147483647;
  animation: cdx-shake 0.5s ease;
}
@keyframes cdx-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* 13. Read Time Indicator */
.cdx-read-time {
  position: fixed;
  bottom: 24px;
  left: 24px;
  padding: 8px 16px;
  background: rgba(30, 30, 30, 0.9);
  border-radius: 20px;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.8);
  z-index: 100;
}

/* ========================================
   PART 4: PSYCHOLOGICAL CODEX (CSS Parts)
   ======================================== */

/* 8. Social Badge */
.cdx-social-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(249, 115, 22, 0.15);
  color: #f97316;
  font-size: 0.75rem;
  border-radius: 12px;
  font-weight: 500;
}

/* 10. Review Date */
.cdx-review-date {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
}

/* 11. Quiet Room Overlay */
.cdx-quiet-room {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.98);
  z-index: 2147483646;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cdx-quiet-room-content {
  max-width: 800px;
  padding: 40px;
}

/* 14. Underwriting View - Grayscale */
.cdx-underwriting {
  filter: grayscale(100%);
}

/* 15. Legacy Font */
.cdx-legacy-font {
  font-family: 'Crimson Text', Georgia, serif;
}

/* 17. Privacy Banner */
.cdx-privacy-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 24px;
  background: rgba(20, 20, 20, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1000;
  font-size: 0.875rem;
}
.cdx-privacy-banner-text {
  color: rgba(255, 255, 255, 0.7);
}
.cdx-privacy-banner-icon {
  color: #22c55e;
}

/* 20. Patient Tag */
.cdx-patient-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  font-size: 0.75rem;
  border-radius: 4px;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.cdx-hidden { display: none !important; }
.cdx-invisible { visibility: hidden; }
.cdx-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Pulse animation */
.cdx-pulse {
  animation: cdx-pulse 2s infinite;
}
@keyframes cdx-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Semantic Colors */
.cdx-success { color: #22c55e; }
.cdx-error { color: #ef4444; }
.cdx-warning { color: #f59e0b; }
.cdx-info { color: #3b82f6; }

.cdx-bg-success { background-color: rgba(34, 197, 94, 0.1); }
.cdx-bg-error { background-color: rgba(239, 68, 68, 0.1); }
.cdx-bg-warning { background-color: rgba(245, 158, 11, 0.1); }
.cdx-bg-info { background-color: rgba(59, 130, 246, 0.1); }
