/* Patient Data Card Styles */

.patient-data-container {
  width: 280px;
  height: 100%;
  max-height: 100%;
  border-left: 1px solid var(--border-muted);
  background: var(--info-box-bg);
  border-radius: var(--border-radius);
  overflow: hidden;
  transition: all 0.3s ease-in-out;
  flex-shrink: 0;
  position: relative;
}

/* Discharge Summary - Much wider container to overlap sphere */
.patient-data-container.discharge-summary {
  width: 80vw; /* Use viewport width for responsiveness */
  min-width: 700px;
  max-width: 900px; /* Increase max-width */
  position: absolute;
  right: 0;
  top: 0;
  z-index: 1000;
  box-shadow: -5px 0 20px rgba(0, 0, 0, 0.15);
  border-left: 2px solid var(--accent-color);
}

.diagnostic-area {
  transition: all 0.3s ease;
}

.diagnostic-area.with-patient-data {
  display: flex;
  flex-direction: row;
}

.patient-card {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  height: 100%;
}

.patient-header {
  display: flex;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-muted);
  position: relative;
}

.patient-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: rgba(100, 108, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 1rem;
}

.patient-avatar i {
  color: var(--accent-color);
  width: 24px;
  height: 24px;
}

.patient-summary h3 {
  font-size: 1.1rem;
  font-weight: 500;
  margin: 0;
  color: var(--text-strong);
}

.chief-complaint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0 0;
}

.close-patient-data {
  position: absolute;
  top: 0;
  right: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
}

.close-patient-data i {
  width: 16px;
  height: 16px;
}

.data-section {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-muted);
}

.data-section:last-child {
  border-bottom: none;
}

.data-section h4 {
  font-size: 0.9rem;
  font-weight: 500;
  margin: 0 0 0.75rem 0;
  color: var(--text-strong);
}

/* Vital signs grid */
.vital-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.vital-item {
  display: flex;
  flex-direction: column;
  background-color: rgba(255, 255, 255, 0.05);
  padding: 0.5rem;
  border-radius: 4px;
}

.vital-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.vital-value {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-strong);
}

.trend-up {
  color: var(--high-risk) !important;
}

.trend-down {
  color: var(--high-risk) !important;
}

.unknown {
  color: var(--text-muted) !important;
  font-style: italic;
}

/* Findings list */
.findings-list {
  margin: 0;
  padding: 0 0 0 1.25rem;
}

.findings-list li {
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text-medium);
}

/* Risk factors */
.risk-factor-item {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.75rem;
}

.risk-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.risk-value {
  font-size: 0.85rem;
  color: var(--text-medium);
}

/* Loading overlay styles */
.patient-data-container.loading::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(2px);
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  animation: fade-in 0.3s forwards;
}

.loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 0;
  gap: 1rem;
}

.loading-spinner {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  border-top-color: var(--accent-color);
  animation: spin 1s infinite linear;
}

.loading-indicator p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

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

@keyframes fade-in {
  to {
    opacity: 0.7;
  }
}

.patient-header {
  display: flex;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-muted);
  position: relative;
}

.patient-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: rgba(100, 108, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 1rem;
}

.patient-avatar i {
  color: var(--accent-color);
  width: 24px;
  height: 24px;
}

.patient-summary h3 {
  font-size: 1.1rem;
  font-weight: 500;
  margin: 0;
  color: var(--text-strong);
}

.chief-complaint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0 0;
}

.close-patient-data {
  position: absolute;
  top: 0;
  right: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
}

.close-patient-data i {
  width: 16px;
  height: 16px;
}

.data-section {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-muted);
}

.data-section:last-child {
  border-bottom: none;
}

.data-section h4 {
  font-size: 0.9rem;
  font-weight: 500;
  margin: 0 0 0.75rem 0;
  color: var(--text-strong);
}

/* Vital signs grid */
.vital-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.vital-item {
  display: flex;
  flex-direction: column;
  background-color: var(--vitals-bg);
  padding: 0.5rem;
  border-radius: 4px;
}

.vital-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.vital-value {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-strong);
}

.trend-up {
  color: var(--high-risk);
  position: relative;
}

.trend-up::after {
  content: "↑";
  margin-left: 3px;
}

.trend-down {
  color: var(--high-risk);
  position: relative;
}

.trend-down::after {
  content: "↓";
  margin-left: 3px;
}

.unknown {
  color: var(--text-muted);
  font-style: italic;
}

/* Findings list */
.findings-list {
  margin: 0;
  padding: 0 0 0 1.25rem;
}

.findings-list li {
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text-medium);
}

/* Risk factors */
.risk-factor-item {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.75rem;
}

