/**
 * DESIGN TOKENS - SISTEMA DE DISEÑO PROFESIONAL
 * Tokens semánticos para modo claro y oscuro
 * Inspirado en Facebook, Twitter, Instagram, LinkedIn
 * 
 * @author MrGreen Development Team
 * @version 2.0.0
 * @since 2025-01-08
 */

/* ===== TOKENS BASE (MODO CLARO) ===== */
:root {
  /* ===== COLORES SEMÁNTICOS ===== */
  --color-primary: #ff0050;
  --color-primary-hover: #e6004a;
  --color-primary-active: #cc0040;
  --color-primary-light: #ff4d7a;
  --color-primary-dark: #b30036;
  
  --color-secondary: #00c800;
  --color-secondary-hover: #00b300;
  --color-secondary-active: #009900;
  --color-secondary-light: #33d633;
  --color-secondary-dark: #006600;
  
  --color-accent: #00d4ff;
  --color-accent-hover: #00b8e6;
  --color-accent-active: #0099cc;
  --color-accent-light: #33ddff;
  --color-accent-dark: #007a99;
  
  /* ===== SUPERFICIES (SURFACES) ===== */
  --color-surface-primary: #ffffff;
  --color-surface-secondary: #f8f9fa;
  --color-surface-tertiary: #f1f3f4;
  --color-surface-quaternary: #e8eaed;
  --color-surface-elevated: #ffffff;
  --color-surface-overlay: rgba(0, 0, 0, 0.4);
  
  /* ===== TEXTO ===== */
  --color-text-primary: #1a1a1a;
  --color-text-secondary: #5f6368;
  --color-text-tertiary: #9aa0a6;
  --color-text-quaternary: #dadce0;
  --color-text-inverse: #ffffff;
  --color-text-link: #1a73e8;
  --color-text-link-hover: #1557b0;
  
  /* ===== BORDES ===== */
  --color-border-primary: #dadce0;
  --color-border-secondary: #e8eaed;
  --color-border-tertiary: #f1f3f4;
  --color-border-focus: #ff0050;
  --color-border-error: #ea4335;
  --color-border-success: #34a853;
  --color-border-warning: #fbbc04;
  
  /* ===== ESTADOS ===== */
  --color-state-hover: rgba(0, 0, 0, 0.04);
  --color-state-active: rgba(0, 0, 0, 0.08);
  --color-state-selected: rgba(255, 0, 80, 0.1);
  --color-state-disabled: rgba(0, 0, 0, 0.12);
  
  /* ===== SOMBRAS ===== */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);
  --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.15);
  
  /* ===== TRANSICIONES ===== */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 300ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
  
  /* ===== TIPOGRAFÍA ===== */
  --font-family-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-secondary: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-mono: 'Fira Code', 'Monaco', 'Cascadia Code', monospace;
  
  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg: 1.125rem;   /* 18px */
  --font-size-xl: 1.25rem;    /* 20px */
  --font-size-2xl: 1.5rem;    /* 24px */
  --font-size-3xl: 1.875rem;  /* 30px */
  --font-size-4xl: 2.25rem;   /* 36px */
  --font-size-5xl: 3rem;      /* 48px */
  
  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;
  
  --line-height-tight: 1.25;
  --line-height-snug: 1.375;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.625;
  --line-height-loose: 2;
  
  /* ===== ESPACIADO ===== */
  --space-0: 0;
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;     /* 80px */
  --space-24: 6rem;     /* 96px */
  --space-32: 8rem;     /* 128px */
  
  /* ===== BORDES ===== */
  --border-radius-none: 0;
  --border-radius-xs: 0.125rem;   /* 2px */
  --border-radius-sm: 0.25rem;    /* 4px */
  --border-radius-md: 0.375rem;   /* 6px */
  --border-radius-lg: 0.5rem;     /* 8px */
  --border-radius-xl: 0.75rem;    /* 12px */
  --border-radius-2xl: 1rem;      /* 16px */
  --border-radius-3xl: 1.5rem;    /* 24px */
  --border-radius-full: 9999px;
  
  /* ===== Z-INDEX ===== */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
  --z-toast: 1080;
  --z-header: 10000;
  
  /* ===== BREAKPOINTS ===== */
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;
}

/* ===== PREVENIR FLASH DE MODO CLARO ===== */
/* Aplicar modo oscuro inmediatamente si está en localStorage */
html:has(body.dark-mode),
html.dark-mode {
  color-scheme: dark;
}

/* Estilos críticos para prevenir flash */
.dark-mode body,
.dark-mode html {
  background: #0f0f0f !important;
  color: #e4e6eb !important;
}

/* ===== TOKENS MODO OSCURO ===== */
.dark-mode {
  /* ===== SUPERFICIES (SURFACES) ===== */
  --color-surface-primary: #0f0f0f;
  --color-surface-secondary: #161823;
  --color-surface-tertiary: #1e1e1e;
  --color-surface-quaternary: #2a2a2a;
  --color-surface-elevated: #1e1e1e;
  --color-surface-overlay: rgba(0, 0, 0, 0.85);
  
  /* ===== TEXTO ===== */
  --color-text-primary: #e4e6eb;
  --color-text-secondary: #b0b3b8;
  --color-text-tertiary: #8e8e93;
  --color-text-quaternary: #6b7280;
  --color-text-inverse: #1a1a1a;
  --color-text-link: #4a9eff;
  --color-text-link-hover: #6bb6ff;
  
  /* ===== BORDES ===== */
  --color-border-primary: #3a3b3c;
  --color-border-secondary: #4e4f50;
  --color-border-tertiary: #5f6368;
  --color-border-focus: #ff0050;
  --color-border-error: #ff6b6b;
  --color-border-success: #4ade80;
  --color-border-warning: #fbbf24;
  
  /* ===== ESTADOS ===== */
  --color-state-hover: rgba(255, 255, 255, 0.1);
  --color-state-active: rgba(255, 255, 255, 0.2);
  --color-state-selected: rgba(255, 0, 80, 0.2);
  --color-state-disabled: rgba(255, 255, 255, 0.12);
  
  /* ===== SOMBRAS ===== */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.5);
  --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.6);
}

/* ===== TRANSICIONES GLOBALES ===== */
* {
  transition: 
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast),
    box-shadow var(--transition-fast);
}

/* ===== TRANSICIONES ESPECÍFICAS PARA CAMBIO DE TEMA ===== */
.theme-transitioning * {
  transition: 
    background-color var(--transition-normal),
    border-color var(--transition-normal),
    color var(--transition-normal),
    box-shadow var(--transition-normal),
    transform var(--transition-normal) !important;
}

/* ===== ANIMACIONES DE CAMBIO DE TEMA ===== */
@keyframes themeFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.theme-transitioning .card,
.theme-transitioning .feed-card,
.theme-transitioning .activity-card {
  animation: themeFadeIn var(--transition-normal) ease-out;
}

/* ===== ELEMENTOS QUE NO DEBEN TRANSICIONAR ===== */
*:before,
*:after,
svg,
img,
video,
canvas,
iframe,
object,
embed,
.theme-transitioning *:before,
.theme-transitioning *:after {
  transition: none !important;
}
