@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ============================================
   VARIABLES CSS (Thème)
   ============================================ */
:root {
  /* Layout Base */
  --card-padding: 0.5rem;
  --section-gap: 0.5rem;
  --item-gap: 0.25rem;
  --grid-columns: 2;
  --content-max-width: 100%;
  
  /* Shapes Base */
  --radius: 0.5rem;
  --icon-radius: 0.375rem;
  --icon-size: 1.5rem;
  --card-border-width: 1px;

  /* Typography Base */
  --font-display: 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;
  --heading-weight: 800;
  --body-size: 0.75rem;

  /* Shadow */
  --card-shadow: 0 8px 24px -4px rgba(60, 30, 0, 0.25), 0 4px 12px -2px rgba(60, 30, 0, 0.15);

  /* Colors (Style 2 Lavender) */
  --background: hsl(250, 30%, 98%);
  --foreground: hsl(250, 20%, 15%);
  --primary: hsl(270, 60%, 55%);
  --primary-foreground: hsl(250, 30%, 98%);
  --secondary: hsl(250, 25%, 94%);
  --secondary-foreground: hsl(250, 20%, 15%);
  --muted: hsl(250, 20%, 94%);
  --muted-foreground: hsl(250, 15%, 45%);
  --accent: hsl(270, 60%, 55%);
  --accent-foreground: hsl(250, 30%, 98%);
  --border: hsl(250, 25%, 88%);
  --input: hsl(250, 25%, 88%);
  --ring: hsl(270, 60%, 55%);
  --card: hsl(250, 30%, 99%);
  --card-foreground: hsl(250, 20%, 15%);
}

.dark {
  --background: hsl(250, 30%, 8%);
  --foreground: hsl(250, 20%, 95%);
  --primary: hsl(270, 60%, 65%);
  --primary-foreground: hsl(250, 30%, 98%);
  --secondary: hsl(250, 25%, 15%);
  --secondary-foreground: hsl(250, 20%, 95%);
  --muted: hsl(250, 20%, 15%);
  --muted-foreground: hsl(250, 15%, 60%);
  --accent: hsl(270, 60%, 65%);
  --accent-foreground: hsl(250, 30%, 98%);
  --destructive: hsl(0, 62%, 30%);
  --destructive-foreground: hsl(210, 40%, 98%);
  --border: hsl(250, 25%, 20%);
  --input: hsl(250, 25%, 20%);
  --ring: hsl(270, 60%, 55%);
  --card: hsl(250, 30%, 12%);
  --card-foreground: hsl(250, 20%, 95%);
}

/* ============================================
   RESET & BASE
   ============================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border-color: var(--border);
}

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--font-body);
  font-size: var(--body-size);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--heading-weight);
}

/* ============================================
   UTILITY CLASSES (Tailwind-like)
   ============================================ */

