/**
 * EC Core CSS - Modern Design System
 * 
 * Base do sistema de design moderno do Expresso Cadastro
 * Contém design tokens, reset CSS, e elementos fundamentais
 * 
 * @version 3.0.0
 * @since 2024
 */

/* ===== DESIGN TOKENS - CORE SYSTEM ===== */

:root {
  /* === COLORS === */
  /* Primary Brand Colors */
  --ec-primary: #f08000;
  --ec-primary-50: #fef7f0;
  --ec-primary-100: #fdeadb;
  --ec-primary-200: #fbd3b8;
  --ec-primary-300: #f8b584;
  --ec-primary-400: #f49050;
  --ec-primary-500: #f08000; /* Base */
  --ec-primary-600: #e67300;
  --ec-primary-700: #cc6600;
  --ec-primary-800: #b35900;
  --ec-primary-900: #994d00;

  /* Semantic Colors */
  --ec-success: #10b981;
  --ec-success-light: #d1fae5;
  --ec-success-dark: #047857;
  
  --ec-error: #ef4444;
  --ec-error-light: #fee2e2;
  --ec-error-dark: #dc2626;
  
  --ec-warning: #f59e0b;
  --ec-warning-light: #fef3c7;
  --ec-warning-dark: #d97706;
  
  --ec-info: var(--ec-primary, #f08000);
  --ec-info-light: #dbeafe;
  --ec-info-dark: var(--ec-primary, #f08000);

  /* Neutral Colors */
  --ec-gray-50: #f9fafb;
  --ec-gray-100: #f3f4f6;
  --ec-gray-200: #e5e7eb;
  --ec-gray-300: #d1d5db;
  --ec-gray-400: #9ca3af;
  --ec-gray-500: #6b7280;
  --ec-gray-600: #4b5563;
  --ec-gray-700: #374151;
  --ec-gray-800: #1f2937;
  --ec-gray-900: #111827;

  /* Text Colors */
  --ec-text-primary: var(--ec-gray-900);
  --ec-text-secondary: var(--ec-gray-700);
  --ec-text-muted: var(--ec-gray-500);
  --ec-text-disabled: var(--ec-gray-400);
  --ec-text-inverse: #ffffff;

  /* Background Colors */
  --ec-bg-primary: #ffffff;
  --ec-bg-secondary: var(--ec-gray-50);
  --ec-bg-tertiary: var(--ec-gray-100);
  --ec-bg-overlay: rgba(0, 0, 0, 0.5);

  /* Border Colors */
  --ec-border-primary: var(--ec-gray-300);
  --ec-border-secondary: var(--ec-gray-200);
  --ec-border-focus: var(--ec-primary);
  --ec-border-error: var(--ec-error);

  /* === SPACING SCALE === */
  --ec-space-0: 0;
  --ec-space-px: 1px;
  --ec-space-0_5: 2px;
  --ec-space-1: 4px;
  --ec-space-1_5: 6px;
  --ec-space-2: 8px;
  --ec-space-2_5: 10px;
  --ec-space-3: 12px;
  --ec-space-3_5: 14px;
  --ec-space-4: 16px;
  --ec-space-5: 20px;
  --ec-space-6: 24px;
  --ec-space-7: 28px;
  --ec-space-8: 32px;
  --ec-space-9: 36px;
  --ec-space-10: 40px;
  --ec-space-12: 48px;
  --ec-space-16: 64px;
  --ec-space-20: 80px;
  --ec-space-24: 96px;

  /* === TYPOGRAPHY === */
  /* Font Families */
  --ec-font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --ec-font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;

  /* Font Sizes */
  --ec-text-xs: 12px;
  --ec-text-sm: 14px;
  --ec-text-base: 16px;
  --ec-text-lg: 18px;
  --ec-text-xl: 20px;
  --ec-text-2xl: 24px;
  --ec-text-3xl: 30px;
  --ec-text-4xl: 36px;

  /* Font Weights */
  --ec-font-light: 300;
  --ec-font-normal: 400;
  --ec-font-medium: 500;
  --ec-font-semibold: 600;
  --ec-font-bold: 700;

  /* Line Heights */
  --ec-line-tight: 1.25;
  --ec-line-normal: 1.5;
  --ec-line-relaxed: 1.625;
  --ec-line-loose: 2;

  /* === SIZING === */
  /* Border Radius */
  --ec-radius-none: 0;
  --ec-radius-sm: 2px;
  --ec-radius: 4px;
  --ec-radius-md: 6px;
  --ec-radius-lg: 8px;
  --ec-radius-xl: 12px;
  --ec-radius-2xl: 16px;
  --ec-radius-full: 9999px;

  /* Box Shadows */
  --ec-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --ec-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --ec-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --ec-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --ec-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --ec-shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);

  /* Z-Index Scale */
  --ec-z-base: 0;
  --ec-z-docked: 10;
  --ec-z-dropdown: 1000;
  --ec-z-sticky: 1020;
  --ec-z-banner: 1030;
  --ec-z-overlay: 1040;
  --ec-z-modal: 1050;
  --ec-z-popover: 1060;
  --ec-z-tooltip: 1070;
  --ec-z-toast: 1080;

  /* === TRANSITIONS === */
  --ec-transition-fast: 150ms ease;
  --ec-transition-normal: 300ms ease;
  --ec-transition-slow: 500ms ease;

  /* Easing Functions */
  --ec-ease-linear: linear;
  --ec-ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ec-ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ec-ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* === BREAKPOINTS (for reference) === */
  --ec-screen-sm: 640px;
  --ec-screen-md: 768px;
  --ec-screen-lg: 1024px;
  --ec-screen-xl: 1280px;
  --ec-screen-2xl: 1536px;

  /* === COMPONENT SPECIFIC === */
  /* Form Controls */
  --ec-form-height: 40px;
  --ec-form-height-sm: 32px;
  --ec-form-height-lg: 48px;
  --ec-form-border-width: 1px;
  --ec-form-focus-ring: 0 0 0 3px var(--ec-primary-100);

  /* Buttons */
  --ec-btn-height: 40px;
  --ec-btn-height-sm: 32px;
  --ec-btn-height-lg: 48px;
  --ec-btn-padding-x: var(--ec-space-4);
  --ec-btn-padding-y: var(--ec-space-2);

  /* Cards */
  --ec-card-padding: var(--ec-space-6);
  --ec-card-radius: var(--ec-radius-lg);
  --ec-card-shadow: var(--ec-shadow);

  /* Modals */
  --ec-modal-backdrop: rgba(0, 0, 0, 0.5);
  --ec-modal-radius: var(--ec-radius-xl);
  --ec-modal-shadow: var(--ec-shadow-xl);
}

/* ===== MODERN CSS RESET ===== */

/* Box sizing rules */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Prevent font size inflation */
html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

/* Remove default margin in favour of better control in authored CSS */
body, h1, h2, h3, h4, p,
figure, blockquote, dl, dd {
  margin-block-end: 0;
}

/* Remove list styles on ul, ol elements with a list role */
ul[role='list'],
ol[role='list'] {
  list-style: none;
}

/* Set core body defaults */
body {
  min-height: 100vh;
  line-height: var(--ec-line-normal);
  font-family: var(--ec-font-sans);
  font-size: var(--ec-text-base);
  color: var(--ec-text-primary);
  background-color: var(--ec-bg-primary);
}

/* Set shorter line heights on headings and interactive elements */
h1, h2, h3, h4,
button, input, label {
  line-height: var(--ec-line-tight);
}

/* Balance text wrapping on headings */
h1, h2, h3, h4 {
  text-wrap: balance;
}

/* A elements that don't have a class get default styles */
a:not([class]) {
  text-decoration-skip-ink: auto;
  color: currentColor;
}

/* Make images easier to work with */
img,
picture {
  max-width: 100%;
  display: block;
}

/* Inherit fonts for inputs and buttons */
input, button,
textarea, select {
  font: inherit;
}

/* Make sure textareas without a rows attribute are not tiny */
textarea:not([rows]) {
  min-height: 10em;
}

/* Anything that has been anchored to should have extra scroll margin */
:target {
  scroll-margin-block: 5ex;
}

/* ===== FOCUS MANAGEMENT ===== */

/* Focus styles for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--ec-primary);
  outline-offset: 2px;
}

/* Remove focus for mouse/touch interactions */
:focus:not(:focus-visible) {
  outline: none;
}

/* ===== UTILITY CLASSES ===== */

/* Screen Reader Only */
.ec-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Layout Utilities */
.ec-container {
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--ec-space-4);
  padding-right: var(--ec-space-4);
}

