/**
 * smsai Global Base Styles
 *
 * Foundation CSS providing resets, global element defaults, and base utilities.
 * This file depends on tokens.css and must be loaded after it.
 *
 * @version 2.0.0
 * @phase Phase 2 - Design Language & Tokens
 * @date 2025-10-10
 *
 * STRUCTURE:
 *   1. Modern CSS Reset
 *   2. Root & Document Defaults
 *   3. Typography (Headings, Paragraphs, Links)
 *   4. Form Elements
 *   5. Button Defaults
 *   6. Accessibility Features
 *   7. Utility Classes
 *   8. Responsive Containers
 *
 * DESIGN APPROACH:
 *   - Mobile-first responsive design
 *   - WCAG AA accessibility compliance
 *   - All values use design tokens via var()
 *   - Zero magic numbers or hardcoded values
 */

/* ============================================================================
   MODERN CSS RESET
   Normalize browser inconsistencies and establish baseline
   ========================================================================= */

/**
 * Use border-box sizing globally for predictable layout calculations
 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/**
 * Reset margins and padding on all elements
 * Prevents browser inconsistencies
 */
* {
  margin: 0;
  padding: 0;
}

/**
 * Prevent horizontal overflow at page level
 */
html,
body {
  overflow-x: hidden;
  max-width: 100%;
}

/**
 * Smooth scrolling for anchor links
 * Respects user's reduced motion preference (handled in tokens.css)
 */
html {
  scroll-behavior: smooth;
}

/**
 * Percentage-based heights for full-page layouts
 */
html,
body {
  height: 100%;
}

/**
 * Improve text rendering
 * Enable font smoothing for better appearance
 */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/**
 * Improve media defaults
 */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/**
 * Remove default list styles
 * Styles should be added semantically where needed
 */
ul,
ol {
  list-style: none;
}

/**
 * Inherit fonts for form controls
 * Ensures consistency across all form elements
 */
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

/**
 * Remove default button styles
 */
button {
  background: none;
  border: none;
  cursor: pointer;
}

/**
 * Avoid text overflows
 */
p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
}

/**
 * Create a root stacking context
 */
#root,
#__next {
  isolation: isolate;
}

/* ============================================================================
   ROOT & DOCUMENT DEFAULTS
   Base typography and color settings using design tokens
   ========================================================================= */

/**
 * Root document styles
 * Sets foundation for entire application
 */
html {
  /* Base font size for rem calculations (1rem = 16px) */
  font-size: 16px;
}

/**
 * Body defaults
 * All values reference design tokens from tokens.css
 */
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);

  /* Minimum height for short content pages */
  min-height: 100vh;
}

/* ============================================================================
   TYPOGRAPHY SYSTEM
   Headings, paragraphs, links, and text elements
   ========================================================================= */

/* --- HEADINGS --- */

/**
 * Base heading styles
 * Shared properties for all heading levels
 */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  color: var(--color-text-primary);
  margin-bottom: var(--space-4);
  letter-spacing: var(--tracking-tight);
}

/**
 * Individual heading sizes
 * Using responsive clamp() values from tokens
 */
h1 {
  font-size: var(--text-4xl);
  margin-bottom: var(--space-6);
  font-weight: var(--font-extrabold);
}

h2 {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-5);
  font-weight: var(--font-bold);
}

h3 {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-4);
}

h4 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-3);
}

h5 {
  font-size: var(--text-lg);
  margin-bottom: var(--space-3);
  font-weight: var(--font-semibold);
}

