/* ===== CROWNY MED — Global Medical Cluster PWA ===== */

/* ── Layout ── */
.med-page { padding: 0 1rem 5rem; max-width: 900px; margin: 0 auto; }
.med-page h2 { font-size: 1.4rem; margin: 1rem 0 0.8rem; color: var(--text); }
.med-page h3 { font-size: 1.1rem; margin: 0.8rem 0 0.5rem; color: var(--text-secondary); }

/* ── Tabs ── */
.med-tabs {
  display: flex; gap: 0; border-bottom: 2px solid var(--border);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; margin-bottom: 1rem;
}
.med-tabs::-webkit-scrollbar { display: none; }
.med-tab {
  flex-shrink: 0; padding: 0.6rem 1rem; font-size: 0.85rem; font-weight: 600;
  color: var(--text-secondary); cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -2px; white-space: nowrap; transition: color 0.2s, border-color 0.2s;
  background: none; border-top: none; border-left: none; border-right: none;
}
.med-tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.med-tab:hover { color: var(--text); }

/* ── Cards ── */
.med-card {
  background: var(--bg-card); border-radius: 12px; padding: 1rem;
  margin-bottom: 0.8rem; border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.med-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.5rem;
}
.med-card-header h4 { font-size: 0.95rem; color: var(--text); margin: 0; }
.med-card-body { font-size: 0.85rem; color: var(--text-secondary); }

