/**
 * Crown HerCare - Global App Styles
 * Mobile-first PWA with native app feel
 * Supports: Light mode, Dark mode, System preference
 */

/* ============================================
   CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================ */

:root {
  /* Primary Colors */
  --primary: #6B4CE6;
  --primary-light: #8B6FF0;
  --primary-dark: #5A3ED1;
  --primary-50: #F3F0FF;
  --primary-100: #E8E2FF;
  --primary-200: #D4CBFF;
  
  /* Secondary Colors */
  --secondary: #E91E63;
  --secondary-light: #F06292;
  --secondary-50: #FCE4EC;
  
  /* Accent Colors */
  --accent-green: #4CAF50;
  --accent-orange: #FF9800;
  --accent-blue: #2196F3;
  --accent-purple: #9C27B0;
  --accent-teal: #009688;
  
  /* Semantic Colors */
  --success: #10B981;
  --success-light: #D1FAE5;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --danger: #EF4444;
  --danger-light: #FEE2E2;
  --info: #3B82F6;
  --info-light: #DBEAFE;
  
  /* Neutral Colors (Light Mode) */
  --bg-primary: #FAFAFE;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #F3F1FA;
  --bg-elevated: #FFFFFF;
  
  --text-primary: #1A1A2E;
  --text-secondary: #6B6B80;
  --text-tertiary: #9B9BB0;
  --text-inverse: #FFFFFF;
  
  --border-light: #EBE8F4;
  --border-medium: #DDD8EA;
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #6B4CE6 0%, #8B6FF0 50%, #A78BFA 100%);
  --gradient-hero: linear-gradient(160deg, #F3F0FF 0%, #FAFAFE 40%, #FFF0F5 100%);
  --gradient-card: linear-gradient(135deg, #6B4CE6, #9C27B0);
  --gradient-menstrual: linear-gradient(135deg, #E91E63, #F48FB1);
  --gradient-fertility: linear-gradient(135deg, #4CAF50, #81C784);
  --gradient-ovulation: linear-gradient(135deg, #FF9800, #FFB74D);
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(107, 76, 230, 0.06);
  --shadow-md: 0 4px 12px rgba(107, 76, 230, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 24px rgba(107, 76, 230, 0.12), 0 4px 8px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 16px 48px rgba(107, 76, 230, 0.15), 0 8px 16px rgba(0, 0, 0, 0.06);
  --shadow-glow: 0 0 20px rgba(107, 76, 230, 0.15);
  
  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  /* Spacing Scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  
  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 400ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
  
  /* Layout */
  --header-height: 56px;
  --bottom-nav-height: 64px;
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --content-max-width: 430px;
  
  /* Skeleton */
  --skeleton-bg: linear-gradient(90deg, var(--border-light) 25%, var(--bg-tertiary) 50%, var(--border-light) 75%);
}

/* ============================================
   DARK MODE
   ============================================ */

[data-theme="dark"] {
  --bg-primary: #0F0F1A;
  --bg-secondary: #1A1A2E;
  --bg-tertiary: #252540;
  --bg-elevated: #22223A;
  
  --text-primary: #F0F0F5;
  --text-secondary: #A0A0B8;
  --text-tertiary: #707090;
  --text-inverse: #1A1A2E;
  
  --border-light: #2A2A45;
  --border-medium: #353558;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.5);
}

/* System preference */
@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    --bg-primary: #0F0F1A;
    --bg-secondary: #1A1A2E;
    --bg-tertiary: #252540;
    --bg-elevated: #22223A;
    
    --text-primary: #F0F0F5;
    --text-secondary: #A0A0B8;
    --text-tertiary: #707090;
    --text-inverse: #1A1A2E;
    
    --border-light: #2A2A45;
    --border-medium: #353558;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
  }
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
  overscroll-behavior-y: none;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  touch-action: manipulation;
}

/* Mobile viewport fix */
@supports (height: 100dvh) {
  body {
    min-height: 100dvh;
  }
}

/* Disable text selection on UI elements */
.no-select {
  -webkit-user-select: none;
  user-select: none;
}

/* Enable text selection on content */
.selectable {
  -webkit-user-select: text;
  user-select: text;
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* Hide scrollbar but keep functionality */
.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

/* ============================================
   LAYOUT SYSTEM
   ============================================ */

.app-container {
  max-width: var(--content-max-width);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
}

/* Safe area padding for notched devices */
.safe-area-top {
  padding-top: var(--safe-area-top);
}

.safe-area-bottom {
  padding-bottom: calc(var(--safe-area-bottom) + var(--bottom-nav-height));
}

/* Main content area */
.main-content {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--bottom-nav-height) + var(--space-4));
}

/* ============================================
   HEADER / APP BAR
   ============================================ */

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-secondary);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-light);
  height: calc(var(--header-height) + var(--safe-area-top));
  padding-top: var(--safe-area-top);
  display: flex;
  align-items: center;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

.app-header-transparent {
  position: absolute;
  background: transparent;
  border-bottom: none;
  z-index: 100;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
  text-align: center;
  padding: 0 var(--space-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.header-btn:active {
  transform: scale(0.92);
  opacity: 0.8;
}

.header-btn svg {
  width: 20px;
  height: 20px;
}

/* ============================================
   BOTTOM NAVIGATION
   ============================================ */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--content-max-width);
  height: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
  padding-bottom: var(--safe-area-bottom);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-light);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 100%;
  text-decoration: none;
  color: var(--text-tertiary);
  transition: var(--transition-fast);
  position: relative;
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item:active {
  opacity: 0.7;
}

.nav-icon {
  width: 24px;
  height: 24px;
  transition: var(--transition-base);
}

.nav-item.active .nav-icon {
  transform: translateY(-1px);
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.nav-indicator {
  position: absolute;
  top: 6px;
  width: 32px;
  height: 3px;
  background: var(--primary);
  border-radius: var(--radius-full);
  opacity: 0;
  transition: var(--transition-base);
}

.nav-item.active .nav-indicator {
  opacity: 1;
}

/* Notification badge on nav */
.nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 14px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--danger);
  color: white;
  font-size: 9px;
  font-weight: 700;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-secondary);
}