h6 {
  font-size: var(--text-base);
  margin-bottom: var(--space-2);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

/* --- PARAGRAPHS & TEXT --- */

/**
 * Paragraph spacing
 */
p {
  margin-bottom: var(--space-4);
  line-height: var(--leading-normal);
}

/**
 * Lead paragraph style
 * For introductory text or summaries
 */
p.lead {
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
}

/**
 * Small text
 */
small {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

/**
 * Strong and emphasis
 */
strong,
b {
  font-weight: var(--font-bold);
}

em,
i {
  font-style: italic;
}

/**
 * Mark/highlight text
 */
mark {
  background-color: var(--color-warning-200);
  color: var(--color-text-primary);
  padding: var(--space-0-5) var(--space-1);
  border-radius: var(--radius-sm);
}

/* --- LINKS --- */

/**
 * Default link styles
 * Accessible with clear focus states
 */
a {
  color: var(--color-primary-600);
  text-decoration: none;
  transition: color var(--transition-base) var(--ease-in-out);
}

a:hover {
  color: var(--color-primary-700);
  text-decoration: underline;
}

a:active {
  color: var(--color-primary-800);
}

/**
 * Focus state for keyboard navigation
 * Uses :focus-visible to avoid focus ring on mouse clicks
 */
a:focus-visible {
  outline: var(--focus-outline-width) var(--focus-outline-style) var(--color-border-focus);
  outline-offset: var(--focus-outline-offset);
  border-radius: var(--radius-sm);
}

/**
 * Remove focus outline when not using keyboard
 */
a:focus:not(:focus-visible) {
  outline: none;
}

/**
 * Visited links (optional, can be disabled if needed)
 */
a:visited {
  color: var(--color-primary-700);
}

/* --- LISTS --- */

/**
 * Add list styles back for content areas
 */
article ul,
article ol,
.content ul,
.content ol {
  margin-bottom: var(--space-4);
  padding-left: var(--space-6);
}

article ul,
.content ul {
  list-style-type: disc;
}

article ol,
.content ol {
  list-style-type: decimal;
}

article li,
.content li {
  margin-bottom: var(--space-2);
  line-height: var(--leading-relaxed);
}

article li > ul,
article li > ol,
.content li > ul,
.content li > ol {
  margin-top: var(--space-2);
  margin-bottom: var(--space-2);
}

/* --- CODE & PREFORMATTED TEXT --- */

/**
 * Inline code
 */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: var(--color-gray-100);
  color: var(--color-danger-700);
  padding: var(--space-0-5) var(--space-1);
  border-radius: var(--radius-sm);
  border: var(--border-1) solid var(--color-border-secondary);
}

/**
 * Code blocks
 */
pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background-color: var(--color-gray-900);
  color: var(--color-gray-100);
  padding: var(--space-4);
  border-radius: var(--radius-base);
  overflow-x: auto;
  margin-bottom: var(--space-4);
  border: var(--border-1) solid var(--color-border-primary);
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/**
 * Keyboard input
 */
kbd {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background-color: var(--color-gray-100);
  color: var(--color-text-primary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  border: var(--border-1) solid var(--color-border-primary);
  box-shadow: var(--shadow-xs);
}

/* --- HORIZONTAL RULES --- */

/**
 * Horizontal dividers
 */
hr {
  border: none;
  border-top: var(--border-1) solid var(--color-border-secondary);
  margin: var(--space-8) 0;
}

/* --- BLOCKQUOTES --- */

/**
 * Quote styling
 */
blockquote {
  border-left: var(--border-4) solid var(--color-primary-600);
  padding: var(--space-4) var(--space-6);
  margin: var(--space-6) 0;
  background-color: var(--color-bg-tertiary);
  border-radius: var(--radius-base);
}

blockquote p {
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
  font-style: italic;
}

blockquote cite {
  display: block;
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-style: normal;
}

blockquote cite::before {
  content: "— ";
}

/* ============================================================================
   FORM ELEMENTS
   Inputs, textareas, selects with consistent styling and accessibility
   ========================================================================= */

/**
 * Base form element styles
 * Shared across input, textarea, select
 */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="week"],
input[type="time"],
textarea,
select {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  border: var(--border-1) solid var(--color-border-primary);
  border-radius: var(--radius-base);
  transition: border-color var(--transition-base) var(--ease-in-out),
              box-shadow var(--transition-base) var(--ease-in-out);

  /* Minimum touch target for mobile accessibility */
  min-height: var(--touch-target-min);
}

/**
 * Hover state for form elements
 */
input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="search"]:hover,
input[type="tel"]:hover,
input[type="url"]:hover,
input[type="number"]:hover,
input[type="date"]:hover,
input[type="datetime-local"]:hover,
input[type="month"]:hover,
input[type="week"]:hover,
input[type="time"]:hover,
textarea:hover,
select:hover {
  border-color: var(--color-border-focus);
}

