/* ===================================
   CLOUD TOWER PREMIUM UX/UI SYSTEM
   Version: v98.0 - Stable Premium Design
   =================================== */

/* ===================================
   1. DESIGN TOKENS & VARIABLES
   =================================== */
:root {
  /* Spacing Scale (8pt Grid System) */
  --space-4: 4px;
  --space-8: 8px;
  --space-12: 12px;
  --space-16: 16px;
  --space-24: 24px;
  --space-32: 32px;
  --space-48: 48px;
  --space-64: 64px;
  
  /* Typography Scale */
  --text-xs: 0.75rem;      /* 12px */
  --text-sm: 0.875rem;     /* 14px */
  --text-base: 1rem;       /* 16px */
  --text-lg: 1.125rem;     /* 18px */
  --text-xl: 1.25rem;      /* 20px */
  --text-2xl: 1.5rem;      /* 24px */
  --text-3xl: 1.875rem;    /* 30px */
  --text-4xl: 2.25rem;     /* 36px */
  --text-5xl: 3rem;        /* 48px */
  
  /* Border Radius */
  --radius-sm: 0.375rem;   /* 6px */
  --radius-md: 0.5rem;     /* 8px */
  --radius-lg: 0.75rem;    /* 12px */
  --radius-xl: 1rem;       /* 16px */
  --radius-2xl: 1.5rem;    /* 24px */
  --radius-3xl: 2rem;      /* 32px */
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  
  /* Z-index Scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-tooltip: 1070;
  
  /* Transition Timing */
  --transition-fast: 150ms;
  --transition-base: 250ms;
  --transition-slow: 350ms;
  --transition-slower: 500ms;
  
  /* Colors - Premium Palette */
  --color-primary: #2563eb;
  --color-primary-dark: #1e40af;
  --color-primary-light: #3b82f6;
  --color-secondary: #7c3aed;
  --color-accent: #8b5cf6;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  
  /* Touch Target Sizes */
  --touch-target-min: 48px;
  --touch-target-comfortable: 56px;
}

/* ===================================
   2. RESET & BASE IMPROVEMENTS
   =================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Helvetica Neue', sans-serif;
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===================================
   3. RESPONSIVE IMAGES & MEDIA
   =================================== */
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

img {
  border-style: none;
  vertical-align: middle;
}

/* Prevent Image Drag */
img {
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
}

/* ===================================
   4. ENHANCED FOCUS STATES
   =================================== */
/* Remove default outlines */
*:focus {
  outline: none;
}

/* Enhanced keyboard navigation focus */
*:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Button focus states */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  *:focus-visible {
    outline-width: 4px;
    outline-color: currentColor;
  }
}

/* ===================================
   5. CONSISTENT BUTTON SYSTEM
   =================================== */
/* Base button styles */
button,
.btn,
[role="button"],
input[type="submit"],
input[type="button"],
input[type="reset"] {
  /* Minimum touch target size */
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
  
  /* Padding & Typography */
  padding: var(--space-12) var(--space-24);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.5;
  
  /* Visual appearance */
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  
  /* Transitions */
  transition: all var(--transition-base) ease;
  
  /* Remove default appearance */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  
  /* Display & Alignment */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  text-align: center;
  text-decoration: none;
  vertical-align: middle;
  
  /* Prevent text selection */
  user-select: none;
  -webkit-user-select: none;
  
  /* Touch action */
  touch-action: manipulation;
}

/* Button size variants */
.btn-sm {
  min-height: 40px;
  padding: var(--space-8) var(--space-16);
  font-size: var(--text-sm);
}

.btn-lg {
  min-height: var(--touch-target-comfortable);
  padding: var(--space-16) var(--space-32);
  font-size: var(--text-lg);
}

/* Button hover states */
button:not(:disabled):hover,
.btn:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Button active states */
button:not(:disabled):active,
.btn:not(:disabled):active {
  transform: translateY(0);
}

/* Disabled state */
button:disabled,
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ===================================
   6. FORM VALIDATION & FEEDBACK
   =================================== */
/* Input base styles */
input:not([type="checkbox"]):not([type="radio"]),
textarea,
select {
  width: 100%;
  min-height: var(--touch-target-min);
  padding: var(--space-12) var(--space-16);
  font-size: var(--text-base);
  line-height: 1.5;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-md);
  transition: all var(--transition-base) ease;
  background-color: white;
}

/* Prevent iOS zoom on focus */
@supports (-webkit-touch-callout: none) {
  input:not([type="checkbox"]):not([type="radio"]),
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* Focus state */
input:focus,
textarea:focus,
select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Invalid state */
input[aria-invalid="true"],
textarea[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--color-error);
  background-color: #fef2f2;
}

