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

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

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

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

.patients-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);
  
  @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);
  }
}

// ============================================================================
// Refresh Button
// ============================================================================

.refresh-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-primary-dark, #1e40af) 100%);
  color: var(--text-inverse, #ffffff);
  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));
  box-shadow: var(--shadow-sm, 0 1px 3px 0 rgba(0, 0, 0, 0.1));
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  
  svg {
    width: 18px;
    height: 18px;
    transition: transform var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
    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-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);
    
    svg {
      transform: rotate(180deg);
    }
    
    &::before {
      width: 300px;
      height: 300px;
    }
  }
  
  &:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
  }
  
  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
  }
  
  @media (max-width: 768px) {
    width: 100%;
    justify-content: center;
  }
}

// ============================================================================
// Search Container
// ============================================================================

.search-container {
  display: block;
  width: 100%;
  margin-bottom: var(--space-xl, 2rem);
  visibility: visible;
  opacity: 1;
  
  @media (max-width: 768px) {
    margin-bottom: var(--space-lg, 1.5rem);
  }
}

.search-box {
  position: relative;
  display: flex !important;
  align-items: center;
  width: 100%;
  min-height: 48px;
  background: var(--bg-primary, #ffffff);
  border: 2px solid var(--color-gray-300, #d1d5db);
  border-radius: var(--radius-lg, 0.75rem);
  padding: var(--space-sm, 0.5rem) var(--space-md, 1rem);
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  box-shadow: var(--shadow-sm, 0 1px 3px 0 rgba(0, 0, 0, 0.1));
  visibility: visible;
  opacity: 1;
  
  &:focus-within {
    border-color: var(--color-primary, #2563eb);
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1)), 0 0 0 3px rgba(37, 99, 235, 0.1);
  }
  
  .search-icon {
    width: 20px;
    height: 20px;
    color: var(--text-secondary, #6b7280);
    flex-shrink: 0;
    margin-right: var(--space-sm, 0.5rem);
  }
  
  .search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: var(--font-size-base, 1rem);
    color: var(--text-primary, #111827);
    background: transparent;
    min-width: 200px;
    width: 100%;
    
    &::placeholder {
      color: var(--text-tertiary, #9ca3af);
    }
    
    &:focus {
      outline: none;
    }
  }
  
  .clear-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    border-radius: var(--radius-sm, 0.25rem);
    transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
    flex-shrink: 0;
    margin-left: var(--space-xs, 0.25rem);
    
    svg {
      width: 16px;
      height: 16px;
    }
    
    &:hover {
      background: var(--color-gray-100, #f3f4f6);
      color: var(--text-primary, #111827);
    }
    
    &:active {
      transform: scale(0.95);
    }
  }
  
  @media (max-width: 768px) {
    padding: var(--space-xs, 0.375rem) var(--space-sm, 0.75rem);
    
    .search-icon {
      width: 18px;
      height: 18px;
    }
    
    .search-input {
      font-size: var(--font-size-sm, 0.875rem);
    }
  }
}

.search-results-info {
  margin-top: var(--space-sm, 0.5rem);
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--text-secondary, #6b7280);
  padding-left: var(--space-xs, 0.25rem);
  
  @media (max-width: 768px) {
    font-size: var(--font-size-xs, 0.75rem);
  }
}

.clear-search-link {
  margin-top: var(--space-md, 1rem);
  padding: var(--space-xs, 0.5rem) var(--space-md, 1rem);
  font-size: var(--font-size-sm, 0.875rem);
  font-weight: var(--font-weight-medium, 500);
  color: var(--color-primary, #2563eb);
  background: var(--color-primary-50, #eff6ff);
  border: 1px solid var(--color-primary-200, #bfdbfe);
  border-radius: var(--radius-md, 0.5rem);
  cursor: pointer;
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  
  &:hover {
    background: var(--color-primary-100, #dbeafe);
    border-color: var(--color-primary-300, #93c5fd);
    color: var(--color-primary-700, #1d4ed8);
  }
  
  &:active {
    transform: scale(0.98);
  }
}

// ============================================================================
// Patients Grid
// ============================================================================

.patients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: var(--space-lg, 1.5rem);
  
  @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);
  }
}

// ============================================================================
// Patient Card
// ============================================================================

.patient-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), 0 2px 4px -1px rgba(0, 0, 0, 0.06));
  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;
  
  &::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));
  }
  
  &:hover {
    transform: translateY(-4px);
    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));
    border-color: var(--color-primary, #2563eb);
    
    &::before {
      transform: scaleX(1);
    }
  }
  
  @media (max-width: 768px) {
    padding: var(--space-md, 1rem);
    border-radius: var(--radius-lg, 0.75rem);
  }
}