.risk-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.risk-value {
  font-size: 0.85rem;
  color: var(--text-medium);
}

/* Button styles when active */
.action-button.active {
  background-color: var(--accent-color);
  color: white;
}

/* Animation for card appearance */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.patient-data-container {
  animation: slideInRight 0.3s ease-out forwards;
}

/* Discharge Summary Card Styles */
.discharge-summary-card {
  height: 100%;
  overflow-y: auto;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.97); /* nearly solid for light theme */
  /* fallback for dark theme */
}
.light-theme .discharge-summary-card {
  background: #fff;
}

.discharge-section {
  background: rgba(255, 255, 255, 0.96); /* more solid for content blocks */
  border-radius: var(--border-radius);
  padding: 1.5rem;
  border-left: 4px solid var(--accent-light);
}
.light-theme .discharge-section {
  background: #f8fafd;
}

/* Optionally, for dark theme, use a dark solid background */
:root:not(.light-theme) .discharge-summary-card {
  background: #23243a;
}
:root:not(.light-theme) .discharge-section {
  background: #23243a;
}

.discharge-section h4 {
  color: var(--text-strong);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.discharge-section .section-content {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-medium);
}

.discharge-section .section-content p {
  margin-bottom: 1rem;
}

.discharge-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.discharge-section li {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-medium);
  margin-bottom: 0.6rem;
  padding-left: 1.2rem;
  position: relative;
}

.discharge-section li:before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: bold;
}

.discharge-section .sublist {
  margin-left: 1.5rem;
  margin-top: 0.6rem;
}

.discharge-section .sublist li {
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}

.patient-info-header {
  background: var(--vitals-bg);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin-bottom: 1.5rem;
}

.patient-info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}

.patient-info-grid .info-item {
  font-size: 0.95rem;
  line-height: 1.4;
}

.patient-info-grid .info-label {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
  margin-bottom: 0.4rem;
}

.patient-info-grid .info-value {
  color: var(--text-strong);
  font-weight: 500;
  font-size: 1rem;
}