input[aria-invalid="true"]:focus,
textarea[aria-invalid="true"]:focus,
select[aria-invalid="true"]:focus {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Valid state */
input[aria-invalid="false"],
textarea[aria-invalid="false"],
select[aria-invalid="false"] {
  border-color: var(--color-success);
  background-color: #f0fdf4;
}

/* Error message styling */
.error-message {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  margin-top: var(--space-8);
  padding: var(--space-8) var(--space-12);
  font-size: var(--text-sm);
  color: var(--color-error);
  background-color: #fef2f2;
  border-left: 4px solid var(--color-error);
  border-radius: var(--radius-sm);
}

/* Success message styling */
.success-message {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  margin-top: var(--space-8);
  padding: var(--space-12) var(--space-16);
  font-size: var(--text-base);
  color: var(--color-success);
  background-color: #dcfce7;
  border-left: 4px solid var(--color-success);
  border-radius: var(--radius-sm);
}

/* ===================================
   7. PREMIUM CARD SYSTEM
   =================================== */
.premium-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--space-24);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base) ease;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

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

/* Glass effect card */
.glass-card {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
}

/* ===================================
   8. RESPONSIVE LAYOUT UTILITIES
   =================================== */
/* Container */
.container-premium {
  width: 100%;
  max-width: 1440px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-16);
  padding-right: var(--space-16);
}

@media (min-width: 640px) {
  .container-premium {
    padding-left: var(--space-24);
    padding-right: var(--space-24);
  }
}

@media (min-width: 1024px) {
  .container-premium {
    padding-left: var(--space-32);
    padding-right: var(--space-32);
  }
}

/* Responsive grid */
.grid-responsive {
  display: grid;
  gap: var(--space-24);
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .grid-responsive {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-32);
  }
}

@media (min-width: 1024px) {
  .grid-responsive {
    gap: var(--space-48);
  }
}

/* ===================================
   9. MOBILE OPTIMIZATIONS
   =================================== */
/* Prevent horizontal scroll on mobile */
body {
  overflow-x: hidden;
  width: 100%;
}

/* Mobile touch optimization */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets on mobile */
  button,
  a,
  input,
  select {
    min-height: var(--touch-target-comfortable);
  }
  
  /* Remove hover effects on touch devices */
  .premium-card:hover {
    transform: none;
  }
  
  button:hover {
    transform: none;
  }
}

/* Safe area for notched devices */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }
}

/* ===================================
   10. ROADMAP IMAGE STABILITY
   =================================== */
.roadmap-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
}

.roadmap-image-wrapper {
  position: relative;
  width: 100%;
  background: white;
  border-radius: var(--radius-2xl);
  overflow: hidden;
  box-shadow: var(--shadow-2xl);
  border: 2px solid #d8b4fe;
  transition: all var(--transition-base) ease;
}

.roadmap-image-wrapper:hover {
  border-color: #a78bfa;
  box-shadow: 0 25px 50px -12px rgba(139, 92, 246, 0.3);
}

.roadmap-image-wrapper img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  aspect-ratio: 1 / 1;
}

/* Prevent layout shift */
.roadmap-image-wrapper::before {
  content: '';
  display: block;
  padding-bottom: 100%; /* 1:1 aspect ratio */
}

.roadmap-image-wrapper img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Responsive roadmap sizing */
@media (max-width: 640px) {
  .roadmap-container {
    padding: var(--space-16);
  }
}

@media (min-width: 641px) and (max-width: 1023px) {
  .roadmap-container {
    max-width: 600px;
  }
}

@media (min-width: 1024px) {
  .roadmap-container {
    max-width: 100%;
  }
}

/* ===================================
   11. LOADING STATES
   =================================== */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

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

.loading-skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

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

/* ===================================
   12. ACCESSIBILITY ENHANCEMENTS
   =================================== */
/* Screen reader only */
.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;
}

/* Skip to main content */
.skip-to-main {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-primary);
  color: white;
  padding: var(--space-12) var(--space-24);
  text-decoration: none;
  border-radius: var(--radius-md);
  z-index: 9999;
}

.skip-to-main:focus {
  top: 10px;
  left: 10px;
}

/* Keyboard navigation indicator */
body.keyboard-nav *:focus {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* ===================================
   13. PRINT STYLES
   =================================== */
@media print {
  *, *::before, *::after {
    background: white !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  a, a:visited {
    text-decoration: underline;
  }
  
  a[href]::after {
    content: " (" attr(href) ")";
  }
  
  img {
    max-width: 100% !important;
    page-break-inside: avoid;
  }
  
  nav, footer, video, audio {
    display: none;
  }
  
  @page {
    margin: 2cm;
  }
}

/* ===================================
   14. PERFORMANCE OPTIMIZATIONS
   =================================== */
/* GPU acceleration for animations */
.animate-gpu {
  transform: translateZ(0);
  will-change: transform, opacity;
}

/* Contain layout shifts */
.contain-layout {
  contain: layout style paint;
}

/* Lazy load placeholder */
.lazy-placeholder {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

/* ===================================
   15. CUSTOM SCROLLBAR (Premium)
   =================================== */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: var(--radius-lg);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #2563eb 0%, #7c3aed 100%);
  border-radius: var(--radius-lg);
  border: 2px solid #f1f5f9;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #1e40af 0%, #6d28d9 100%);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: #2563eb #f1f5f9;
}