/* Display */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-around { justify-content: space-around; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.space-y-1 > * + * { margin-top: 0.25rem; }
.space-y-4 > * + * { margin-top: 1rem; }

/* Grid */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Spacing */
.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.px-1 { padding-left: 0.25rem; padding-right: 0.25rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-1\.5 { padding-top: 0.375rem; padding-bottom: 0.375rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.pt-2 { padding-top: 0.5rem; }
.pt-4 { padding-top: 1rem; }
.pb-24 { padding-bottom: 6rem; }
.pb-8 { padding-bottom: 2rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-0\.5 { margin-top: 0.125rem; }
.mr-2 { margin-right: 0.5rem; }

/* Sizing */
.w-full { width: 100%; }
.w-10 { width: 2.5rem; }
.w-12 { width: 3rem; }
.w-14 { width: 3.5rem; }
.w-16 { width: 4rem; }
.w-24 { width: 6rem; }
.w-32 { width: 8rem; }
.h-10 { height: 2.5rem; }
.h-16 { height: 4rem; }
.h-20 { height: 5rem; }
.h-auto { height: auto; }
.h-2 { height: 0.5rem; }
.h-8 { height: 2rem; }
.min-h-screen { min-height: 100vh; }
.min-h-\[42px\] { min-height: 42px; }
.flex-1 { flex: 1 1 0%; }
.flex-shrink-0 { flex-shrink: 0; }

/* Typography */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.text-4xl { font-size: 2.25rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.font-display { font-family: var(--font-display); }
.uppercase { text-transform: uppercase; }
.tracking-widest { letter-spacing: 0.1em; }
.tracking-wider { letter-spacing: 0.05em; }
.tracking-tight { letter-spacing: -0.025em; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.leading-tight { line-height: 1.25; }
.leading-none { line-height: 1; }
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Colors */
.text-foreground { color: var(--foreground); }
.text-primary { color: var(--primary); }
.text-secondary-foreground { color: var(--secondary-foreground); }
.text-muted-foreground { color: var(--muted-foreground); }
.bg-background { background-color: var(--background); }
.bg-card { background-color: var(--card); }
.bg-primary { background-color: var(--primary); }
.bg-secondary { background-color: var(--secondary); }
.bg-muted { background-color: var(--muted); }
.bg-primary\/5 { 
  background-color: hsla(270, 60%, 55%, 0.05);
}
.bg-primary\/20 { 
  background-color: hsla(270, 60%, 55%, 0.2);
}
.bg-foreground\/5 { 
  background-color: hsla(250, 20%, 15%, 0.05);
}
.bg-background\/80 {
  background-color: hsla(250, 30%, 98%, 0.8);
}
.border-border { border-color: var(--border); }
.border-primary\/10 { 
  border-color: hsla(270, 60%, 55%, 0.1);
}
.backdrop-blur-lg {
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* Borders */
.border { border-width: 1px; }
.border-t { border-top-width: 1px; }
.border-transparent { border-color: transparent; }
.rounded-full { border-radius: 9999px; }
.rounded-xl { border-radius: 0.75rem; }
.rounded-2xl { border-radius: 1rem; }
.rounded-3xl { border-radius: 1.5rem; }
.rounded-\[var\(--radius\)\] { border-radius: var(--radius); }
.rounded-md { border-radius: 0.375rem; }
.rounded-lg { border-radius: 0.5rem; }

/* Effects */
.shadow-sm { box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); }
.opacity-30 { opacity: 0.3; }
.opacity-40 { opacity: 0.4; }
.opacity-50 { opacity: 0.5; }
.opacity-60 { opacity: 0.6; }
.opacity-70 { opacity: 0.7; }

/* Gradients - Support for multiple classes */
.bg-gradient-to-br {
  background-image: linear-gradient(to bottom right, var(--tw-gradient-from), var(--tw-gradient-to));
}
.from-orange-50 { --tw-gradient-from: #fff7ed; --tw-gradient-to: #ffedd5; }
.to-orange-100 { --tw-gradient-to: #ffedd5; }
.from-yellow-50 { --tw-gradient-from: #fefce8; --tw-gradient-to: #fef9c3; }
.to-yellow-100 { --tw-gradient-to: #fef9c3; }
.border-orange-200 { border-color: #fed7aa; }
.border-yellow-200 { border-color: #fde047; }
.text-orange-500 { color: #f97316; }
.text-orange-600\/70 { color: rgba(234, 88, 12, 0.7); }
.text-orange-700 { color: #c2410c; }
.text-yellow-500 { color: #eab308; }
.text-yellow-600\/70 { color: rgba(202, 138, 4, 0.7); }
.text-yellow-700 { color: #a16207; }
.fill-orange-500 { fill: #f97316; }
.fill-yellow-500 { fill: #eab308; }
.bg-white { background-color: #ffffff; }

/* Dividers */
.divide-y > * + * { 
  border-top-width: 1px; 
  border-top-style: solid;
}
.divide-border\/50 > * + * { 
  border-top-color: hsla(250, 25%, 88%, 0.5); 
}

/* Positioning */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }
.right-0 { right: 0; }
.top-0 { top: 0; }
.z-10 { z-index: 10; }
.z-50 { z-index: 50; }

/* Overflow */
.overflow-hidden { overflow: hidden; }

/* Cursor */
.cursor-pointer { cursor: pointer; }
.cursor-grab { cursor: grab; }
.cursor-grabbing { cursor: grabbing; }

/* Transitions */
.transition-all { transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
.transition-colors { transition-property: color, background-color, border-color; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
.transition-transform { transition-property: transform; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
.duration-200 { transition-duration: 200ms; }
.duration-300 { transition-duration: 300ms; }

/* States */
.hover\:bg-transparent:hover { background-color: transparent; }
.hover\:text-foreground:hover { color: var(--foreground); }
.hover\:translate-y-\[-2px\]:hover { transform: translateY(-2px); }
.active\:scale-95:active { transform: scale(0.95); }
.disabled\:opacity-30:disabled { opacity: 0.3; }

/* ============================================
   THEME UTILITIES
   ============================================ */
.theme-card {
  padding: var(--card-padding);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow) !important;
  border-width: var(--card-border-width);
}

.theme-icon {
  width: var(--icon-size);
  height: var(--icon-size);
  border-radius: var(--icon-radius);
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns), minmax(0, 1fr));
  gap: var(--section-gap);
}

.theme-content {
  max-width: var(--content-max-width);
  margin-left: auto;
  margin-right: auto;
}

.heavy-elevation {
  box-shadow: var(--card-shadow) !important;
}

/* ============================================
   CUSTOM COMPONENTS
   ============================================ */

/* Progress Bar */
.progress {
  width: 100%;
  height: 0.5rem;
  background-color: var(--muted);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background-color: var(--primary);
  transition: width 0.3s ease;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
}

.btn-ghost {
  background-color: transparent;
  color: var(--foreground);
}

.btn-ghost:hover {
  background-color: var(--muted);
}

.btn-default {
  background-color: var(--primary);
  color: var(--primary-foreground);
}

.btn-default:hover {
  opacity: 0.9;
}

.btn-outline {
  border: 1px solid var(--border);
  background-color: transparent;
  color: var(--foreground);
}

.btn-outline:hover {
  background-color: var(--muted);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

.btn-icon {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  white-space: nowrap;
}

.badge-secondary {
  background-color: var(--secondary);
  color: var(--secondary-foreground);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--muted-foreground);
  opacity: 0.5;
}

/* Safe Area */
.safe-area-bottom {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (min-width: 768px) {
  .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .md\:pb-8 { padding-bottom: 2rem; }
  .md\:h-20 { height: 5rem; }
  .md\:border-b-0 { border-bottom-width: 0; }
  .md\:border-t { border-top-width: 1px; }
  .md\:top-auto { top: auto; }
  .md\:bottom-0 { bottom: 0; }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

/* Exercise Row Animation */
.exercise-row {
  position: relative;
  overflow: hidden;
}

.exercise-row.done::before {
  content: '';
  position: absolute;
  inset: 0;
  background-color: var(--muted);
  opacity: 0.2;
  width: 100%;
  transition: width 0.5s ease;
}

/* ============================================
   MOBILE OPTIMIZATIONS (Galaxy Fold Z 5)
   ============================================ */

/* Touch-friendly targets (min 44px) */
button, a, .btn {
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
}

/* Safe area support for notches */
@supports (padding: max(0px)) {
  .safe-area-bottom {
    padding-bottom: max(env(safe-area-inset-bottom), 1rem);
  }
  
  .safe-area-top {
    padding-top: max(env(safe-area-inset-top), 1rem);
  }
}

/* Optimize for foldable devices */
@media (max-width: 768px) {
  /* Smaller text on mobile */
  .text-2xl { font-size: 1.25rem; }
  .text-3xl { font-size: 1.5rem; }
  .text-4xl { font-size: 1.875rem; }
  
  /* Adjust spacing */
  .gap-4 { gap: 0.75rem; }
  .p-6 { padding: 1rem; }
  
  /* Navigation univers - scrollable on mobile */
  .flex.items-end.gap-1 {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  
  .flex.items-end.gap-1::-webkit-scrollbar {
    display: none;
  }
  
  /* Ensure buttons are touch-friendly */
  [data-universe] {
    min-width: 60px;
    flex-shrink: 0;
  }
}

/* Galaxy Fold specific (very narrow) */
@media (max-width: 280px) {
  .text-xs { font-size: 0.625rem; }
  .text-sm { font-size: 0.75rem; }
  
  [data-universe] {
    min-width: 50px;
    padding: 0.25rem;
  }
  
  [data-universe] span {
    font-size: 0.625rem;
  }
}

/* Prevent text selection on buttons */
button, .btn {
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Container max-width */
.container {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

@media (min-width: 640px) {
  .container { max-width: 640px; }
}

@media (min-width: 768px) {
  .container { max-width: 768px; }
}

@media (min-width: 1024px) {
  .container { max-width: 1024px; }
}

@media (min-width: 1280px) {
  .container { max-width: 1280px; }
}
