/* ===== ORION DESIGN SYSTEM - MAIN ENTRY POINT ===== */

/* Import Design Tokens */
@import './tokens.css';

/* Import Component Styles */
@import './components/button.css';
@import './components/form.css';
@import './components/modal.css';
@import './components/table.css';
@import './components/card.css';
@import './components/alert.css';
@import './components/badge.css';
@import './components/navigation.css';

/* ===== ORION BASE STYLES ===== */

/* Reset and normalize */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  background: var(--surface-primary);
}

body {
  margin: 0 !important;
  padding: 0 !important;
  background: var(--surface-primary);
  color: var(--text-primary);
  font-family: var(--font-family-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.5;
  background-color: var(--color-bg);
}

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

/* Spacing Utilities */
.m-0 { margin: 0; }
.m-1 { margin: var(--space-xs); }
.m-2 { margin: var(--space-sm); }
.m-3 { margin: var(--space-md); }
.m-4 { margin: var(--space-lg); }
.m-5 { margin: var(--space-xl); }

.p-0 { padding: 0; }
.p-1 { padding: var(--space-xs); }
.p-2 { padding: var(--space-sm); }
.p-3 { padding: var(--space-md); }
.p-4 { padding: var(--space-lg); }
.p-5 { padding: var(--space-xl); }

.mb-1 { margin-bottom: var(--space-xs); }
.mb-2 { margin-bottom: var(--space-sm); }
.mb-3 { margin-bottom: var(--space-md); }
.mb-4 { margin-bottom: var(--space-lg); }
.mb-5 { margin-bottom: var(--space-xl); }

.mt-1 { margin-top: var(--space-xs); }
.mt-2 { margin-top: var(--space-sm); }
.mt-3 { margin-top: var(--space-md); }
.mt-4 { margin-top: var(--space-lg); }
.mt-5 { margin-top: var(--space-xl); }

.mr-1 { margin-right: var(--space-xs); }
.mr-2 { margin-right: var(--space-sm); }
.mr-3 { margin-right: var(--space-md); }
.mr-4 { margin-right: var(--space-lg); }
.mr-5 { margin-right: var(--space-xl); }

.ml-1 { margin-left: var(--space-xs); }
.ml-2 { margin-left: var(--space-sm); }
.ml-3 { margin-left: var(--space-md); }
.ml-4 { margin-left: var(--space-lg); }
.ml-5 { margin-left: var(--space-xl); }

/* 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-grid { display: grid; }

/* Flex Utilities */
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }

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

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

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

/* Grid Utilities */
.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-auto { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.gap-1 { gap: var(--space-xs); }
.gap-2 { gap: var(--space-sm); }
.gap-3 { gap: var(--space-md); }
.gap-4 { gap: var(--space-lg); }
.gap-5 { gap: var(--space-xl); }

/* Text Utilities */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-md { font-size: var(--font-size-md); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }

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

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--status-success); }
.text-warning { color: var(--status-warning); }
.text-error { color: var(--status-error); }

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

/* Border Utilities */
.border { border: 1px solid var(--border-color); }
.border-t { border-top: 1px solid var(--border-color); }
.border-r { border-right: 1px solid var(--border-color); }
.border-b { border-bottom: 1px solid var(--border-color); }
.border-l { border-left: 1px solid var(--border-color); }

.rounded-none { border-radius: 0; }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

/* Shadow Utilities */
.shadow-none { box-shadow: none; }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }

/* Position Utilities */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

.top-0 { top: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }

/* Width/Height Utilities */
.w-full { width: 100%; }
.w-auto { width: auto; }
.h-full { height: 100%; }
.h-auto { height: auto; }
.h-screen { height: 100vh; }

/* Medical Utility Classes */
.status-active { color: var(--status-success); }
.status-pending { color: var(--status-warning); }
.status-inactive { color: var(--status-neutral); }
.status-critical { color: var(--status-critical); }
.status-emergency { color: var(--color-medical-emergency); }

.priority-low { color: var(--color-medical-priority-low); }
.priority-normal { color: var(--color-medical-priority-normal); }
.priority-high { color: var(--color-medical-priority-high); }
.priority-critical { color: var(--color-medical-priority-critical); }

/* Medical Background Classes */
.bg-patient { background: var(--color-medical-patient-bg); }
.bg-study { background: var(--color-medical-study-bg); }
.bg-report { background: var(--color-medical-report-bg); }
.bg-appointment { background: var(--color-medical-appointment-bg); }

/* Accessibility Utilities */
.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;
}