/* ============================================
   CARDS
   ============================================ */

.card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: var(--transition-base);
}

.card-elevated {
  box-shadow: var(--shadow-md);
}

.card-premium {
  background: var(--gradient-primary);
  color: var(--text-inverse);
  border: none;
}

.card-premium .card-title,
.card-premium .card-text {
  color: var(--text-inverse);
}

.card-menstrual {
  background: var(--gradient-menstrual);
  color: var(--text-inverse);
  border: none;
}

.card-fertility {
  background: var(--gradient-fertility);
  color: var(--text-inverse);
  border: none;
}

.card-ovulation {
  background: var(--gradient-ovulation);
  color: var(--text-inverse);
  border: none;
}

.card-glass {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

[data-theme="dark"] .card-glass {
  background: rgba(26, 26, 46, 0.8);
}

.card-interactive {
  cursor: pointer;
}

.card-interactive:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.card-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 14px 24px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: var(--transition-base);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 14px rgba(107, 76, 230, 0.3);
}

.btn-primary:active {
  box-shadow: 0 2px 8px rgba(107, 76, 230, 0.2);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--primary);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
}

.btn-success {
  background: var(--success-light);
  color: var(--success);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 16px 32px;
  font-size: 16px;
}

.btn-block {
  width: 100%;
}

.btn-rounded {
  border-radius: var(--radius-full);
}

/* Button ripple effect */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
  transform: scale(0);
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  border-radius: inherit;
}

.btn:active::after {
  transform: scale(2);
  opacity: 1;
  transition: 0s;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */

.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.form-label-required::after {
  content: ' *';
  color: var(--danger);
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.form-input::placeholder {
  color: var(--text-tertiary);
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-100);
  background: var(--bg-secondary);
}

.form-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.form-input.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-light);
}

.form-input.is-valid {
  border-color: var(--success);
  box-shadow: 0 0 0 3px var(--success-light);
}

.form-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: var(--space-1);
  display: none;
}

.form-input.is-invalid ~ .form-error {
  display: block;
}

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

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.input-group .form-input {
  padding-left: 46px;
}

/* Password toggle */
.password-toggle {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
}

/* ============================================
   OTP INPUT
   ============================================ */

.otp-container {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.otp-input {
  width: 50px;
  height: 56px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  border: 2px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: var(--transition-fast);
  outline: none;
}

.otp-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-100);
}

.otp-input.filled {
  border-color: var(--primary);
  background: var(--primary-50);
}

/* ============================================
   TOGGLES & CHECKBOXES
   ============================================ */

.toggle-switch {
  position: relative;
  width: 50px;
  height: 28px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--border-medium);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-base);
  outline: none;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
  transition: var(--transition-base);
}

.toggle-switch:checked {
  background: var(--primary);
}

.toggle-switch:checked::after {
  left: 25px;
}

/* Modern checkbox */
.checkbox-modern {
  position: relative;
  width: 22px;
  height: 22px;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid var(--border-medium);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.checkbox-modern:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.checkbox-modern:checked::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ============================================
   BOTTOM SHEET / MODAL
   ============================================ */

.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.bottom-sheet-overlay.active {
  opacity: 1;
  visibility: visible;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: var(--content-max-width);
  background: var(--bg-secondary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  z-index: 1001;
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.bottom-sheet.active {
  transform: translateX(-50%) translateY(0);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border-medium);
  border-radius: var(--radius-full);
  margin: 12px auto;
  flex-shrink: 0;
}

.sheet-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  padding-bottom: calc(var(--space-6) + var(--safe-area-bottom));
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-base);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: var(--content-max-width);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-sm .modal {
  max-height: 50vh;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
}

.modal-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: var(--space-3);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
  position: fixed;
  top: calc(var(--header-height) + var(--safe-area-top) + var(--space-3));
  left: 50%;
  transform: translateX(-50%);
  width: 92%;
  max-width: var(--content-max-width);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  animation: toastSlideIn 0.4s var(--transition-spring);
  pointer-events: all;
}