/* ── Status badges ── */
.med-badge {
  display: inline-block; padding: 0.15rem 0.5rem; border-radius: 6px;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
}
.med-badge-green { background: #dcfce7; color: #166534; }
.med-badge-yellow { background: #fef3c7; color: #92400e; }
.med-badge-red { background: #fee2e2; color: #991b1b; }
.med-badge-blue { background: #dbeafe; color: #1e40af; }
.med-badge-gray { background: #f3f4f6; color: #374151; }

/* ── Buttons ── */
.med-btn {
  display: inline-flex; align-items: center; gap: 0.3rem; border: none;
  border-radius: 8px; padding: 0.5rem 1rem; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: transform 0.1s, opacity 0.2s;
}
.med-btn:active { transform: scale(0.96); }
.med-btn-primary { background: var(--primary); color: var(--bg); }
.med-btn-primary:hover { background: var(--primary-hover); }
.med-btn-gold { background: linear-gradient(135deg, #8B6914, #B8860B); color: #FFF8F0; }
.med-btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.med-btn-outline:hover { background: var(--bg-card); }
.med-btn-danger { background: var(--error); color: #fff; }
.med-btn-sm { padding: 0.3rem 0.7rem; font-size: 0.78rem; }
.med-btn-block { display: flex; width: 100%; justify-content: center; }

/* ── Forms ── */
.med-form-group { margin-bottom: 0.8rem; }
.med-form-group label {
  display: block; font-size: 0.78rem; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 0.25rem;
}
.med-input, .med-select, .med-textarea {
  width: 100%; padding: 0.5rem 0.7rem; border: 1px solid var(--border);
  border-radius: 8px; font-size: 0.85rem; background: var(--bg);
  color: var(--text); outline: none; transition: border-color 0.2s;
}
.med-input:focus, .med-select:focus, .med-textarea:focus {
  border-color: var(--gold);
}
.med-textarea { min-height: 80px; resize: vertical; }

/* ── Tables ── */
.med-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.med-table {
  width: 100%; border-collapse: collapse; font-size: 0.82rem;
}
.med-table th {
  text-align: left; padding: 0.5rem 0.6rem; font-weight: 600;
  color: var(--text-secondary); border-bottom: 2px solid var(--border);
  white-space: nowrap; font-size: 0.75rem; text-transform: uppercase;
}
.med-table td {
  padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border);
  color: var(--text); vertical-align: middle;
}
.med-table tr:hover td { background: rgba(139,105,20,0.04); }

/* ── Stats grid ── */
.med-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.6rem; margin-bottom: 1rem;
}
.med-stat {
  background: var(--bg-card); border-radius: 10px; padding: 0.8rem;
  text-align: center; border: 1px solid var(--border);
}
.med-stat-value { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.med-stat-label { font-size: 0.72rem; color: var(--text-secondary); margin-top: 0.15rem; }

/* ── Score ring ── */
.med-score-ring {
  width: 100px; height: 100px; border-radius: 50%; margin: 0.5rem auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 800; color: var(--text);
  border: 5px solid var(--border); position: relative;
}
.med-score-ring[data-level="high"] { border-color: #22c55e; }
.med-score-ring[data-level="mid"] { border-color: #f59e0b; }
.med-score-ring[data-level="low"] { border-color: #ef4444; }

/* ── Queue / list items ── */
.med-list-item {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.7rem 0; border-bottom: 1px solid var(--border);
}
.med-list-item:last-child { border-bottom: none; }
.med-list-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
  color: var(--bg); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}
.med-list-info { flex: 1; min-width: 0; }
.med-list-name { font-weight: 600; font-size: 0.88rem; color: var(--text); }
.med-list-sub { font-size: 0.75rem; color: var(--text-secondary); }
.med-list-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

/* ── Bed board grid ── */
.med-bed-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.5rem; margin-bottom: 1rem;
}
.med-bed {
  border-radius: 8px; padding: 0.6rem; text-align: center;
  font-size: 0.78rem; font-weight: 600; border: 1px solid var(--border);
  cursor: pointer; transition: transform 0.15s;
}
.med-bed:active { transform: scale(0.95); }
.med-bed-empty { background: #f0fdf4; color: #166534; }
.med-bed-occupied { background: #fef3c7; color: #92400e; }
.med-bed-critical { background: #fee2e2; color: #991b1b; }
.med-bed-cleaning { background: #f3f4f6; color: #6b7280; }

/* ── Timeline ── */
.med-timeline { position: relative; padding-left: 1.2rem; }
.med-timeline::before {
  content: ''; position: absolute; left: 0.35rem; top: 0; bottom: 0;
  width: 2px; background: var(--border);
}
.med-timeline-item {
  position: relative; padding-bottom: 1rem; font-size: 0.82rem;
}
.med-timeline-item::before {
  content: ''; position: absolute; left: -1rem; top: 0.25rem;
  width: 8px; height: 8px; border-radius: 50%; background: var(--gold);
}
.med-timeline-date { font-size: 0.72rem; color: var(--text-secondary); }

/* ── Chart placeholder ── */
.med-chart-area {
  background: var(--bg-card); border-radius: 10px; padding: 1rem;
  min-height: 200px; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 0.8rem;
}
.med-chart-area canvas { width: 100% !important; height: auto !important; }

/* ── Empty state ── */
.med-empty {
  text-align: center; padding: 2rem 1rem; color: var(--text-secondary);
  font-size: 0.88rem;
}
.med-empty i { display: block; margin-bottom: 0.5rem; opacity: 0.4; }

/* ── Modal ── */
.med-modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(61,43,31,0.5); z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.med-modal {
  background: var(--bg); border-radius: 14px; padding: 1.2rem;
  max-width: 500px; width: 100%; max-height: 85vh; overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.med-modal h3 { margin-bottom: 1rem; }

/* ── Phase 6: Robot & IoT ── */
.med-badge-orange { background: #ffedd5; color: #9a3412; }
.med-detail-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.4rem 1rem; margin: 0.8rem 0; padding: 0.8rem;
  background: var(--bg-card); border-radius: 10px; border: 1px solid var(--border);
}
.med-alert-banner {
  background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px;
  padding: 0.6rem 1rem; margin-bottom: 1rem;
}
.med-alert-item { padding: 0.3rem 0; color: #991b1b; font-size: 0.85rem; }
.med-form {
  display: flex; flex-direction: column; gap: 0.6rem; max-width: 400px;
  padding: 1rem; background: var(--bg-card); border-radius: 10px; border: 1px solid var(--border);
}
.med-form label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; color: var(--text-secondary); }
.med-form input, .med-form select {
  padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text); font-size: 0.9rem;
}
.med-icu-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.8rem; margin-top: 0.8rem;
}
.med-icu-bed {
  background: var(--bg-card); border-radius: 10px; padding: 0.8rem;
  border: 2px solid var(--border); text-align: center;
}
.med-icu-available { border-color: #22c55e; }
.med-icu-occupied { border-color: #ef4444; }
.med-icu-maintenance { border-color: #f59e0b; }
.med-icu-number { font-size: 1.2rem; font-weight: 800; }
.med-icu-room { font-size: 0.8rem; color: var(--text-secondary); }
.med-icu-patient { font-size: 0.8rem; margin-top: 0.3rem; }
.med-icu-status { margin: 0.3rem 0; }
.med-icu-actions { margin-top: 0.4rem; display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.med-icu-device { margin-bottom: 1rem; }
.med-row-critical td { background: #fef2f2 !important; }
.med-row-alarm td { background: #fffbeb !important; }

/* ── Responsive ── */
@media (max-width: 480px) {
  .med-stats { grid-template-columns: repeat(2, 1fr); }
  .med-bed-grid { grid-template-columns: repeat(3, 1fr); }
  .med-icu-grid { grid-template-columns: repeat(2, 1fr); }
  .med-tab { padding: 0.5rem 0.7rem; font-size: 0.78rem; }
  .med-detail-grid { grid-template-columns: 1fr; }
}