.ec-container-sm {
  max-width: 640px;
}

.ec-container-md {
  max-width: 768px;
}

.ec-container-lg {
  max-width: 1024px;
}

/* Flexbox Utilities */
.ec-flex {
  display: flex;
}

.ec-flex-col {
  flex-direction: column;
}

.ec-flex-wrap {
  flex-wrap: wrap;
}

.ec-items-center {
  align-items: center;
}

.ec-items-start {
  align-items: flex-start;
}

.ec-items-end {
  align-items: flex-end;
}

.ec-justify-center {
  justify-content: center;
}

.ec-justify-between {
  justify-content: space-between;
}

.ec-justify-end {
  justify-content: flex-end;
}

.ec-gap-1 { gap: var(--ec-space-1); }
.ec-gap-2 { gap: var(--ec-space-2); }
.ec-gap-3 { gap: var(--ec-space-3); }
.ec-gap-4 { gap: var(--ec-space-4); }
.ec-gap-6 { gap: var(--ec-space-6); }
.ec-gap-8 { gap: var(--ec-space-8); }

/* Grid Utilities */
.ec-grid {
  display: grid;
}

.ec-grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.ec-grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ec-grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ec-grid-cols-auto { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* Spacing Utilities */
.ec-m-0 { margin: 0; }
.ec-m-1 { margin: var(--ec-space-1); }
.ec-m-2 { margin: var(--ec-space-2); }
.ec-m-3 { margin: var(--ec-space-3); }
.ec-m-4 { margin: var(--ec-space-4); }
.ec-m-6 { margin: var(--ec-space-6); }
.ec-m-8 { margin: var(--ec-space-8); }

.ec-mt-0 { margin-top: 0; }
.ec-mt-1 { margin-top: var(--ec-space-1); }
.ec-mt-2 { margin-top: var(--ec-space-2); }
.ec-mt-3 { margin-top: var(--ec-space-3); }
.ec-mt-4 { margin-top: var(--ec-space-4); }
.ec-mt-6 { margin-top: var(--ec-space-6); }
.ec-mt-8 { margin-top: var(--ec-space-8); }

.ec-mb-0 { margin-bottom: 0; }
.ec-mb-1 { margin-bottom: var(--ec-space-1); }
.ec-mb-2 { margin-bottom: var(--ec-space-2); }
.ec-mb-3 { margin-bottom: var(--ec-space-3); }
.ec-mb-4 { margin-bottom: var(--ec-space-4); }
.ec-mb-6 { margin-bottom: var(--ec-space-6); }
.ec-mb-8 { margin-bottom: var(--ec-space-8); }

.ec-p-0 { padding: 0; }
.ec-p-1 { padding: var(--ec-space-1); }
.ec-p-2 { padding: var(--ec-space-2); }
.ec-p-3 { padding: var(--ec-space-3); }
.ec-p-4 { padding: var(--ec-space-4); }
.ec-p-6 { padding: var(--ec-space-6); }
.ec-p-8 { padding: var(--ec-space-8); }

/* Text Utilities */
.ec-text-xs { font-size: var(--ec-text-xs); }
.ec-text-sm { font-size: var(--ec-text-sm); }
.ec-text-base { font-size: var(--ec-text-base); }
.ec-text-lg { font-size: var(--ec-text-lg); }
.ec-text-xl { font-size: var(--ec-text-xl); }
.ec-text-2xl { font-size: var(--ec-text-2xl); }

.ec-font-light { font-weight: var(--ec-font-light); }
.ec-font-normal { font-weight: var(--ec-font-normal); }
.ec-font-medium { font-weight: var(--ec-font-medium); }
.ec-font-semibold { font-weight: var(--ec-font-semibold); }
.ec-font-bold { font-weight: var(--ec-font-bold); }

.ec-text-left { text-align: left; }
.ec-text-center { text-align: center; }
.ec-text-right { text-align: right; }

.ec-text-primary { color: var(--ec-text-primary); }
.ec-text-secondary { color: var(--ec-text-secondary); }
.ec-text-muted { color: var(--ec-text-muted); }
.ec-text-success { color: var(--ec-success); }
.ec-text-error { color: var(--ec-error); }
.ec-text-warning { color: var(--ec-warning); }

/* Background Utilities */
.ec-bg-primary { background-color: var(--ec-bg-primary); }
.ec-bg-secondary { background-color: var(--ec-bg-secondary); }
.ec-bg-success { background-color: var(--ec-success-light); }
.ec-bg-error { background-color: var(--ec-error-light); }
.ec-bg-warning { background-color: var(--ec-warning-light); }

/* Border Utilities */
.ec-border { border: 1px solid var(--ec-border-primary); }
.ec-border-t { border-top: 1px solid var(--ec-border-primary); }
.ec-border-r { border-right: 1px solid var(--ec-border-primary); }
.ec-border-b { border-bottom: 1px solid var(--ec-border-primary); }
.ec-border-l { border-left: 1px solid var(--ec-border-primary); }

.ec-rounded { border-radius: var(--ec-radius); }
.ec-rounded-md { border-radius: var(--ec-radius-md); }
.ec-rounded-lg { border-radius: var(--ec-radius-lg); }
.ec-rounded-xl { border-radius: var(--ec-radius-xl); }
.ec-rounded-full { border-radius: var(--ec-radius-full); }

/* Shadow Utilities */
.ec-shadow { box-shadow: var(--ec-shadow); }
.ec-shadow-md { box-shadow: var(--ec-shadow-md); }
.ec-shadow-lg { box-shadow: var(--ec-shadow-lg); }
.ec-shadow-xl { box-shadow: var(--ec-shadow-xl); }

/* ===== DARK MODE SUPPORT ===== */

@media (prefers-color-scheme: dark) {
  :root {
    --ec-text-primary: var(--ec-gray-100);
    --ec-text-secondary: var(--ec-gray-300);
    --ec-text-muted: var(--ec-gray-400);
    --ec-text-disabled: var(--ec-gray-500);
    
    --ec-bg-primary: var(--ec-gray-900);
    --ec-bg-secondary: var(--ec-gray-800);
    --ec-bg-tertiary: var(--ec-gray-700);
    
    --ec-border-primary: var(--ec-gray-600);
    --ec-border-secondary: var(--ec-gray-700);
  }
}

/* ===== HIGH CONTRAST MODE ===== */

@media (prefers-contrast: high) {
  :root {
    --ec-border-primary: currentColor;
    --ec-border-secondary: currentColor;
  }
  
  .ec-border,
  .ec-border-t,
  .ec-border-r,
  .ec-border-b,
  .ec-border-l {
    border-width: 2px;
  }
}

/* ===== REDUCED MOTION ===== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== PRINT STYLES ===== */

@media print {
  :root {
    --ec-text-primary: #000;
    --ec-text-secondary: #333;
    --ec-bg-primary: #fff;
    --ec-border-primary: #000;
  }
  
  .ec-shadow,
  .ec-shadow-md,
  .ec-shadow-lg,
  .ec-shadow-xl {
    box-shadow: none !important;
  }
}