/* Alert box styling */
.alert-box {
  background: var(--bg-danger, #fee2e2);
  border-left: 4px solid var(--border-danger, #ef4444);
  padding: 1.5rem;
  border-radius: 8px;
  margin: 1.5rem 0;
  color: var(--text-danger, #991b1b);
  font-size: 1rem;
  line-height: 1.6;
}

/* Vital signs in discharge summary */
.vital-signs {
  background: var(--vitals-bg);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin: 1.5rem 0;
}

.discharge-summary-card .vital-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}

.vital-item {
  background: var(--accent-light);
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  color: var(--text-strong);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.vital-value {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-strong);
  margin-bottom: 0.4rem;
}

.vital-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Medications box */
.medications-box {
  background: transparent;
  border-left: none;
  padding: 0;
  border-radius: 0;
  margin: 0.5rem 0;
}

.medications-box ul {
  margin: 0;
  padding: 0 0 0 1.25rem;
}

.medications-box li {
  color: var(--text-medium);
  font-weight: 400;
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 0.4rem;
}

/* Medications list in discharge summary */
.medications-list {
  list-style: disc;
  padding-left: 1.25rem;
  margin: 0;
}

.medications-list li {
  color: var(--text-medium);
  font-weight: 400;
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 0.4rem;
}

/* Discharge footer */
.discharge-footer {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 2px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.signature-section {
  flex: 1;
}

.signature-line {
  border-bottom: 2px solid var(--border-light);
  width: 250px;
  margin: 1.5rem 0 0.75rem 0;
}

.physician-name {
  font-size: 1rem;
  color: var(--text-strong);
  font-weight: 500;
}

.date-section {
  text-align: right;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.discharge-date {
  font-weight: 500;
  color: var(--text-strong);
  margin-top: 0.4rem;
  font-size: 1rem;
}

.lab-results {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.lab-group {
  background: var(--vitals-bg);
  padding: 0.75rem;
  border-radius: var(--border-radius);
}

.lab-group h5 {
  margin-bottom: 0.5rem;
  color: var(--text-strong);
}

.lab-group ul {
  margin: 0;
  padding: 0;
}

.lab-group li {
  font-size: 0.75rem;
  margin-bottom: 0.2rem;
}

/* Patient Data Summary in Discharge Summary */
.patient-data-summary {
  background: var(--vitals-bg);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin: 1.5rem 0;
}

.data-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.data-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.data-label {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
}

.data-value {
  color: var(--text-strong);
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.5;
}

/* Enhanced vital signs grid for discharge summary */
.discharge-summary-card .vital-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}

/* Mobile responsive adjustments for discharge summary */
@media (max-width: 768px) {
  .patient-data-container {
    width: 100%;
    height: auto;
    max-height: 60vh;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    border-left: none;
    border-top: 1px solid var(--border-muted);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
  }
  
  .patient-data-container.discharge-summary {
    width: 100%;
    height: 85vh;
    max-height: 85vh;
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    border-radius: 0;
    box-shadow: none;
    border-left: none;
  }
  
  .discharge-summary-card {
    max-height: 85vh;
    padding: 1rem;
  }
  
  .vital-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
  
  .patient-info-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
  
  .data-grid {
    grid-template-columns: 1fr;
  }
  
  .vitals-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .patient-data-container.discharge-summary {
    width: 600px;
    min-width: 600px;
  }
  
  .patient-info-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .vital-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1200px) {
  .patient-data-container.discharge-summary {
    width: 650px;
    min-width: 650px;
  }
}

@media (min-width: 1400px) {
  .patient-data-container.discharge-summary {
    width: 800px;
    min-width: 800px;
  }
}

@media (max-width: 480px) {
  .vital-grid {
    grid-template-columns: 1fr;
  }
  
  .patient-info-grid {
    grid-template-columns: 1fr;
  }
  
  .discharge-summary-card {
    padding: 0.75rem;
  }
  
  .discharge-section {
    padding: 1rem;
  }
  
  .patient-info-header {
    padding: 1rem;
  }
}

/* --- Two-column Discharge Summary Overlay Styles --- */
.discharge-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 2000;
  background: rgba(20, 22, 34, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s;
}
.discharge-overlay.hidden {
  display: none;
}
.discharge-columns {
  display: flex;
  flex-direction: row;
  background: none;
  border-radius: 18px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
  overflow: hidden;
  max-width: 1200px;
  width: 90vw;
  min-height: 70vh;
  max-height: 90vh;
}
.discharge-patient-col {
  background: var(--info-box-bg, #23243a);
  min-width: 320px;
  max-width: 350px;
  width: 350px;
  padding: 0;
  border-right: 1px solid var(--border-muted);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.discharge-summary-col {
  background: var(--card-bg, #23243a);
  flex: 1 1 0;
  min-width: 400px;
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.discharge-overlay-close {
  position: absolute;
  top: 24px;
  right: 36px;
  background: #23243a;
  color: #fff;
  border: none;
  font-size: 2.2rem;
  font-weight: 700;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  transition: background 0.2s;
}
.discharge-overlay-close:hover {
  background: #3a3b5a;
}
@media (max-width: 900px) {
  .discharge-columns {
    flex-direction: column;
    min-width: 0;
    width: 98vw;
    max-width: 98vw;
    min-height: 0;
    max-height: 98vh;
  }
  .discharge-patient-col, .discharge-summary-col {
    min-width: 0;
    max-width: 100vw;
    width: 100vw;
    border-right: none;
    border-bottom: 1px solid var(--border-muted);
  }
}
/* --- End Two-column Discharge Summary Overlay Styles --- */

/* --- Fix two-column discharge summary drawer overflow --- */
.patient-data-container.discharge-summary {
  width: 70vw;
  min-width: 0;
  max-width: 98vw;
  right: 0;
  left: auto;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  align-items: stretch;
}
.discharge-columns {
  width: 100%;
  max-width: 100vw;
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  overflow: hidden;
}
.discharge-patient-col {
  min-width: 320px;
  max-width: 350px;
  width: 350px;
  flex: 0 0 350px;
  overflow-y: auto;
  border-right: 1px solid var(--border-muted);
  background: var(--info-box-bg, #23243a);
}
.discharge-summary-col {
  flex: 1 1 0;
  min-width: 0;
  max-width: 100%;
  overflow-y: auto;
  background: var(--card-bg, #23243a);
  display: flex;
  flex-direction: column;
}
@media (max-width: 900px) {
  .patient-data-container.discharge-summary {
    width: 100vw;
    min-width: 0;
    max-width: 100vw;
    flex-direction: column;
  }
  .discharge-columns {
    flex-direction: column;
    min-width: 0;
    width: 100vw;
    max-width: 100vw;
  }
  .discharge-patient-col, .discharge-summary-col {
    min-width: 0;
    max-width: 100vw;
    width: 100vw;
    border-right: none;
    border-bottom: 1px solid var(--border-muted);
  }
}
/* --- End fix for discharge summary drawer overflow --- */

/* Updating state styles */
.patient-data-container.updating {
  opacity: 0.7;
  pointer-events: none;
}

.discharge-patient-col.updating {
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

.discharge-patient-col.updating::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(var(--accent-color-rgb), 0.1);
  z-index: 10;
}