/**
 * Focus state with accessible ring
 * WCAG AA compliant focus indicator
 */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="month"]:focus,
input[type="week"]:focus,
input[type="time"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: var(--ring-primary);
}

/**
 * Disabled state
 */
input[type="text"]:disabled,
input[type="email"]:disabled,
input[type="password"]:disabled,
input[type="search"]:disabled,
input[type="tel"]:disabled,
input[type="url"]:disabled,
input[type="number"]:disabled,
input[type="date"]:disabled,
input[type="datetime-local"]:disabled,
input[type="month"]:disabled,
input[type="week"]:disabled,
input[type="time"]:disabled,
textarea:disabled,
select:disabled {
  background-color: var(--color-bg-tertiary);
  color: var(--color-text-muted);
  cursor: not-allowed;
  opacity: 0.6;
}

/**
 * Placeholder text styling
 */
::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}

:-ms-input-placeholder {
  color: var(--color-text-muted);
}

::-ms-input-placeholder {
  color: var(--color-text-muted);
}

/**
 * Textarea specific styles
 */
textarea {
  min-height: 120px;
  resize: vertical;
}

/**
 * Select dropdown specific styles
 */
select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  padding-right: var(--space-10);
}

/**
 * Checkboxes and radio buttons
 */
input[type="checkbox"],
input[type="radio"] {
  width: var(--space-5);
  height: var(--space-5);
  min-height: auto;
  margin-right: var(--space-2);
  cursor: pointer;
  accent-color: var(--color-primary-600);
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: var(--focus-outline-width) var(--focus-outline-style) var(--color-border-focus);
  outline-offset: var(--focus-outline-offset);
}

/**
 * Form labels
 */
label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

/**
 * Required field indicator
 */
label.required::after {
  content: " *";
  color: var(--color-danger-600);
}

/**
 * Form field wrapper
 */
.form-group {
  margin-bottom: var(--space-6);
}

/**
 * Form helper text
 */
.form-help {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/**
 * Form validation states
 */
.form-error {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-danger-700);
}

input.is-invalid,
textarea.is-invalid,
select.is-invalid {
  border-color: var(--color-danger-600);
}

input.is-invalid:focus,
textarea.is-invalid:focus,
select.is-invalid:focus {
  box-shadow: var(--ring-danger);
}

input.is-valid,
textarea.is-valid,
select.is-valid {
  border-color: var(--color-success-600);
}

input.is-valid:focus,
textarea.is-valid:focus,
select.is-valid:focus {
  box-shadow: var(--ring-success);
}

/* ============================================================================
   BUTTON DEFAULTS
   Base button styles (component-specific styles in components.css)
   ========================================================================= */

/**
 * Base button reset and defaults
 */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);

  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  line-height: var(--leading-normal);
  text-align: center;
  text-decoration: none;
  white-space: nowrap;

  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-base);
  border: var(--border-1) solid transparent;

  cursor: pointer;
  user-select: none;

  /* Ensure minimum touch target size for mobile accessibility */
  min-height: var(--touch-target-min);

  transition: background-color var(--transition-base) var(--ease-in-out),
              border-color var(--transition-base) var(--ease-in-out),
              color var(--transition-base) var(--ease-in-out),
              box-shadow var(--transition-base) var(--ease-in-out),
              transform var(--transition-base) var(--ease-in-out);
}

/**
 * Focus state for buttons (keyboard navigation)
 */
button:focus-visible,
.btn:focus-visible {
  outline: var(--focus-outline-width) var(--focus-outline-style) var(--color-border-focus);
  outline-offset: var(--focus-outline-offset);
}

button:focus:not(:focus-visible),
.btn:focus:not(:focus-visible) {
  outline: none;
}

/**
 * Active/pressed state
 */
button:active:not(:disabled),
.btn:active:not(:disabled) {
  transform: translateY(1px);
}

