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

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

:host,
app-prescriptions {
  display: block;
  width: 100%;
  overflow-x: hidden;
  min-height: 100%;
}

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

.prescriptions-section {
  width: 100%;
  padding: var(--space-xl, 2rem);
  background: transparent;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: visible;
  
  @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);
  
  @media (max-width: 768px) {
    flex-direction: column;
    gap: var(--space-md, 1rem);
    margin-bottom: var(--space-xl, 2rem);
  }
}

// ============================================================================
// Section Title
// ============================================================================

.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;
  display: inline-block;
  
  &::after {
    content: '';
    position: absolute;
    bottom: -8px;
    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: var(--space-md, 1rem) 0 0 0;
  line-height: var(--line-height-normal, 1.5);
  
  @media (max-width: 768px) {
    font-size: var(--font-size-sm, 0.875rem);
  }
}

// ============================================================================
// Header Actions
// ============================================================================

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm, 0.5rem);
  flex-wrap: wrap;
  
  @media (max-width: 768px) {
    width: 100%;
    
    button {
      flex: 1;
      min-width: 120px;
    }
  }
}

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

.primary-button,
.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: none;
  border-radius: var(--radius-md, 0.5rem);
  font-size: var(--font-size-sm, 0.875rem);
  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;
  overflow: hidden;
  white-space: nowrap;
  
  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::before {
    width: 300px;
    height: 300px;
  }
  
  &:active {
    transform: scale(0.98);
  }
  
  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
  }
}

