// ============================================================================
// Enterprise EHR Component Styles
// Modern, Professional, and Responsive Styling
// ============================================================================

// ============================================================================
// Component Root & Variables
// ============================================================================

:host,
app-ehr {
  display: block;
  width: 100%;
}

// ============================================================================
// Main Section Container
// ============================================================================

.ehr-section {
  width: 100%;
  padding: var(--space-xl, 2rem);
  background: transparent;
  
  @media (max-width: 768px) {
    padding: var(--space-md, 1rem);
  }
}

// ============================================================================
// Section Header
// ============================================================================

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-lg, 1.5rem);
  margin-bottom: var(--space-2xl, 3rem);
  flex-wrap: wrap;
  
  @media (max-width: 1024px) {
    flex-direction: column;
    gap: var(--space-md, 1rem);
    margin-bottom: var(--space-xl, 2rem);
  }
}

.section-title {
  font-size: var(--font-size-3xl, 1.875rem);
  font-weight: var(--font-weight-bold, 700);
  color: var(--text-primary, #111827);
  margin: 0 0 var(--space-sm, 0.5rem) 0;
  line-height: var(--line-height-tight, 1.25);
  position: relative;
  padding-bottom: var(--space-md, 1rem);
  
  &::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 4px;
    background: linear-gradient(135deg, var(--color-primary, #2563eb) 0%, var(--color-accent, #8b5cf6) 100%);
    border-radius: var(--radius-full, 9999px);
  }
  
  @media (max-width: 768px) {
    font-size: var(--font-size-2xl, 1.5rem);
  }
}

.section-description {
  font-size: var(--font-size-base, 1rem);
  color: var(--text-secondary, #4b5563);
  margin: 0;
  line-height: var(--line-height-normal, 1.5);
  
  @media (max-width: 768px) {
    font-size: var(--font-size-sm, 0.875rem);
  }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md, 1rem);
  flex-wrap: wrap;
  
  @media (max-width: 640px) {
    width: 100%;
  }
}

// ============================================================================
// Error Message
// ============================================================================

.error-message {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md, 1rem);
  padding: var(--space-md, 1rem) var(--space-lg, 1.5rem);
  background: var(--color-danger-light, #fee2e2);
  border: 1px solid var(--color-danger, #ef4444);
  border-radius: var(--radius-lg, 0.75rem);
  color: var(--color-danger, #ef4444);
  font-size: var(--font-size-sm, 0.875rem);
  margin-bottom: var(--space-xl, 2rem);
  animation: slideDown var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  
  strong {
    font-weight: var(--font-weight-semibold, 600);
  }
  
  button {
    background: transparent;
    border: none;
    color: var(--color-danger, #ef4444);
    font-size: var(--font-size-xl, 1.25rem);
    font-weight: var(--font-weight-bold, 700);
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm, 0.375rem);
    transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
    flex-shrink: 0;
    line-height: 1;
    
    &:hover {
      background: var(--color-danger, #ef4444);
      color: var(--text-inverse, #ffffff);
      transform: scale(1.1);
    }
    
    &:active {
      transform: scale(0.95);
    }
  }
  
  @media (max-width: 640px) {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm, 0.5rem);
  }
}

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

// ============================================================================
// Card Component
// ============================================================================

.card {
  background: var(--bg-primary, #ffffff);
  border-radius: var(--radius-xl, 1rem);
  padding: var(--space-xl, 2rem);
  box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
  border: 1px solid var(--color-gray-200, #e5e7eb);
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  position: relative;
  overflow: hidden;
  margin-bottom: var(--space-xl, 2rem);
  
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--color-primary, #2563eb) 0%, var(--color-accent, #8b5cf6) 100%);
  }
  
  &:hover {
    box-shadow: var(--shadow-xl, 0 20px 25px -5px rgba(0, 0, 0, 0.1));
    border-color: var(--color-primary, #2563eb);
  }
  
  h3 {
    font-size: var(--font-size-xl, 1.25rem);
    font-weight: var(--font-weight-semibold, 600);
    color: var(--text-primary, #111827);
    margin: 0 0 var(--space-lg, 1.5rem) 0;
    line-height: var(--line-height-tight, 1.25);
  }
  
  @media (max-width: 768px) {
    padding: var(--space-lg, 1.5rem);
    border-radius: var(--radius-lg, 0.75rem);
    margin-bottom: var(--space-lg, 1.5rem);
  }
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md, 1rem);
  margin-bottom: var(--space-lg, 1.5rem);
  flex-wrap: wrap;
  
  h3 {
    margin: 0;
  }
  
  @media (max-width: 640px) {
    flex-direction: column;
    align-items: stretch;
    
    h3 {
      text-align: center;
    }
  }
}

// ============================================================================
// Patient Selection & Info
// ============================================================================

.patient-info-card {
  background: linear-gradient(135deg, var(--color-primary-light, #dbeafe) 0%, var(--color-accent-light, #ede9fe) 100%);
  border-color: var(--color-primary, #2563eb);
  
  h3 {
    color: var(--color-primary-dark, #1e40af);
  }
  
  p {
    font-size: var(--font-size-lg, 1.125rem);
    color: var(--text-primary, #111827);
    margin: 0;
    font-weight: var(--font-weight-medium, 500);
    
    strong {
      font-weight: var(--font-weight-bold, 700);
      color: var(--color-primary-dark, #1e40af);
    }
  }
}

.patient-info-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md, 1rem);
  
  .view-profile-btn {
    padding: var(--space-xs, 0.5rem) var(--space-md, 1rem);
    background: var(--color-primary, #2563eb);
    color: var(--text-inverse, #ffffff);
    border: none;
    border-radius: var(--radius-md, 0.5rem);
    font-size: var(--font-size-sm, 0.875rem);
    font-weight: var(--font-weight-semibold, 600);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-xs, 0.5rem);
    transition: all var(--transition-base, 200ms);
    
    &:hover {
      background: var(--color-primary-dark, #1e40af);
      transform: translateY(-1px);
    }
    
    svg {
      width: 16px;
      height: 16px;
    }
  }
}

// ============================================================================
// Loading State
// ============================================================================

.loading-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl, 4rem);
  min-height: 300px;
}

.spinner-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg, 1.5rem);
  
  p {
    font-size: var(--font-size-lg, 1.125rem);
    color: var(--text-secondary, #4b5563);
    margin: 0;
    font-weight: var(--font-weight-medium, 500);
  }
}

.spinner {
  width: 48px;
  height: 48px;
  color: var(--color-primary, #2563eb);
  animation: spin 1s linear infinite;
}

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

// ============================================================================
// Tabs Navigation
// ============================================================================

.ehr-tabs {
  display: flex;
  gap: var(--space-sm, 0.5rem);
  margin-bottom: var(--space-xl, 2rem);
  border-bottom: 2px solid var(--color-gray-200, #e5e7eb);
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-gray-300, #d1d5db) transparent;
  
  &::-webkit-scrollbar {
    height: 6px;
  }
  
  &::-webkit-scrollbar-track {
    background: transparent;
  }
  
  &::-webkit-scrollbar-thumb {
    background: var(--color-gray-300, #d1d5db);
    border-radius: var(--radius-full, 9999px);
    
    &:hover {
      background: var(--color-gray-400, #9ca3af);
    }
  }
  
  @media (max-width: 640px) {
    gap: var(--space-xs, 0.25rem);
  }
}

.tab-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm, 0.5rem);
  padding: var(--space-md, 1rem) var(--space-lg, 1.5rem);
  border: none;
  background: transparent;
  color: var(--text-secondary, #4b5563);
  font-size: var(--font-size-base, 1rem);
  font-weight: var(--font-weight-medium, 500);
  cursor: pointer;
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  position: relative;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  
  svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: color var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  }
  
  .badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 var(--space-xs, 0.25rem);
    background: var(--color-gray-200, #e5e7eb);
    color: var(--text-secondary, #4b5563);
    border-radius: var(--radius-full, 9999px);
    font-size: var(--font-size-xs, 0.75rem);
    font-weight: var(--font-weight-semibold, 600);
  }
  
  &:hover {
    color: var(--color-primary, #2563eb);
    
    svg {
      color: var(--color-primary, #2563eb);
    }
    
    .badge {
      background: var(--color-primary-light, #dbeafe);
      color: var(--color-primary, #2563eb);
    }
  }
  
  &.active {
    color: var(--color-primary, #2563eb);
    border-bottom-color: var(--color-primary, #2563eb);
    font-weight: var(--font-weight-semibold, 600);
    
    svg {
      color: var(--color-primary, #2563eb);
    }
    
    .badge {
      background: var(--color-primary, #2563eb);
      color: var(--text-inverse, #ffffff);
    }
  }
  
  @media (max-width: 640px) {
    padding: var(--space-sm, 0.5rem) var(--space-md, 1rem);
    font-size: var(--font-size-sm, 0.875rem);
    
    svg {
      width: 18px;
      height: 18px;
    }
    
    .badge {
      min-width: 18px;
      height: 18px;
      font-size: 0.625rem;
    }
  }
}

.tab-content {
  animation: fadeIn var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
}

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

// ============================================================================
// Form Elements
// ============================================================================

form {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl, 2rem);
  
  @media (max-width: 768px) {
    gap: var(--space-lg, 1.5rem);
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs, 0.25rem);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-lg, 1.5rem);
  
  @media (max-width: 1024px) {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-md, 1rem);
  }
  
  @media (max-width: 640px) {
    grid-template-columns: 1fr;
    gap: var(--space-md, 1rem);
  }
}

.form-label {
  font-size: var(--font-size-sm, 0.875rem);
  font-weight: var(--font-weight-medium, 500);
  color: var(--text-primary, #111827);
  margin-bottom: var(--space-xs, 0.25rem);
  display: flex;
  align-items: center;
  gap: var(--space-xs, 0.25rem);
}

.required-asterisk {
  color: var(--color-danger, #ef4444);
  font-weight: var(--font-weight-bold, 700);
}

.form-input {
  width: 100%;
  padding: var(--space-sm, 0.5rem) var(--space-md, 1rem);
  border: 2px solid var(--color-gray-300, #d1d5db);
  border-radius: var(--radius-md, 0.5rem);
  background: var(--bg-primary, #ffffff);
  color: var(--text-primary, #111827);
  font-size: var(--font-size-base, 1rem);
  font-family: var(--font-family-base, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  appearance: none;
  
  &:hover {
    border-color: var(--color-primary, #2563eb);
  }
  
  &:focus {
    outline: none;
    border-color: var(--color-primary, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  }
  
  &::placeholder {
    color: var(--color-gray-400, #9ca3af);
  }
  
  &:disabled {
    background: var(--color-gray-100, #f3f4f6);
    color: var(--text-disabled, #9ca3af);
    cursor: not-allowed;
    border-color: var(--color-gray-200, #e5e7eb);
  }
  
  &[type="number"] {
    &::-webkit-inner-spin-button,
    &::-webkit-outer-spin-button {
      opacity: 1;
      height: auto;
      cursor: pointer;
    }
  }
  
  &[type="date"] {
    position: relative;
    
    &::-webkit-calendar-picker-indicator {
      cursor: pointer;
      opacity: 0.6;
      transition: opacity var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
      
      &:hover {
        opacity: 1;
      }
    }
  }
}

select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9L12 15L18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-sm, 0.5rem) center;
  background-size: 20px;
  padding-right: var(--space-2xl, 3rem);
  cursor: pointer;
  
  option {
    padding: var(--space-sm, 0.5rem);
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #111827);
  }
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
  font-family: var(--font-family-base, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  
  &.form-input {
    line-height: var(--line-height-relaxed, 1.75);
  }
}

.form-actions {
  display: flex;
  gap: var(--space-md, 1rem);
  justify-content: flex-end;
  margin-top: var(--space-md, 1rem);
  flex-wrap: wrap;
  
  @media (max-width: 640px) {
    flex-direction: column-reverse;
    
    button {
      width: 100%;
    }
  }
}

// ============================================================================
// Buttons
// ============================================================================

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm, 0.5rem);
  padding: var(--space-sm, 0.5rem) var(--space-lg, 1.5rem);
  border: none;
  border-radius: var(--radius-md, 0.5rem);
  background: linear-gradient(135deg, var(--color-primary, #2563eb) 0%, var(--color-accent, #8b5cf6) 100%);
  color: var(--text-inverse, #ffffff);
  font-size: var(--font-size-base, 1rem);
  font-weight: var(--font-weight-semibold, 600);
  cursor: pointer;
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
  position: relative;
  overflow: hidden;
  
  svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }
  
  &::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
  }
  
  &:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--color-accent, #8b5cf6) 0%, var(--color-primary, #2563eb) 100%);
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
    transform: translateY(-2px);
    
    &::before {
      width: 300px;
      height: 300px;
    }
  }
  
  &:active:not(:disabled) {
    transform: translateY(0);
  }
  
  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
  }
  
  @media (max-width: 640px) {
    width: 100%;
    justify-content: center;
  }
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm, 0.5rem);
  padding: var(--space-sm, 0.5rem) var(--space-lg, 1.5rem);
  border: 2px solid var(--color-primary, #2563eb);
  border-radius: var(--radius-md, 0.5rem);
  background: var(--bg-primary, #ffffff);
  color: var(--color-primary, #2563eb);
  font-size: var(--font-size-base, 1rem);
  font-weight: var(--font-weight-medium, 500);
  cursor: pointer;
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  
  &:hover:not(:disabled) {
    background: var(--color-primary, #2563eb);
    color: var(--text-inverse, #ffffff);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
  }
  
  &:active:not(:disabled) {
    transform: translateY(0);
  }
  
  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
  }
  
  @media (max-width: 640px) {
    width: 100%;
    justify-content: center;
  }
}

.form-actions button {
  padding: var(--space-sm, 0.5rem) var(--space-lg, 1.5rem);
  border: none;
  border-radius: var(--radius-md, 0.5rem);
  font-size: var(--font-size-base, 1rem);
  font-weight: var(--font-weight-medium, 500);
  cursor: pointer;
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  
  &[type="submit"] {
    background: linear-gradient(135deg, var(--color-primary, #2563eb) 0%, var(--color-accent, #8b5cf6) 100%);
    color: var(--text-inverse, #ffffff);
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
    
    &:hover:not(:disabled) {
      background: linear-gradient(135deg, var(--color-accent, #8b5cf6) 0%, var(--color-primary, #2563eb) 100%);
      transform: translateY(-2px);
      box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
    }
  }
  
  &[type="button"] {
    background: var(--bg-primary, #ffffff);
    color: var(--text-secondary, #4b5563);
    border: 2px solid var(--color-gray-300, #d1d5db);
    
    &:hover:not(:disabled) {
      background: var(--color-gray-50, #f9fafb);
      border-color: var(--color-gray-400, #9ca3af);
      color: var(--text-primary, #111827);
    }
  }
  
  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
  }
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: var(--radius-md, 0.5rem);
  background: transparent;
  color: var(--text-secondary, #4b5563);
  cursor: pointer;
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  
  svg {
    width: 20px;
    height: 20px;
  }
  
  &:hover {
    background: var(--color-gray-100, #f3f4f6);
    color: var(--color-primary, #2563eb);
    transform: scale(1.1);
  }
  
  &:active {
    transform: scale(0.95);
  }
  
  &.delete-button {
    &:hover {
      background: var(--color-danger-light, #fee2e2);
      color: var(--color-danger, #ef4444);
    }
  }
}

// ============================================================================
// Medical Records
// ============================================================================

.medical-records-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg, 1.5rem);
}

.medical-record-card {
  background: var(--bg-secondary, #f9fafb);
  border-radius: var(--radius-lg, 0.75rem);
  padding: var(--space-lg, 1.5rem);
  border: 1px solid var(--color-gray-200, #e5e7eb);
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  position: relative;
  
  &:hover {
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
    border-color: var(--color-primary, #2563eb);
    transform: translateY(-2px);
  }
  
  @media (max-width: 768px) {
    padding: var(--space-md, 1rem);
  }
}

.record-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md, 1rem);
  margin-bottom: var(--space-md, 1rem);
  
  h4 {
    font-size: var(--font-size-lg, 1.125rem);
    font-weight: var(--font-weight-semibold, 600);
    color: var(--text-primary, #111827);
    margin: 0 0 var(--space-sm, 0.5rem) 0;
    line-height: var(--line-height-tight, 1.25);
  }
  
  @media (max-width: 640px) {
    flex-direction: column;
    gap: var(--space-sm, 0.5rem);
  }
}

.record-meta {
  display: flex;
  align-items: center;
  gap: var(--space-md, 1rem);
  flex-wrap: wrap;
}

.record-type {
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs, 0.25rem) var(--space-sm, 0.5rem);
  background: var(--color-primary-light, #dbeafe);
  color: var(--color-primary, #2563eb);
  border-radius: var(--radius-full, 9999px);
  font-size: var(--font-size-xs, 0.75rem);
  font-weight: var(--font-weight-medium, 500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.record-date {
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--text-secondary, #4b5563);
}

.record-actions {
  display: flex;
  gap: var(--space-xs, 0.25rem);
  flex-shrink: 0;
}

.record-content {
  p {
    font-size: var(--font-size-base, 1rem);
    color: var(--text-primary, #111827);
    line-height: var(--line-height-relaxed, 1.75);
    margin: 0 0 var(--space-md, 1rem) 0;
    white-space: pre-wrap;
    word-wrap: break-word;
  }
}

.record-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs, 0.25rem);
  padding-top: var(--space-md, 1rem);
  border-top: 1px solid var(--color-gray-200, #e5e7eb);
}

.detail-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm, 0.5rem);
  font-size: var(--font-size-sm, 0.875rem);
  
  .detail-label {
    font-weight: var(--font-weight-medium, 500);
    color: var(--text-secondary, #4b5563);
  }
  
  .detail-value {
    color: var(--text-primary, #111827);
  }
}

// ============================================================================
// Vital Signs
// ============================================================================

.vital-signs-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg, 1.5rem);
  margin-bottom: var(--space-lg, 1.5rem);
  
  @media (max-width: 768px) {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-md, 1rem);
  }
  
  @media (max-width: 480px) {
    grid-template-columns: 1fr;
  }
}

.vital-sign-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs, 0.25rem);
  padding: var(--space-md, 1rem);
  background: var(--bg-secondary, #f9fafb);
  border-radius: var(--radius-md, 0.5rem);
  border: 1px solid var(--color-gray-200, #e5e7eb);
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  
  &:hover {
    background: var(--color-primary-light, #dbeafe);
    border-color: var(--color-primary, #2563eb);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm, 0 1px 3px 0 rgba(0, 0, 0, 0.1));
  }
  
  .vital-label {
    font-size: var(--font-size-xs, 0.75rem);
    font-weight: var(--font-weight-medium, 500);
    color: var(--text-secondary, #4b5563);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  
  .vital-value {
    font-size: var(--font-size-xl, 1.25rem);
    font-weight: var(--font-weight-bold, 700);
    color: var(--text-primary, #111827);
  }
}

.vital-date {
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--text-secondary, #4b5563);
  margin: var(--space-md, 1rem) 0 0 0;
  text-align: center;
  font-style: italic;
}

.vital-signs-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg, 1.5rem);
}

.vital-signs-card {
  background: var(--bg-secondary, #f9fafb);
  border-radius: var(--radius-lg, 0.75rem);
  padding: var(--space-lg, 1.5rem);
  border: 1px solid var(--color-gray-200, #e5e7eb);
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  
  &:hover {
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
    border-color: var(--color-primary, #2563eb);
    transform: translateY(-2px);
  }
  
  @media (max-width: 768px) {
    padding: var(--space-md, 1rem);
  }
}

.vital-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md, 1rem);
  padding-bottom: var(--space-md, 1rem);
  border-bottom: 1px solid var(--color-gray-200, #e5e7eb);
}

.vital-signs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-md, 1rem);
  
  @media (max-width: 480px) {
    grid-template-columns: 1fr;
  }
}

.vital-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm, 0.5rem) var(--space-md, 1rem);
  background: var(--bg-primary, #ffffff);
  border-radius: var(--radius-sm, 0.375rem);
  
  .vital-label {
    font-size: var(--font-size-sm, 0.875rem);
    font-weight: var(--font-weight-medium, 500);
    color: var(--text-secondary, #4b5563);
  }
  
  .vital-value {
    font-size: var(--font-size-base, 1rem);
    font-weight: var(--font-weight-semibold, 600);
    color: var(--text-primary, #111827);
  }
}

.vital-notes {
  margin-top: var(--space-md, 1rem);
  padding-top: var(--space-md, 1rem);
  border-top: 1px solid var(--color-gray-200, #e5e7eb);
  
  p {
    font-size: var(--font-size-sm, 0.875rem);
    color: var(--text-secondary, #4b5563);
    margin: 0;
    line-height: var(--line-height-normal, 1.5);
    
    strong {
      font-weight: var(--font-weight-semibold, 600);
      color: var(--text-primary, #111827);
    }
  }
}

// ============================================================================
// Lab Results
// ============================================================================

.lab-results-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg, 1.5rem);
}

.lab-result-card {
  background: var(--bg-secondary, #f9fafb);
  border-radius: var(--radius-lg, 0.75rem);
  padding: var(--space-lg, 1.5rem);
  border: 1px solid var(--color-gray-200, #e5e7eb);
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  position: relative;
  
  &:hover {
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
    border-color: var(--color-primary, #2563eb);
    transform: translateY(-2px);
  }
  
  @media (max-width: 768px) {
    padding: var(--space-md, 1rem);
  }
}

.lab-result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md, 1rem);
  margin-bottom: var(--space-md, 1rem);
  
  h4 {
    font-size: var(--font-size-lg, 1.125rem);
    font-weight: var(--font-weight-semibold, 600);
    color: var(--text-primary, #111827);
    margin: 0 0 var(--space-sm, 0.5rem) 0;
    line-height: var(--line-height-tight, 1.25);
  }
  
  @media (max-width: 640px) {
    flex-direction: column;
    gap: var(--space-sm, 0.5rem);
  }
}

.lab-result-meta {
  display: flex;
  align-items: center;
  gap: var(--space-md, 1rem);
  flex-wrap: wrap;
}

.lab-status {
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs, 0.25rem) var(--space-sm, 0.5rem);
  border-radius: var(--radius-full, 9999px);
  font-size: var(--font-size-xs, 0.75rem);
  font-weight: var(--font-weight-medium, 500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  
  &.status-pending {
    background: var(--color-info-light, #dbeafe);
    color: var(--color-info, #3b82f6);
    border: 1px solid var(--color-info, #3b82f6);
  }
  
  &.status-normal {
    background: var(--color-success-light, #d1fae5);
    color: var(--color-success, #10b981);
    border: 1px solid var(--color-success, #10b981);
  }
  
  &.status-abnormal {
    background: var(--color-warning-light, #fef3c7);
    color: var(--color-warning, #f59e0b);
    border: 1px solid var(--color-warning, #f59e0b);
  }
  
  &.status-critical {
    background: var(--color-danger-light, #fee2e2);
    color: var(--color-danger, #ef4444);
    border: 1px solid var(--color-danger, #ef4444);
  }
}

.lab-date {
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--text-secondary, #4b5563);
}

.lab-result-actions {
  display: flex;
  gap: var(--space-xs, 0.25rem);
  flex-shrink: 0;
}

.lab-result-content {
  .lab-result-value {
    font-size: var(--font-size-lg, 1.125rem);
    font-weight: var(--font-weight-semibold, 600);
    color: var(--text-primary, #111827);
    margin-bottom: var(--space-md, 1rem);
    
    strong {
      font-weight: var(--font-weight-bold, 700);
      color: var(--color-primary, #2563eb);
    }
  }
}

.lab-result-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs, 0.25rem);
  padding-top: var(--space-md, 1rem);
  border-top: 1px solid var(--color-gray-200, #e5e7eb);
}

// ============================================================================
// Empty State
// ============================================================================

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl, 4rem) var(--space-xl, 2rem);
  text-align: center;
  background: var(--bg-secondary, #f9fafb);
  border-radius: var(--radius-lg, 0.75rem);
  border: 2px dashed var(--color-gray-300, #d1d5db);
  margin-top: var(--space-lg, 1.5rem);
  
  .empty-icon {
    width: 80px;
    height: 80px;
    color: var(--color-gray-400, #9ca3af);
    margin-bottom: var(--space-lg, 1.5rem);
    opacity: 0.6;
    animation: float 3s ease-in-out infinite;
  }
  
  h3 {
    font-size: var(--font-size-2xl, 1.5rem);
    font-weight: var(--font-weight-semibold, 600);
    color: var(--text-primary, #111827);
    margin: 0 0 var(--space-sm, 0.5rem) 0;
  }
  
  p {
    font-size: var(--font-size-base, 1rem);
    color: var(--text-secondary, #4b5563);
    margin: 0 0 var(--space-lg, 1.5rem) 0;
    max-width: 400px;
    line-height: var(--line-height-normal, 1.5);
  }
  
  button {
    margin-top: var(--space-md, 1rem);
  }
  
  @media (max-width: 768px) {
    padding: var(--space-2xl, 3rem) var(--space-lg, 1.5rem);
    
    .empty-icon {
      width: 60px;
      height: 60px;
    }
    
    h3 {
      font-size: var(--font-size-xl, 1.25rem);
    }
    
    p {
      font-size: var(--font-size-sm, 0.875rem);
    }
  }
}

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

// ============================================================================
// Responsive Enhancements
// ============================================================================

@media (max-width: 640px) {
  .ehr-section {
    padding: var(--space-sm, 0.5rem);
  }
  
  .card {
    border-radius: var(--radius-lg, 0.75rem);
    padding: var(--space-md, 1rem);
  }
  
  .form-input {
    font-size: var(--font-size-sm, 0.875rem);
    padding: var(--space-sm, 0.5rem) var(--space-md, 1rem);
  }
  
  .primary-button,
  .secondary-button {
    font-size: var(--font-size-sm, 0.875rem);
    padding: var(--space-sm, 0.5rem) var(--space-md, 1rem);
  }
}

// ============================================================================
// Focus Visible for Accessibility
// ============================================================================

.form-input:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.tab-button:focus-visible,
.icon-button:focus-visible {
  outline: 2px solid var(--color-primary, #2563eb);
  outline-offset: 2px;
}

// ============================================================================
// Print Styles
// ============================================================================

@media print {
  .ehr-section {
    padding: 0;
  }
  
  .card {
    box-shadow: none;
    border: 1px solid var(--color-gray-300, #d1d5db);
    padding: var(--space-md, 1rem);
    break-inside: avoid;
    page-break-inside: avoid;
    
    &:hover {
      transform: none;
      box-shadow: none;
    }
  }
  
  .header-actions,
  .form-actions,
  .record-actions,
  .vital-header,
  .lab-result-actions,
  .icon-button,
  .primary-button,
  .secondary-button {
    display: none;
  }
  
  .form-input {
    border: 1px solid var(--color-gray-400, #9ca3af);
    background: transparent;
  }
  
  .ehr-tabs {
    border-bottom: 2px solid var(--color-gray-400, #9ca3af);
  }
  
  .tab-button {
    &.active {
      border-bottom-color: var(--color-gray-900, #111827);
      color: var(--color-gray-900, #111827);
    }
  }
}

// ============================================================================
// Dark Mode Support (Optional)
// ============================================================================

// ============================================================================
// Modal Styles (for Patient Profile)
// ============================================================================

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-xl, 2rem);
}

.modal-content {
  background: var(--color-white, #ffffff);
  border-radius: var(--radius-lg, 0.75rem);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;

  &.profile-modal {
    max-width: 800px;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg, 1.5rem);
  border-bottom: 1px solid var(--color-gray-200, #e5e7eb);

  h2 {
    margin: 0;
    font-size: var(--font-size-2xl, 1.5rem);
    color: var(--text-primary, #111827);
  }

  .modal-close {
    background: none;
    border: none;
    font-size: var(--font-size-xl, 1.25rem);
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition-base, 200ms);

    &:hover {
      background: var(--color-gray-100, #f3f4f6);
      color: var(--text-primary, #111827);
    }

    svg {
      width: 20px;
      height: 20px;
    }
  }
}

.modal-body {
  padding: var(--space-lg, 1.5rem);
}

// Profile Full View Styles (shared with patient component)
.profile-full-view {
  .profile-section {
    margin-bottom: var(--space-xl, 2rem);
    padding-bottom: var(--space-lg, 1.5rem);
    border-bottom: 1px solid var(--color-gray-200, #e5e7eb);

    &:last-child {
      border-bottom: none;
      margin-bottom: 0;
    }

    h3 {
      font-size: var(--font-size-xl, 1.25rem);
      font-weight: var(--font-weight-semibold, 600);
      color: var(--text-primary, #111827);
      margin: 0 0 var(--space-md, 1rem) 0;
    }
  }

  .info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-md, 1rem);
  }

  .info-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs, 0.25rem);

    .info-label {
      font-size: var(--font-size-sm, 0.875rem);
      font-weight: var(--font-weight-semibold, 600);
      color: var(--text-secondary, #6b7280);
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }

    .info-value {
      font-size: var(--font-size-base, 1rem);
      color: var(--text-primary, #111827);
    }
  }

  .tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs, 0.5rem);
    margin-top: var(--space-xs, 0.5rem);
  }

  .tag {
    padding: var(--space-xs, 0.5rem) var(--space-md, 1rem);
    background: var(--color-primary-light, #dbeafe);
    color: var(--color-primary-dark, #1e40af);
    border-radius: 9999px;
    font-size: var(--font-size-sm, 0.875rem);
    font-weight: var(--font-weight-medium, 500);
  }

  .biography-text {
    line-height: 1.8;
    color: var(--text-primary, #111827);
    white-space: pre-wrap;
  }
}

@media (prefers-color-scheme: dark) {
  // Add dark mode styles if needed
  // This is a placeholder for future dark mode support
}