.not-sr-only {
  position: static;
  width: auto;
  height: auto;
  padding: 0;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

.focus-visible:focus-visible {
  outline: 2px solid var(--focus-color);
  outline-offset: 2px;
}

/* Animation Utilities */
.animate-none { animation: none; }
.animate-pulse { animation: pulse 2s infinite; }
.animate-bounce { animation: bounce 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% { transform: translate3d(0, 0, 0); }
  40%, 43% { transform: translate3d(0, -8px, 0); }
  70% { transform: translate3d(0, -4px, 0); }
  90% { transform: translate3d(0, -2px, 0); }
}

/* Loading States */
.loading {
  position: relative;
  overflow: hidden;
}

.loading::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(var(--primary-rgb), 0.1),
    transparent
  );
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* Medical Emergency Classes */
.emergency-blink {
  animation: emergencyBlink 1s infinite;
}

.critical-pulse {
  animation: criticalPulse 1.5s infinite;
}

@keyframes emergencyBlink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0.6; }
}

@keyframes criticalPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* Container Utilities */
.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.container-fluid {
  width: 100%;
  padding: 0 var(--space-md);
}

/* Layout Grid */
.orion-layout {
  display: grid;
  grid-template-areas: 
    "sidebar header"
    "sidebar main"
    "sidebar footer";
  grid-template-columns: var(--nav-sidebar-width) 1fr;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

.orion-layout__sidebar { grid-area: sidebar; }
.orion-layout__header { grid-area: header; }
.orion-layout__main { grid-area: main; }
.orion-layout__footer { grid-area: footer; }

.orion-layout--no-sidebar {
  grid-template-areas: 
    "header"
    "main"
    "footer";
  grid-template-columns: 1fr;
}

/* Responsive Layout */
@media (max-width: 1024px) {
  .orion-layout {
    grid-template-areas: 
      "header"
      "main"
      "footer";
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  
  .orion-layout__sidebar {
    display: none;
  }
}

/* Medical Content Layout */
.medical-content {
  padding: var(--space-lg);
  max-width: var(--content-max-width);
  margin: 0 auto;
}

.medical-header {
  background: var(--surface-elevated);
  border-bottom: 1px solid var(--border-color);
  padding: var(--space-md) var(--space-lg);
}

.medical-section {
  margin: var(--space-xl) 0;
  padding: var(--space-lg);
  background: var(--surface-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.medical-section__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin: 0 0 var(--space-md) 0;
  border-bottom: 2px solid var(--color-medical-primary);
  padding-bottom: var(--space-sm);
}

/* Medical Data Tables */
.medical-table-container {
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* Focus Management */
.focus-trap {
  position: relative;
}

.focus-trap:focus-within {
  outline: 2px solid var(--focus-color);
  outline-offset: 2px;
}

/* Theme Switching */
.theme-light {
  color-scheme: light;
}

.theme-dark {
  color-scheme: dark;
}

.theme-medical {
  --primary: var(--color-medical-primary);
  --primary-light: var(--color-medical-primary-light);
  --primary-dark: var(--color-medical-primary-dark);
}

.theme-high-contrast {
  filter: contrast(150%);
}

/* Medical Workflow States */
.workflow-pending {
  border-left: 4px solid var(--status-warning);
  background: var(--status-warning-bg);
}

.workflow-progress {
  border-left: 4px solid var(--status-info);
  background: var(--status-info-bg);
  position: relative;
}

.workflow-progress::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: var(--progress-height, 50%);
  background: var(--color-medical-study);
  transition: height var(--transition-normal);
}

.workflow-completed {
  border-left: 4px solid var(--status-success);
  background: var(--status-success-bg);
}

.workflow-cancelled {
  border-left: 4px solid var(--status-neutral);
  background: var(--status-neutral-bg);
  opacity: 0.7;
}

/* Removed forced background on .brand-logo to allow proper logo display */

/* Print Styles */
@media print {
  body {
    background: white !important;
    color: black !important;
    font-size: 12pt;
  }
  
  .orion-layout {
    grid-template-areas: 
      "main";
    grid-template-columns: 1fr;
  }
  
  .medical-content {
    padding: 0;
    max-width: none;
  }
  
  .no-print {
    display: none !important;
  }
  
  .print-only {
    display: block !important;
  }
}

.uppercase {
  text-transform: uppercase;
}

.enterprise {
    color: var(--color-info);
    text-shadow: 2px 2px rgba(0, 0, 0, 0.05);;    
    font-size: var(--font-size-xl);
    text-transform: uppercase;
    font-weight: var(--font-weight-medium);
}

.noselect-text {
  -webkit-touch-callout: none; /* iOS Safari */
  -webkit-user-select: none; /* Safari */
  -khtml-user-select: none; /* Konqueror HTML */
  -moz-user-select: none; /* Firefox */
  -ms-user-select: none; /* Internet Explorer/Edge */
  user-select: none; /* Standard property */
}