/**
 * Disabled button state
 */
button:disabled,
button.disabled,
.btn:disabled,
.btn.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============================================================================
   ACCESSIBILITY FEATURES
   Screen readers, focus management, reduced motion
   ========================================================================= */

/**
 * Screen reader only content
 * Visually hidden but available to assistive technology
 */
.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;
}

/**
 * Focusable screen reader content
 * Becomes visible when focused (for skip links)
 */
.sr-only-focusable:focus,
.sr-only-focusable:active {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/**
 * Skip to main content link
 * Appears at top of page when focused
 */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  z-index: var(--z-tooltip);

  padding: var(--space-3) var(--space-6);
  background-color: var(--color-primary-600);
  color: var(--color-text-inverse);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-base);
  text-decoration: none;

  transition: top var(--transition-base) var(--ease-out);
}

.skip-link:focus {
  top: var(--space-4);
  outline: var(--focus-outline-width) var(--focus-outline-style) var(--color-text-inverse);
  outline-offset: var(--focus-outline-offset);
}

/**
 * Reduce motion for users who prefer it
 * Honors prefers-reduced-motion media query
 * Phase 7: Enhanced accessibility support
 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    /* Disable all animations and transitions for accessibility */
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  /* Remove transform transitions that could cause motion sickness */
  button:active:not(:disabled),
  .btn:active:not(:disabled) {
    transform: none !important;
  }
}

/**
 * Focus visible polyfill support
 * For browsers that don't support :focus-visible
 */
.js-focus-visible :focus:not(.focus-visible) {
  outline: none;
}

/* ============================================================================
   UTILITY CLASSES
   Common helper classes for layout and visibility
   ========================================================================= */

/* --- VISIBILITY UTILITIES --- */

/**
 * Hidden element (display: none)
 */
.hidden {
  display: none !important;
}

/**
 * Visually hidden (screen readers can still access)
 */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/**
 * Invisible (occupies space but not visible)
 */
.invisible {
  visibility: hidden;
}

/* --- RESPONSIVE VISIBILITY --- */

/**
 * Show only on mobile (< 768px)
 */
.visible-mobile {
  display: block;
}

@media (min-width: 768px) {
  .visible-mobile {
    display: none !important;
  }
}

/**
 * Hide on mobile (< 768px)
 */
.hidden-mobile {
  display: none;
}

@media (min-width: 768px) {
  .hidden-mobile {
    display: block;
  }
}

/**
 * Show only on tablet and up (>= 768px)
 */
.visible-tablet {
  display: none;
}

@media (min-width: 768px) {
  .visible-tablet {
    display: block;
  }
}

/**
 * Show only on desktop and up (>= 1024px)
 */
.visible-desktop {
  display: none;
}

@media (min-width: 1024px) {
  .visible-desktop {
    display: block;
  }
}

/* --- TEXT UTILITIES --- */

/**
 * Text alignment
 */
.text-left {
  text-align: left;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-justify {
  text-align: justify;
}

/**
 * Text transformation
 */
.text-uppercase {
  text-transform: uppercase;
}

.text-lowercase {
  text-transform: lowercase;
}

.text-capitalize {
  text-transform: capitalize;
}

/**
 * Font weights
 */
.font-light {
  font-weight: var(--font-light);
}

.font-normal {
  font-weight: var(--font-normal);
}

.font-medium {
  font-weight: var(--font-medium);
}

.font-semibold {
  font-weight: var(--font-semibold);
}

.font-bold {
  font-weight: var(--font-bold);
}

/**
 * Text colors
 */
.text-primary {
  color: var(--color-text-primary);
}

.text-secondary {
  color: var(--color-text-secondary);
}

.text-muted {
  color: var(--color-text-muted);
}

.text-success {
  color: var(--color-success-700);
}

.text-danger {
  color: var(--color-danger-700);
}

.text-warning {
  color: var(--color-warning-700);
}

.text-info {
  color: var(--color-info-700);
}

/**
 * Text truncation
 */
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/**
 * Line clamp (multi-line truncation)
 */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- SPACING UTILITIES --- */

/**
 * Margin utilities (using spacing tokens)
 */
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mr-0 { margin-right: 0; }
.mb-0 { margin-bottom: 0; }
.ml-0 { margin-left: 0; }

.m-auto { margin: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }
.my-auto { margin-top: auto; margin-bottom: auto; }

/**
 * Padding utilities
 */
.p-0 { padding: 0; }
.pt-0 { padding-top: 0; }
.pr-0 { padding-right: 0; }
.pb-0 { padding-bottom: 0; }
.pl-0 { padding-left: 0; }

/* --- DISPLAY UTILITIES --- */

.d-none { display: none; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }
.d-grid { display: grid; }

/* --- FLEXBOX UTILITIES --- */

.flex-row { flex-direction: row; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }

.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }

.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.items-center { align-items: center; }
.items-baseline { align-items: baseline; }
.items-stretch { align-items: stretch; }

.flex-1 { flex: 1 1 0%; }
.flex-auto { flex: 1 1 auto; }
.flex-none { flex: none; }

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* ============================================================================
   CONTAINER & LAYOUT
   Responsive containers and page layout structure
   ========================================================================= */

/**
 * Main container
 * Responsive max-width with centered content
 */
.container {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

/* Responsive container widths */
@media (min-width: 640px) {
  .container {
    max-width: var(--container-sm);
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
}

@media (min-width: 768px) {
  .container {
    max-width: var(--container-md);
  }
}

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

@media (min-width: 1280px) {
  .container {
    max-width: var(--container-xl);
  }
}

@media (min-width: 1536px) {
  .container {
    max-width: var(--container-2xl);
  }
}

/**
 * Fluid container (full width with padding)
 */
.container-fluid {
  width: 100%;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

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

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

/**
 * Section spacing
 * Consistent vertical rhythm for page sections
 */
.section {
  padding-top: var(--space-12);
  padding-bottom: var(--space-12);
}

@media (min-width: 768px) {
  .section {
    padding-top: var(--space-16);
    padding-bottom: var(--space-16);
  }
}

@media (min-width: 1024px) {
  .section {
    padding-top: var(--space-24);
    padding-bottom: var(--space-24);
  }
}

/* ============================================================================
   TABLES
   Accessible and responsive table styles
   ========================================================================= */

/**
 * Base table styles
 */
table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  margin-bottom: var(--space-6);
}

/**
 * Table headers
 */
thead {
  background-color: var(--color-bg-tertiary);
  border-bottom: var(--border-2) solid var(--color-border-primary);
}

th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

/**
 * Table cells
 */
td {
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-1) solid var(--color-border-secondary);
}

/**
 * Table row hover
 */
tbody tr:hover {
  background-color: var(--color-bg-tertiary);
}

/**
 * Responsive table wrapper
 * Adds horizontal scroll on mobile
 */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================================
   PRINT STYLES
   Optimized styles for printing
   ========================================================================= */

@media print {
  /**
   * Reset colors for print
   */
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  /**
   * Ensure links are underlined
   */
  a,
  a:visited {
    text-decoration: underline;
  }

  /**
   * Show URLs after links
   */
  a[href]::after {
    content: " (" attr(href) ")";
  }

  /**
   * Don't show URLs for fragment identifiers or javascript
   */
  a[href^="#"]::after,
  a[href^="javascript:"]::after {
    content: "";
  }

  /**
   * Page breaks
   */
  pre,
  blockquote,
  tr,
  img,
  h1,
  h2,
  h3 {
    page-break-inside: avoid;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    page-break-after: avoid;
  }

  p,
  h2,
  h3 {
    orphans: 3;
    widows: 3;
  }

  /**
   * Hide non-essential elements
   */
  nav,
  aside,
  .no-print {
    display: none !important;
  }

  /**
   * Ensure images fit page width
   */
  img {
    max-width: 100% !important;
  }

  /**
   * Add borders to tables
   */
  thead {
    display: table-header-group;
  }

  table {
    border-collapse: collapse;
  }

  th,
  td {
    border: 1px solid #ddd;
  }
}