.toast.hiding {
  animation: toastSlideOut 0.3s ease forwards;
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info { border-left: 3px solid var(--info); }

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* ============================================
   SKELETON LOADERS
   ============================================ */

.skeleton {
  background: var(--bg-tertiary);
  background-size: 200% 100%;
  animation: skeletonPulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeletonPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
}

.skeleton-text-lg {
  height: 20px;
  margin-bottom: 12px;
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.skeleton-card {
  height: 120px;
  border-radius: var(--radius-lg);
}

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

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

/* Spacing */
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-3 { padding-top: var(--space-3); padding-bottom: var(--space-3); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }

/* Text */
.text-xs { font-size: 12px; }
.text-sm { font-size: 13px; }
.text-base { font-size: 14px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 20px; }
.text-2xl { font-size: 24px; }
.text-3xl { font-size: 30px; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }

/* Background */
.bg-primary { background: var(--bg-primary); }
.bg-secondary { background: var(--bg-secondary); }

/* Rounded */
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

/* Misc */
.w-full { width: 100%; }
.h-full { height: 100%; }
.hidden { display: none !important; }
.overflow-hidden { overflow: hidden; }

/* ============================================
   PAGE TRANSITIONS
   ============================================ */

.page-enter {
  animation: pageEnter 0.3s ease-out;
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.fade-in {
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.slide-up {
  animation: slideUp 0.4s var(--transition-spring);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   CYCLE PHASE INDICATORS
   ============================================ */

.phase-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
}

.phase-menstrual {
  background: var(--secondary-50);
  color: var(--secondary);
}

.phase-follicular {
  background: #FFF8E1;
  color: #F57F17;
}

.phase-ovulatory {
  background: #E8F5E9;
  color: var(--accent-green);
}

.phase-luteal {
  background: #F3E5F5;
  color: var(--accent-purple);
}

/* ============================================
   PROGRESS RING
   ============================================ */

.progress-ring {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.progress-ring svg {
  transform: rotate(-90deg);
}

.progress-ring-bg {
  fill: none;
  stroke: var(--border-light);
}

.progress-ring-fill {
  fill: none;
  stroke: var(--primary);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s ease;
}

.progress-ring-text {
  position: absolute;
  text-align: center;
}

/* ============================================
   CALENDAR STYLES
   ============================================ */

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  position: relative;
}

.calendar-day:hover {
  background: var(--bg-tertiary);
}

.calendar-day.other-month {
  color: var(--text-tertiary);
}

.calendar-day.today {
  background: var(--primary-50);
  color: var(--primary);
  font-weight: 700;
}

.calendar-day.period {
  background: var(--secondary-50);
  color: var(--secondary);
  font-weight: 600;
}

.calendar-day.fertile {
  background: #E8F5E9;
  color: var(--accent-green);
}

.calendar-day.ovulation {
  background: var(--accent-green);
  color: white;
  font-weight: 700;
}

.calendar-day.predicted {
  border: 2px dashed var(--secondary);
  color: var(--secondary);
}

.calendar-day .day-dot {
  position: absolute;
  bottom: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--primary);
}

/* ============================================
   CHAT BUBBLES (AI Assistant)
   ============================================ */

.chat-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
}

.chat-bubble {
  max-width: 85%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.5;
  animation: messagePop 0.3s var(--transition-spring);
}

@keyframes messagePop {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.chat-bubble-user {
  align-self: flex-end;
  background: var(--gradient-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-bubble-assistant {
  align-self: flex-start;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.chat-bubble-system {
  align-self: center;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 12px;
  text-align: center;
  max-width: 100%;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: var(--space-3) var(--space-4);
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-8px); }
}

/* ============================================
   INSTALL PROMPT
   ============================================ */

.install-prompt {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom) + var(--space-3));
  left: 50%;
  transform: translateX(-50%) translateY(150%);
  width: 92%;
  max-width: 400px;
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  box-shadow: var(--shadow-xl);
  z-index: 900;
  transition: transform 0.5s var(--transition-spring);
}

.install-prompt.show {
  transform: translateX(-50%) translateY(0);
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(107, 76, 230, 0.3); }
  50% { box-shadow: 0 0 0 12px rgba(107, 76, 230, 0); }
}

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

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

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ============================================
   RESPONSIVE (Tablet and up)
   ============================================ */

@media (min-width: 768px) {
  :root {
    --content-max-width: 430px;
  }
  
  .app-container {
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.1);
  }
  
  body {
    background: #e8e5f0;
  }
  
  [data-theme="dark"] body {
    background: #0a0a15;
  }
}

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