.primary-button {
  background: linear-gradient(135deg, var(--color-primary, #2563eb) 0%, var(--color-primary-dark, #1e40af) 100%);
  color: var(--text-inverse, #ffffff);
  box-shadow: var(--shadow-sm, 0 1px 3px 0 rgba(0, 0, 0, 0.1));
  
  &:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--color-primary-dark, #1e40af) 0%, var(--color-primary, #2563eb) 100%);
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
    transform: translateY(-2px);
  }
}

.secondary-button {
  background: var(--bg-primary, #ffffff);
  color: var(--color-primary, #2563eb);
  border: 2px solid var(--color-primary, #2563eb);
  box-shadow: var(--shadow-xs, 0 1px 2px 0 rgba(0, 0, 0, 0.05));
  
  &:hover:not(:disabled) {
    background: var(--color-primary, #2563eb);
    color: var(--text-inverse, #ffffff);
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
    transform: translateY(-2px);
  }
}

// ============================================================================
// Prescription Analytics
// ============================================================================

.prescription-analytics {
  margin-bottom: var(--space-2xl, 3rem);
  padding: var(--space-lg, 1.5rem);
  background: var(--bg-primary, #ffffff);
  border-radius: var(--radius-xl, 1rem);
  box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
  border: 1px solid var(--color-gray-200, #e5e7eb);
  
  @media (max-width: 768px) {
    padding: var(--space-md, 1rem);
  }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg, 1.5rem);
  width: 100%;
  box-sizing: border-box;
  overflow: visible;
  
  @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;
    gap: var(--space-md, 1rem);
  }
}

.stat-card {
  display: flex;
  align-items: center;
  gap: var(--space-md, 1rem);
  padding: var(--space-lg, 1.5rem);
  background: linear-gradient(135deg, var(--color-gray-50, #f9fafb) 0%, var(--bg-primary, #ffffff) 100%);
  border-radius: var(--radius-lg, 0.75rem);
  border: 1px solid var(--color-gray-200, #e5e7eb);
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  
  &:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
    border-color: var(--color-primary, #2563eb);
  }
  
  @media (max-width: 768px) {
    padding: var(--space-md, 1rem);
    flex-direction: column;
    text-align: center;
  }
}

.stat-icon {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: var(--radius-full, 9999px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-inverse, #ffffff);
  
  svg {
    width: 24px;
    height: 24px;
  }
  
  &.total {
    background: linear-gradient(135deg, var(--color-primary, #2563eb) 0%, var(--color-primary-dark, #1e40af) 100%);
  }
  
  &.active {
    background: linear-gradient(135deg, var(--color-success, #10b981) 0%, var(--color-secondary-dark, #059669) 100%);
  }
  
  &.completed {
    background: linear-gradient(135deg, var(--color-accent, #8b5cf6) 0%, var(--color-accent-dark, #7c3aed) 100%);
  }
  
  &.recent {
    background: linear-gradient(135deg, var(--color-info, #3b82f6) 0%, var(--color-info-dark, #2563eb) 100%);
  }
  
  &.eprescription {
    background: linear-gradient(135deg, var(--color-warning, #f59e0b) 0%, var(--color-warning-dark, #d97706) 100%);
  }
  
  @media (max-width: 768px) {
    width: 40px;
    height: 40px;
    min-width: 40px;
    
    svg {
      width: 20px;
      height: 20px;
    }
  }
}

.stat-content {
  flex: 1;
  min-width: 0;
  
  h3 {
    font-size: var(--font-size-2xl, 1.5rem);
    font-weight: var(--font-weight-bold, 700);
    color: var(--text-primary, #111827);
    margin: 0 0 var(--space-xs, 0.25rem) 0;
    line-height: var(--line-height-tight, 1.25);
  }
  
  p {
    font-size: var(--font-size-sm, 0.875rem);
    color: var(--text-secondary, #4b5563);
    margin: 0;
    line-height: var(--line-height-normal, 1.5);
  }
  
  small {
    font-size: var(--font-size-xs, 0.75rem);
    color: var(--text-tertiary, #6b7280);
    display: block;
    margin-top: var(--space-xs, 0.25rem);
  }
}

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

.error-message {
  padding: var(--space-md, 1rem) var(--space-lg, 1.5rem);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(239, 68, 68, 0.05) 100%);
  border-left: 4px solid var(--color-danger, #ef4444);
  border-radius: var(--radius-md, 0.5rem);
  color: var(--color-danger, #ef4444);
  font-size: var(--font-size-sm, 0.875rem);
  margin-bottom: var(--space-lg, 1.5rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md, 1rem);
  box-shadow: var(--shadow-sm, 0 1px 3px 0 rgba(0, 0, 0, 0.1));
  animation: slideInDown 0.3s ease-out;
  
  .error-content {
    display: flex;
    align-items: center;
    gap: var(--space-sm, 0.5rem);
    flex: 1;
  }
  
  .error-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }
  
  .error-text {
    flex: 1;
    
    strong {
      font-weight: var(--font-weight-semibold, 600);
    }
  }
  
  .error-close {
    background: none;
    border: none;
    color: var(--color-danger, #ef4444);
    font-size: var(--font-size-xl, 1.25rem);
    cursor: pointer;
    padding: var(--space-xs, 0.25rem);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm, 0.25rem);
    transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
    flex-shrink: 0;
    
    &:hover {
      background: var(--color-danger, #ef4444);
      color: var(--text-inverse, #ffffff);
      transform: scale(1.1);
    }
    
    &:active {
      transform: scale(0.95);
    }
  }
}

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

// ============================================================================
// Loading Overlay
// ============================================================================

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.2s ease-out;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg, 1.5rem);
}

.spinner {
  width: 50px;
  height: 50px;
  animation: rotate 1s linear infinite;
}

.spinner .path {
  stroke: var(--color-primary, #2563eb);
  stroke-linecap: round;
  stroke-dasharray: 90, 150;
  stroke-dashoffset: 0;
  animation: dash 1.5s ease-in-out infinite;
}

.loading-text {
  font-size: var(--font-size-base, 1rem);
  color: var(--text-secondary, #4b5563);
  font-weight: var(--font-weight-medium, 500);
  margin: 0;
}

@keyframes rotate {
  100% {
    transform: rotate(360deg);
  }
}

@keyframes dash {
  0% {
    stroke-dasharray: 1, 150;
    stroke-dashoffset: 0;
  }
  50% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -35;
  }
  100% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -124;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

// ============================================================================
// Prescription Controls
// ============================================================================

.prescription-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-lg, 1.5rem);
  margin-bottom: var(--space-lg, 1.5rem);
  flex-wrap: wrap;
  
  @media (max-width: 768px) {
    flex-direction: column;
    align-items: stretch;
  }
}

.controls-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm, 0.5rem);
  flex-wrap: wrap;
  flex: 1;
  
  @media (max-width: 768px) {
    flex-direction: column;
    
    > * {
      width: 100%;
    }
  }
}

.controls-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm, 0.5rem);
  flex-wrap: wrap;
  
  @media (max-width: 768px) {
    width: 100%;
    
    .secondary-button {
      flex: 1;
    }
  }
}

// ============================================================================
// Search Box
// ============================================================================

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 250px;
  
  .search-icon {
    position: absolute;
    left: var(--space-md, 1rem);
    width: 20px;
    height: 20px;
    color: var(--text-secondary, #4b5563);
    pointer-events: none;
    z-index: 1;
    transition: color var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  }
  
  .search-input {
    width: 100%;
    padding: var(--space-sm, 0.5rem) var(--space-xl, 2.5rem) var(--space-sm, 0.5rem) var(--space-2xl, 3rem);
    border: 2px solid var(--color-gray-300, #d1d5db);
    border-radius: var(--radius-md, 0.5rem);
    font-size: var(--font-size-sm, 0.875rem);
    background: var(--bg-primary, #ffffff);
    transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
    
    &:focus {
      outline: none;
      border-color: var(--color-primary, #2563eb);
      box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
      
      + .search-icon {
        color: var(--color-primary, #2563eb);
      }
    }
    
    &::placeholder {
      color: var(--text-tertiary, #6b7280);
    }
  }
  
  .clear-search {
    position: absolute;
    right: var(--space-sm, 0.5rem);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-gray-200, #e5e7eb);
    border: none;
    border-radius: var(--radius-full, 9999px);
    color: var(--text-secondary, #4b5563);
    cursor: pointer;
    transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
    z-index: 1;
    
    svg {
      width: 14px;
      height: 14px;
    }
    
    &:hover {
      background: var(--color-gray-300, #d1d5db);
      color: var(--text-primary, #111827);
      transform: scale(1.1);
    }
    
    &:active {
      transform: scale(0.95);
    }
  }
}

// ============================================================================
// Filter Select
// ============================================================================

.filter-select {
  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);
  font-size: var(--font-size-sm, 0.875rem);
  background: var(--bg-primary, #ffffff);
  color: var(--text-primary, #111827);
  cursor: pointer;
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  
  &:focus {
    outline: none;
    border-color: var(--color-primary, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  }
  
  &:hover {
    border-color: var(--color-primary, #2563eb);
  }
}

// ============================================================================
// Date Range
// ============================================================================

.date-range {
  display: flex;
  align-items: center;
  gap: var(--space-sm, 0.5rem);
  
  input[type="date"] {
    padding: var(--space-sm, 0.5rem);
    border: 2px solid var(--color-gray-300, #d1d5db);
    border-radius: var(--radius-md, 0.5rem);
    font-size: var(--font-size-sm, 0.875rem);
    transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
    
    &:focus {
      outline: none;
      border-color: var(--color-primary, #2563eb);
      box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    }
  }
  
  span {
    color: var(--text-secondary, #4b5563);
    font-size: var(--font-size-sm, 0.875rem);
  }
}

// ============================================================================
// View Toggle
// ============================================================================

.view-toggle {
  display: flex;
  gap: var(--space-xs, 0.25rem);
  background: var(--color-gray-100, #f3f4f6);
  border-radius: var(--radius-md, 0.5rem);
  padding: var(--space-xs, 0.25rem);
}

.toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm, 0.5rem);
  border: none;
  background: transparent;
  border-radius: var(--radius-sm, 0.25rem);
  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-200, #e5e7eb);
    color: var(--text-primary, #111827);
  }
  
  &.active {
    background: var(--bg-primary, #ffffff);
    color: var(--color-primary, #2563eb);
    box-shadow: var(--shadow-sm, 0 1px 3px 0 rgba(0, 0, 0, 0.1));
  }
}

// ============================================================================
// Bulk Actions Bar
// ============================================================================

.bulk-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md, 1rem);
  padding: var(--space-md, 1rem);
  background: linear-gradient(135deg, var(--color-primary, #2563eb) 0%, var(--color-primary-dark, #1e40af) 100%);
  border-radius: var(--radius-lg, 0.75rem);
  margin-bottom: var(--space-lg, 1.5rem);
  color: var(--text-inverse, #ffffff);
  box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
  
  .selection-count {
    font-size: var(--font-size-sm, 0.875rem);
    font-weight: var(--font-weight-medium, 500);
  }
  
  .bulk-actions {
    display: flex;
    gap: var(--space-sm, 0.5rem);
    flex-wrap: wrap;
  }
  
  .secondary-button {
    background: var(--bg-primary, #ffffff);
    color: var(--color-primary, #2563eb);
    border-color: var(--bg-primary, #ffffff);
    
    &:hover {
      background: var(--color-gray-100, #f3f4f6);
      color: var(--color-primary-dark, #1e40af);
    }
  }
  
  @media (max-width: 768px) {
    flex-direction: column;
    align-items: stretch;
    
    .bulk-actions {
      width: 100%;
      
      .secondary-button {
        flex: 1;
      }
    }
  }
}

// ============================================================================
// Card Container
// ============================================================================

.card {
  background: var(--bg-primary, #ffffff);
  border-radius: var(--radius-xl, 1rem);
  padding: var(--space-lg, 1.5rem);
  box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
  border: 1px solid var(--color-gray-200, #e5e7eb);
  margin-bottom: var(--space-lg, 1.5rem);
  width: 100%;
  box-sizing: border-box;
  overflow: visible;
  position: relative;
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  
  &:hover {
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
  }
  
  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);
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  
  .card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-md, 1rem);
    margin-bottom: var(--space-lg, 1.5rem);
    padding-bottom: var(--space-lg, 1.5rem);
    border-bottom: 1px solid var(--color-gray-200, #e5e7eb);
    
    .header-content {
      flex: 1;
      
      h3 {
        margin: 0 0 var(--space-xs, 0.25rem) 0;
      }
    }
    
    .card-subtitle {
      font-size: var(--font-size-sm, 0.875rem);
      color: var(--text-secondary, #4b5563);
      margin: 0;
      line-height: var(--line-height-normal, 1.5);
    }
    
    .close-button {
      width: 32px;
      height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: var(--color-gray-100, #f3f4f6);
      border: none;
      border-radius: var(--radius-md, 0.5rem);
      color: var(--text-secondary, #4b5563);
      cursor: pointer;
      transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
      flex-shrink: 0;
      
      svg {
        width: 18px;
        height: 18px;
      }
      
      &:hover {
        background: var(--color-gray-200, #e5e7eb);
        color: var(--text-primary, #111827);
        transform: scale(1.1);
      }
      
      &:active {
        transform: scale(0.95);
      }
    }
  }
  
  @media (max-width: 768px) {
    padding: var(--space-md, 1rem);
    border-radius: var(--radius-lg, 0.75rem);
  }
}

.create-form-card,
.update-form-card {
  animation: slideInUp 0.3s ease-out;
  box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
}

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

// ============================================================================
// Forms
// ============================================================================

.form-group {
  margin-bottom: var(--space-lg, 1.5rem);
  
  &:last-child {
    margin-bottom: 0;
  }
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md, 1rem);
  
  @media (max-width: 768px) {
    grid-template-columns: 1fr;
  }
}

.form-label {
  display: block;
  font-size: var(--font-size-sm, 0.875rem);
  font-weight: var(--font-weight-medium, 500);
  color: var(--text-primary, #111827);
  margin-bottom: var(--space-sm, 0.5rem);
  
  .required-asterisk {
    color: var(--color-danger, #ef4444);
    margin-left: var(--space-xs, 0.25rem);
  }
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  
  .input-icon {
    position: absolute;
    left: var(--space-md, 1rem);
    width: 20px;
    height: 20px;
    color: var(--text-secondary, #4b5563);
    pointer-events: none;
    z-index: 1;
    transition: color var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  }
  
  .form-input,
  .form-textarea {
    padding-left: var(--space-2xl, 3rem);
    
    &:focus + .input-icon {
      color: var(--color-primary, #2563eb);
    }
  }
  
  select.form-input {
    padding-left: var(--space-2xl, 3rem);
    padding-right: var(--space-2xl, 3rem);
    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='%234b5563' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-md, 1rem) center;
    appearance: none;
    cursor: pointer;
    
    &:focus {
      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='%232563eb' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    }
  }
}

.form-input,
.form-textarea {
  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);
  font-size: var(--font-size-base, 1rem);
  background: var(--bg-primary, #ffffff);
  color: var(--text-primary, #111827);
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  
  &:focus {
    outline: none;
    border-color: var(--color-primary, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  }
  
  &:disabled {
    background: var(--color-gray-100, #f3f4f6);
    cursor: not-allowed;
    opacity: 0.7;
  }
  
  &::placeholder {
    color: var(--text-tertiary, #6b7280);
  }
  
  &:invalid:not(:placeholder-shown) {
    border-color: var(--color-danger, #ef4444);
  }
  
  &:valid:not(:placeholder-shown) {
    border-color: var(--color-success, #10b981);
  }
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
  font-family: inherit;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-md, 1rem);
  margin-top: var(--space-xl, 2rem);
  padding-top: var(--space-lg, 1.5rem);
  border-top: 1px solid var(--color-gray-200, #e5e7eb);
  align-items: center;
  flex-wrap: wrap;
  
  @media (max-width: 768px) {
    flex-direction: column;
    width: 100%;
    
    button {
      width: 100%;
    }
  }
  
  .cancel-button,
  .submit-button {
    padding: var(--space-md, 1rem) var(--space-xl, 2rem);
    border: none;
    border-radius: var(--radius-md, 0.5rem);
    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));
    position: relative;
    overflow: visible;
    min-width: 140px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm, 0.5rem);
    
    &:disabled {
      opacity: 0.7;
      cursor: not-allowed;
      pointer-events: none;
    }
  }
  
  .cancel-button {
    background: var(--bg-primary, #ffffff);
    color: var(--text-secondary, #4b5563);
    border: 2px solid var(--color-gray-300, #d1d5db);
    box-shadow: var(--shadow-xs, 0 1px 2px 0 rgba(0, 0, 0, 0.05));
    
    &:hover:not(:disabled) {
      background: var(--color-gray-100, #f3f4f6);
      border-color: var(--color-gray-400, #9ca3af);
      box-shadow: var(--shadow-sm, 0 1px 3px 0 rgba(0, 0, 0, 0.1));
      transform: translateY(-1px);
    }
    
    &:active:not(:disabled) {
      transform: translateY(0) scale(0.98);
    }
  }
  
  .submit-button {
    background: linear-gradient(135deg, var(--color-primary, #2563eb) 0%, var(--color-primary-dark, #1e40af) 100%);
    color: var(--text-inverse, #ffffff);
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06));
    position: relative;
    
    &::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-primary-dark, #1e40af) 0%, var(--color-primary, #2563eb) 100%);
      box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05));
      transform: translateY(-2px);
      
      &::before {
        width: 300px;
        height: 300px;
      }
    }
    
    &:active:not(:disabled) {
      transform: translateY(0) scale(0.98);
    }
    
    .loading-content {
      display: inline-flex;
      align-items: center;
      gap: var(--space-sm, 0.5rem);
    }
    
    .spinner-small {
      width: 16px;
      height: 16px;
      animation: spin 0.8s linear infinite;
    }
  }
}

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

// ============================================================================
// Prescription Grid (Card View)
// ============================================================================

.prescription-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: var(--space-lg, 1.5rem);
  width: 100%;
  box-sizing: border-box;
  overflow: visible;
  
  @media (max-width: 1024px) {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-md, 1rem);
  }
  
  @media (max-width: 768px) {
    grid-template-columns: 1fr;
    gap: var(--space-md, 1rem);
  }
  
  @media (max-width: 480px) {
    grid-template-columns: 1fr;
    gap: var(--space-sm, 0.5rem);
  }
}

.prescription-card {
  background: var(--bg-primary, #ffffff);
  border-radius: var(--radius-xl, 1rem);
  padding: var(--space-lg, 1.5rem);
  box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
  border: 2px solid var(--color-gray-200, #e5e7eb);
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  position: relative;
  overflow: visible;
  width: 100%;
  box-sizing: border-box;
  min-height: 200px;
  
  &::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%);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition-slow, 300ms cubic-bezier(0.4, 0, 0.2, 1));
    z-index: 1;
  }
  
  &:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
    border-color: var(--color-primary, #2563eb);
    z-index: 10;
    
    &::before {
      transform: scaleX(1);
    }
  }
  
  &.selected {
    border-color: var(--color-primary, #2563eb);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.05) 0%, rgba(255, 255, 255, 1) 100%);
    z-index: 5;
  }
  
  @media (max-width: 768px) {
    padding: var(--space-md, 1rem);
    min-height: auto;
  }
}

.prescription-card-checkbox {
  margin-bottom: var(--space-md, 1rem);
  
  input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--color-primary, #2563eb);
  }
}

.prescription-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md, 1rem);
  margin-bottom: var(--space-lg, 1.5rem);
  padding-bottom: var(--space-lg, 1.5rem);
  border-bottom: 1px solid var(--color-gray-200, #e5e7eb);
  flex-wrap: wrap;
  min-width: 0;
  
  > div:first-child {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    
    h3 {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      word-wrap: break-word;
      
      @media (max-width: 480px) {
        white-space: normal;
      }
    }
  }
  
  @media (max-width: 640px) {
    flex-direction: column;
    align-items: stretch;
  }
}

.prescription-header-right {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm, 0.5rem);
  flex-direction: column;
  flex-shrink: 0;
  
  @media (max-width: 640px) {
    flex-direction: row;
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

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

.prescription-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xs, 0.25rem) var(--space-md, 1rem);
  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;
  white-space: nowrap;
  
  &.status-active {
    background: var(--color-success-light, #d1fae5);
    color: var(--color-success, #10b981);
    border: 1px solid var(--color-success, #10b981);
  }
  
  &.status-completed {
    background: var(--color-info-light, #dbeafe);
    color: var(--color-info, #3b82f6);
    border: 1px solid var(--color-info, #3b82f6);
  }
  
  &.status-cancelled {
    background: var(--color-danger-light, #fee2e2);
    color: var(--color-danger, #ef4444);
    border: 1px solid var(--color-danger, #ef4444);
  }
  
  &.status-discontinued {
    background: var(--color-gray-100, #f3f4f6);
    color: var(--color-gray-700, #374151);
    border: 1px solid var(--color-gray-300, #d1d5db);
  }
}

.prescription-number {
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--text-secondary, #4b5563);
  margin: var(--space-xs, 0.25rem) 0;
  font-family: 'Monaco', 'Courier New', monospace;
}

.prescription-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm, 0.5rem);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-sm, 0.5rem);
  padding: var(--space-sm, 0.5rem) 0;
  width: 100%;
  box-sizing: border-box;
  
  &:not(:last-child) {
    border-bottom: 1px solid var(--color-gray-100, #f3f4f6);
  }
  
  &.e-prescription-sent {
    display: flex;
    align-items: center;
    gap: var(--space-xs, 0.25rem);
    color: var(--color-success, #10b981);
    font-weight: var(--font-weight-medium, 500);
    font-size: var(--font-size-sm, 0.875rem);
    padding: var(--space-sm, 0.5rem);
    background: var(--color-success-light, #d1fae5);
    border-radius: var(--radius-sm, 0.25rem);
    margin-top: var(--space-xs, 0.25rem);
    flex-wrap: wrap;
    
    svg {
      width: 16px;
      height: 16px;
      flex-shrink: 0;
    }
  }
  
  @media (max-width: 480px) {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs, 0.25rem);
  }
}

.detail-label {
  font-size: var(--font-size-sm, 0.875rem);
  font-weight: var(--font-weight-medium, 500);
  color: var(--text-secondary, #4b5563);
  flex-shrink: 0;
  white-space: nowrap;
}

.detail-value {
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--text-primary, #111827);
  text-align: right;
  word-break: break-word;
  overflow-wrap: break-word;
  flex: 1;
  min-width: 0;
  
  &.instructions-text {
    text-align: left;
    font-style: italic;
    color: var(--text-secondary, #4b5563);
    white-space: normal;
  }
  
  @media (max-width: 480px) {
    text-align: left;
    width: 100%;
  }
}

// ============================================================================
// Prescription Table
// ============================================================================

.prescription-table-container {
  overflow-x: auto;
  overflow-y: visible;
  width: 100%;
  -webkit-overflow-scrolling: touch;
  position: relative;
  
  &::-webkit-scrollbar {
    height: 8px;
  }
  
  &::-webkit-scrollbar-track {
    background: var(--color-gray-100, #f3f4f6);
    border-radius: var(--radius-sm, 0.25rem);
  }
  
  &::-webkit-scrollbar-thumb {
    background: var(--color-gray-400, #9ca3af);
    border-radius: var(--radius-sm, 0.25rem);
    
    &:hover {
      background: var(--color-gray-500, #6b7280);
    }
  }
}

.prescription-table {
  width: 100%;
  min-width: 1200px;
  border-collapse: collapse;
  font-size: var(--font-size-sm, 0.875rem);
  table-layout: auto;
  
  thead {
    background: linear-gradient(135deg, var(--color-gray-50, #f9fafb) 0%, var(--bg-primary, #ffffff) 100%);
    border-bottom: 2px solid var(--color-gray-300, #d1d5db);
  }
  
  th {
    padding: var(--space-md, 1rem);
    text-align: left;
    font-weight: var(--font-weight-semibold, 600);
    color: var(--text-primary, #111827);
    white-space: nowrap;
    
    &.sortable {
      cursor: pointer;
      user-select: none;
      transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
      
      &:hover {
        background: var(--color-gray-100, #f3f4f6);
      }
    }
    
    .sort-indicator {
      margin-left: var(--space-xs, 0.25rem);
      color: var(--color-primary, #2563eb);
    }
  }
  
  td {
    padding: var(--space-md, 1rem);
    border-bottom: 1px solid var(--color-gray-200, #e5e7eb);
    color: var(--text-primary, #111827);
  }
  
  tbody tr {
    transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
    
    &:hover {
      background: var(--color-gray-50, #f9fafb);
    }
    
    &.selected {
      background: linear-gradient(135deg, rgba(37, 99, 235, 0.05) 0%, rgba(255, 255, 255, 1) 100%);
    }
  }
  
  .checkbox-column {
    width: 40px;
    text-align: center;
    
    input[type="checkbox"] {
      width: 18px;
      height: 18px;
      cursor: pointer;
      accent-color: var(--color-primary, #2563eb);
    }
  }
  
  .prescription-number-cell {
    font-family: 'Monaco', 'Courier New', monospace;
    font-weight: var(--font-weight-semibold, 600);
    color: var(--color-primary, #2563eb);
  }
  
  .e-prescription-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs, 0.25rem);
    color: var(--color-success, #10b981);
    font-size: var(--font-size-xs, 0.75rem);
    font-weight: var(--font-weight-medium, 500);
    
    svg {
      width: 14px;
      height: 14px;
    }
  }
  
  .not-sent {
    color: var(--text-tertiary, #6b7280);
  }
  
  .actions-column {
    width: 120px;
  }
  
  @media (max-width: 768px) {
    font-size: var(--font-size-xs, 0.75rem);
    
    th, td {
      padding: var(--space-sm, 0.5rem);
    }
  }
}

.table-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs, 0.25rem);
}

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

// ============================================================================
// Dropdown
// ============================================================================

.dropdown {
  position: relative;
  z-index: 100;
  
  .dropdown-menu {
    position: absolute;
    top: calc(100% + var(--space-xs, 0.25rem));
    right: 0;
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--color-gray-300, #d1d5db);
    border-radius: var(--radius-md, 0.5rem);
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
    min-width: 180px;
    max-width: 250px;
    z-index: 1000;
    display: none;
    overflow: visible;
    white-space: nowrap;
    
    // Ensure dropdown is visible even if parent has overflow hidden
    @media (min-width: 769px) {
      position: fixed;
      transform: translateX(calc(-100% + 32px));
    }
    
    button {
      display: block;
      width: 100%;
      padding: var(--space-sm, 0.5rem) var(--space-md, 1rem);
      border: none;
      background: transparent;
      text-align: left;
      font-size: var(--font-size-sm, 0.875rem);
      color: var(--text-primary, #111827);
      cursor: pointer;
      transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      
      &:hover {
        background: var(--color-gray-100, #f3f4f6);
      }
    }
  }
  
  &:hover .dropdown-menu,
  .dropdown-menu:hover {
    display: block;
  }
  
  // Fix for table cells
  .prescription-table & {
    position: static;
    
    .dropdown-menu {
      position: absolute;
      right: 0;
      top: calc(100% + var(--space-xs, 0.25rem));
    }
  }
}

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

.empty-state-card {
  animation: fadeIn 0.4s ease-out;
}

.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;
  
  .empty-icon-wrapper {
    margin-bottom: var(--space-xl, 2rem);
    padding: var(--space-lg, 1.5rem);
    background: linear-gradient(135deg, var(--color-gray-50, #f9fafb) 0%, rgba(255, 255, 255, 1) 100%);
    border-radius: var(--radius-full, 9999px);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .empty-icon {
    width: 80px;
    height: 80px;
    color: var(--color-gray-400, #9ca3af);
    opacity: 0.6;
    animation: float 3s ease-in-out infinite;
  }
  
  .empty-content {
    max-width: 500px;
    
    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;
      line-height: var(--line-height-normal, 1.5);
    }
  }
  
  .empty-actions {
    margin-top: var(--space-lg, 1.5rem);
  }
  
  @media (max-width: 768px) {
    padding: var(--space-2xl, 3rem) var(--space-lg, 1.5rem);
    
    .empty-icon-wrapper {
      padding: var(--space-md, 1rem);
    }
    
    .empty-icon {
      width: 60px;
      height: 60px;
    }
    
    .empty-content h3 {
      font-size: var(--font-size-xl, 1.25rem);
    }
  }
}

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

// ============================================================================
// Debug Toggle
// ============================================================================

.debug-toggle {
  margin-bottom: var(--space-md, 1rem);
}

.debug-pre {
  background: var(--color-gray-100, #f3f4f6);
  padding: var(--space-md, 1rem);
  border-radius: var(--radius-md, 0.5rem);
  font-size: var(--font-size-xs, 0.75rem);
  font-family: 'Monaco', 'Courier New', monospace;
  overflow-x: auto;
  margin-bottom: var(--space-lg, 1.5rem);
  border: 1px solid var(--color-gray-300, #d1d5db);
}

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

@media (max-width: 640px) {
  .prescription-card {
    border-radius: var(--radius-lg, 0.75rem);
  }
  
  .prescription-header {
    flex-direction: column;
    gap: var(--space-sm, 0.5rem);
    
    > div {
      width: 100%;
    }
  }
  
  .prescription-header-right {
    width: 100%;
    flex-direction: row;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  
  .detail-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs, 0.25rem);
    
    .detail-value {
      text-align: left;
      width: 100%;
    }
  }
  
  .table-actions {
    flex-wrap: wrap;
  }
  
  .prescription-table {
    min-width: 800px;
  }
}

// Ensure all containers allow overflow
.prescription-list-header {
  width: 100%;
  overflow: visible;
  
  h3 {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
}

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

@media print {
  .prescriptions-section {
    padding: 0;
  }
  
  .section-header,
  .prescription-controls,
  .bulk-actions-bar,
  .header-actions,
  .prescription-actions,
  .form-actions,
  .icon-button,
  .dropdown {
    display: none;
  }
  
  .prescription-card,
  .card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid var(--color-gray-300, #d1d5db);
    margin-bottom: var(--space-md, 1rem);
    
    &:hover {
      transform: none;
      box-shadow: none;
    }
    
    &::before {
      display: none;
    }
  }
  
  .prescription-table {
    font-size: var(--font-size-xs, 0.75rem);
    
    th, td {
      padding: var(--space-xs, 0.25rem);
    }
  }
}