// ============================================================================
// Patient Header
// ============================================================================

.patient-header {
  display: flex;
  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);
  
  @media (max-width: 480px) {
    gap: var(--space-sm, 0.5rem);
  }
}

// ============================================================================
// Patient Avatar
// ============================================================================

.patient-avatar {
  width: 64px;
  height: 64px;
  min-width: 64px;
  border-radius: var(--radius-full, 9999px);
  background: linear-gradient(135deg, var(--color-primary, #2563eb) 0%, var(--color-accent, #8b5cf6) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-inverse, #ffffff);
  box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  
  svg {
    width: 32px;
    height: 32px;
  }
  
  .patient-card:hover & {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
  }
  
  @media (max-width: 480px) {
    width: 56px;
    height: 56px;
    min-width: 56px;
    
    svg {
      width: 28px;
      height: 28px;
    }
  }
}

// ============================================================================
// Patient Info
// ============================================================================

.patient-info {
  flex: 1;
  min-width: 0;
}

.patient-name {
  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-xs, 0.25rem) 0;
  line-height: var(--line-height-tight, 1.25);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  
  @media (max-width: 768px) {
    font-size: var(--font-size-lg, 1.125rem);
  }
}

.patient-email {
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--text-secondary, #4b5563);
  margin: 0 0 var(--space-xs, 0.25rem) 0;
  line-height: var(--line-height-normal, 1.5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: var(--space-xs, 0.25rem);
  
  &::before {
    content: '✉';
    font-size: var(--font-size-xs, 0.75rem);
    opacity: 0.6;
  }
}

.patient-id {
  font-size: var(--font-size-xs, 0.75rem);
  color: var(--text-tertiary, #6b7280);
  margin: 0;
  line-height: var(--line-height-normal, 1.5);
  font-family: 'Monaco', 'Courier New', monospace;
  background: var(--color-gray-100, #f3f4f6);
  padding: var(--space-xs, 0.25rem) var(--space-sm, 0.5rem);
  border-radius: var(--radius-sm, 0.25rem);
  display: inline-block;
  
  &::before {
    content: 'ID: ';
    opacity: 0.7;
  }
}

// ============================================================================
// Patient Details
// ============================================================================

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

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm, 0.5rem);
  padding: var(--space-sm, 0.5rem) 0;
  
  &:not(:last-child) {
    border-bottom: 1px solid var(--color-gray-100, #f3f4f6);
  }
  
  @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);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.detail-value {
  font-size: var(--font-size-base, 1rem);
  color: var(--text-primary, #111827);
  font-weight: var(--font-weight-medium, 500);
  text-align: right;
  word-break: break-word;
  
  @media (max-width: 480px) {
    text-align: left;
  }
}

// ============================================================================
// 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-primary, #ffffff);
  border-radius: var(--radius-xl, 1rem);
  box-shadow: var(--shadow-sm, 0 1px 3px 0 rgba(0, 0, 0, 0.1));
  border: 2px dashed var(--color-gray-300, #d1d5db);
  
  .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;
    
    @media (max-width: 768px) {
      width: 60px;
      height: 60px;
    }
  }
  
  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;
    
    @media (max-width: 768px) {
      font-size: var(--font-size-xl, 1.25rem);
    }
  }
  
  p {
    font-size: var(--font-size-base, 1rem);
    color: var(--text-secondary, #4b5563);
    margin: 0;
    max-width: 400px;
    line-height: var(--line-height-normal, 1.5);
    
    @media (max-width: 768px) {
      font-size: var(--font-size-sm, 0.875rem);
    }
  }
  
  @media (max-width: 768px) {
    padding: var(--space-2xl, 3rem) var(--space-lg, 1.5rem);
  }
}

.search-empty {
  border-color: var(--color-gray-300, #d1d5db);
  background: var(--bg-primary, #ffffff);
  
  .empty-icon {
    color: var(--color-gray-400, #9ca3af);
  }
}

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

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

.patients-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl, 4rem);
  color: var(--text-secondary, #4b5563);
  font-size: var(--font-size-lg, 1.125rem);
  
  &::after {
    content: '';
    width: 20px;
    height: 20px;
    margin-left: var(--space-sm, 0.5rem);
    border: 3px solid var(--color-gray-300, #d1d5db);
    border-top-color: var(--color-primary, #2563eb);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
}

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

// ============================================================================
// Patient Actions
// ============================================================================

.patient-actions {
  display: flex;
  gap: var(--space-sm, 0.5rem);
  margin-top: var(--space-md, 1rem);
  padding-top: var(--space-md, 1rem);
  border-top: 1px solid var(--color-gray-200, #e5e7eb);
  flex-wrap: wrap;
}

.btn-action {
  display: flex;
  align-items: center;
  gap: var(--space-xs, 0.25rem);
  padding: var(--space-xs, 0.5rem) var(--space-sm, 0.75rem);
  font-size: var(--font-size-sm, 0.875rem);
  font-weight: var(--font-weight-medium, 500);
  border-radius: var(--radius-md, 0.5rem);
  cursor: pointer;
  transition: all var(--transition-base, 200ms cubic-bezier(0.4, 0, 0.2, 1));
  border: 1px solid;
  
  svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
  }
  
  &:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm, 0 1px 3px 0 rgba(0, 0, 0, 0.1));
  }
  
  &:active:not(:disabled) {
    transform: translateY(0);
  }
  
  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
  
  @media (max-width: 480px) {
    padding: var(--space-xs, 0.375rem) var(--space-xs, 0.5rem);
    font-size: var(--font-size-xs, 0.75rem);
    flex: 1;
    justify-content: center;
    
    svg {
      width: 14px;
      height: 14px;
    }
  }
}

.btn-chat {
  color: var(--color-primary, #2563eb);
  background: var(--color-primary-50, #eff6ff);
  border-color: var(--color-primary-200, #bfdbfe);
  
  &:hover:not(:disabled) {
    background: var(--color-primary-100, #dbeafe);
    border-color: var(--color-primary-300, #93c5fd);
    color: var(--color-primary-700, #1d4ed8);
  }
}

.btn-appointment {
  color: var(--color-green-600, #16a34a);
  background: var(--color-green-50, #f0fdf4);
  border-color: var(--color-green-200, #bbf7d0);
  
  &:hover:not(:disabled) {
    background: var(--color-green-100, #dcfce7);
    border-color: var(--color-green-300, #86efac);
    color: var(--color-green-700, #15803d);
  }
}

.btn-remove {
  color: var(--color-red-600, #dc2626);
  background: var(--color-red-50, #fef2f2);
  border-color: var(--color-red-200, #fecaca);
  
  &:hover:not(:disabled) {
    background: var(--color-red-100, #fee2e2);
    border-color: var(--color-red-300, #fca5a5);
    color: var(--color-red-700, #b91c1c);
  }
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl, 4rem) var(--space-xl, 2rem);
  text-align: center;
  
  .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-gray-200, #e5e7eb);
    border-top-color: var(--color-primary, #2563eb);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: var(--space-md, 1rem);
  }
  
  p {
    color: var(--text-secondary, #6b7280);
    font-size: var(--font-size-base, 1rem);
  }
}

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

@media (max-width: 640px) {
  .patient-card {
    border-radius: var(--radius-lg, 0.75rem);
  }
  
  .patient-header {
    padding-bottom: var(--space-md, 1rem);
  }
  
  .patient-actions {
    flex-direction: column;
    gap: var(--space-xs, 0.5rem);
  }
  
  .section-header {
    align-items: stretch;
  }
}

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

@media print {
  .patients-section {
    padding: 0;
  }
  
  .section-header {
    margin-bottom: var(--space-md, 1rem);
  }
  
  .refresh-button {
    display: none;
  }
  
  .patient-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;
    }
  }
  
  .patients-grid {
    display: block;
  }
}

