:root {
  --primary: #0ea5e9;
  --primary-glow: rgba(14, 165, 233, 0.5);
  --bg: #0f172a;
  --card-bg: rgba(30, 41, 59, 0.7);
  --border: rgba(255, 255, 255, 0.1);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #2dd4bf;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --font-main: 'Outfit', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
  background-image: 
    radial-gradient(at 0% 0%, rgba(14, 165, 233, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(45, 212, 191, 0.1) 0px, transparent 50%);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

header {
  margin-bottom: 3rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.5rem;
}

.patient-info h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(to right, #0ea5e9, #2dd4bf);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
}

.patient-meta {
  display: flex;
  gap: 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.patient-meta span b {
  color: var(--text);
}

.controls {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.file-input-wrapper {
  display: flex;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.5rem 1rem;
  backdrop-filter: blur(10px);
}

.file-input-wrapper input {
  background: transparent;
  border: none;
  color: var(--text);
  outline: none;
  font-family: inherit;
  width: 150px;
}

button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0 15px var(--primary-glow);
}

button:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 0 25px var(--primary-glow);
}

button:active {
  transform: translateY(0);
}

button.secondary {
  background: transparent;
  border: 1px solid var(--primary);
  box-shadow: none;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1.5rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 1.5rem;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.card:hover {
  border-color: rgba(14, 165, 233, 0.3);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--primary);
}

.card-title svg {
  width: 20px;
  height: 20px;
}

/* Specific Card Layouts */
.col-12 { grid-column: span 12; }
.col-8 { grid-column: span 8; }
.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }

@media (max-width: 1024px) {
  .col-8, .col-4 { grid-column: span 12; }
}

/* Sections */
.overview-text {
  font-size: 1.1rem;
  color: var(--text-muted);
  line-height: 1.8;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.timeline-item {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 0.75rem;
  border-left: 3px solid var(--primary);
  transition: background 0.2s ease;
}

.timeline-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.timeline-date {
  font-weight: 600;
  min-width: 100px;
}

.timeline-content h4 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.timeline-status {
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-radius: 1rem;
  background: rgba(14, 165, 233, 0.1);
  color: var(--primary);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

th {
  text-align: left;
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.95rem;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.tag {
  padding: 0.25rem 0.6rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
}

.tag-primary { background: rgba(14, 165, 233, 0.15); color: #7dd3fc; }
.tag-success { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
.tag-warning { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.tag-danger { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }

/* Diagnosis Blocks */
.diagnosis-group {
  margin-bottom: 2rem;
}

.diagnosis-group h4 {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  text-transform: uppercase;
}

.diagnosis-card {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 0.75rem;
  padding: 1.25rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.diagnosis-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.diagnosis-name {
  font-weight: 600;
  font-size: 1.1rem;
}

.diagnosis-code {
  background: rgba(14, 165, 233, 0.1);
  color: var(--primary);
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.8rem;
  font-family: monospace;
}

.diagnosis-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Action Items */
.action-list {
  list-style: none;
}

.action-item {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-left: 0.5rem;
}

.action-item::before {
  content: '→';
  color: var(--primary);
  font-weight: bold;
}

.sub-actions {
  margin-left: 2rem;
  margin-top: 0.5rem;
  list-style: none;
  border-left: 1px dashed var(--border);
  padding-left: 1rem;
}

.sub-actions li {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Safety Alerts */
.safety-alert {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 2rem;
  display: none; /* hidden by default */
}

.safety-alert.active {
  display: block;
  animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
  0% { border-color: rgba(239, 68, 68, 0.3); }
  50% { border-color: rgba(239, 68, 68, 0.8); }
  100% { border-color: rgba(239, 68, 68, 0.3); }
}

.alert-title {
  color: var(--danger);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

/* Loader */
#loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(5px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  display: none;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(14, 165, 233, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

/* Arabic Support */
[dir="rtl"] {
  text-align: right;
}

.ar-text {
  font-family: 'IBM Plex Sans Arabic', sans-serif;
}
