/* ==========================================================================
   PatientX - Modern Hospital Management & Patient Care Portal
   Palette: Deep Navy (#123B5D), Clinical Teal (#00897B), Emergency Red (#D32F2F)
   ========================================================================== */

:root {
  --primary: #123B5D;
  --primary-dark: #0A2239;
  --primary-light: #1E5582;
  --teal: #00897B;
  --teal-light: #E0F2F1;
  --teal-dark: #00695C;
  --accent-blue: #1976D2;
  --emergency: #D32F2F;
  --emergency-light: #FFEBEE;
  --success: #2E7D32;
  --success-light: #E8F5E9;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --bg-main: #F5F7FA;
  --bg-card: #FFFFFF;
  --border: #E2E8F0;
  --text-main: #1E293B;
  --text-muted: #64748B;
  --sidebar-w: 260px;
  --header-h: 68px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(18, 59, 93, 0.08);
  --shadow-lg: 0 10px 25px rgba(18, 59, 93, 0.12);
  --radius: 10px;
  --transition: all 0.2s ease-in-out;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* ==========================================================================
   LOGIN VIEW
   ========================================================================== */
#login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: linear-gradient(135deg, #0A2239 0%, #123B5D 50%, #00695C 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  width: 100%;
  max-width: 460px;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
  text-align: center;
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.login-logo .cross-icon {
  width: 44px;
  height: 44px;
  background: var(--teal);
  color: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 900;
}

.login-card h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.login-card .subtitle {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 16px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: white;
  color: var(--text-main);
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: var(--accent-blue);
  color: white;
}
.btn-primary:hover {
  background: #1565C0;
}

.btn-teal {
  background: var(--teal);
  color: white;
}
.btn-teal:hover {
  background: var(--teal-dark);
}

.btn-emergency {
  background: var(--emergency);
  color: white;
}
.btn-emergency:hover {
  background: #B71C1C;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-main);
}
.btn-outline:hover {
  background: var(--bg-main);
  border-color: var(--text-muted);
}

.btn-block {
  width: 100%;
}

.demo-account-pills {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
}

.demo-account-pills p {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.pills-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.pill-btn {
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  padding: 5px 11px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  transition: var(--transition);
}

.pill-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ==========================================================================
   APP SHELL (SIDEBAR & HEADER)
   ========================================================================== */
#app-layout {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

/* Sidebar */
#sidebar {
  width: var(--sidebar-w);
  background: var(--primary-dark);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  gap: 12px;
}

.sidebar-header .logo-box {
  width: 36px;
  height: 36px;
  background: var(--teal);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 20px;
}

.sidebar-header .logo-text {
  font-size: 20px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.5px;
}

.sidebar-header .role-tag {
  font-size: 10px;
  background: rgba(255,255,255,0.15);
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: auto;
  text-transform: uppercase;
}

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

.menu-category {
  font-size: 11px;
  font-weight: 700;
  color: #94A3B8;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: #CBD5E1;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 3px;
  transition: var(--transition);
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.nav-item.active {
  background: var(--teal);
  color: white;
  font-weight: 600;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--emergency);
  color: white;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 700;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-profile-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.user-details {
  flex: 1;
  overflow: hidden;
}

.user-details .uname {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-details .urole {
  font-size: 11px;
  color: #94A3B8;
}

/* Main Content Area */
#main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
#top-header {
  height: var(--header-h);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

.header-title-box h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.header-title-box p {
  font-size: 12px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.emergency-btn-header {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(211, 47, 47, 0); }
  100% { box-shadow: 0 0 0 0 rgba(211, 47, 47, 0); }
}

/* Content Container */
#content-area {
  padding: 26px 28px;
  flex: 1;
}

/* Emergency Global Banner */
.emergency-banner {
  background: #FEF2F2;
  border: 1.5px solid #F87171;
  border-left: 6px solid var(--emergency);
  padding: 14px 20px;
  border-radius: 8px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: flashAlert 1.5s infinite alternate;
}

@keyframes flashAlert {
  from { background-color: #FEF2F2; }
  to { background-color: #FEE2E2; }
}

.emergency-banner .banner-text {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: #991B1B;
  font-weight: 600;
}

/* KPI Summary Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 26px;
}

.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-blue);
}

.stat-info p {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stat-info h3 {
  font-size: 30px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.icon-blue { background: #E0F2FE; color: #0284C7; }
.icon-teal { background: #E0F2F1; color: var(--teal); }
.icon-purple { background: #F3E8FF; color: #9333EA; }
.icon-orange { background: #FFEDD5; color: #EA580C; }

/* Panels and Tables */
.card-panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-input {
  padding: 7px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  width: 220px;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.data-table-container {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

.data-table th {
  background: #F8FAFC;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: var(--transition);
}

.data-table tbody tr:hover {
  background-color: #F8FAFC;
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: #B45309; }
.badge-emergency { background: var(--emergency-light); color: var(--emergency); }
.badge-info { background: #E0F2FE; color: #0369A1; }
.badge-neutral { background: #F1F5F9; color: #475569; }

.action-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 5px;
}

/* ==========================================================================
   PATIENT 360 WORKSPACE & TABS
   ========================================================================== */
.tabs-header {
  display: flex;
  background: #F1F5F9;
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  gap: 4px;
}

.tab-btn {
  padding: 12px 18px;
  border: none;
  background: transparent;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: var(--transition);
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
  background: white;
}

.tab-content {
  padding: 22px;
}

.patient-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  background: #F8FAFC;
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.info-item {
  display: flex;
  flex-direction: column;
}

.info-item .info-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.info-item .info-val {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--primary);
  margin-top: 2px;
}

/* Prescriptions & Multi-lingual Lab */
.prescription-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 960px) {
  .prescription-layout {
    grid-template-columns: 1fr;
  }
}

.presc-box {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}

.med-card {
  background: #F0F9FF;
  border: 1px solid #BAE6FD;
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.med-card .med-title {
  font-weight: 700;
  color: #0369A1;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
}

.med-card .med-desc {
  font-size: 13px;
  color: #334155;
  margin-top: 4px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 34, 57, 0.65);
  backdrop-filter: blur(2px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: white;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-content.modal-lg {
  max-width: 1050px;
}

.modal-header {
  padding: 18px 24px;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: white;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 24px;
  background: #F8FAFC;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Toast Messages */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: white;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease-out;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--emergency); }
.toast-info { background: var(--accent-blue); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Case Sheet Photo Upload & Preview */
.photo-upload-zone {
  border: 2px dashed #CBD5E1;
  background: #F8FAFC;
  border-radius: 8px;
  padding: 22px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.photo-upload-zone:hover {
  border-color: var(--teal);
  background: #F0FDF4;
}

.photo-preview-box {
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.photo-preview-img {
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
  background: #0B132B;
  display: block;
  margin: 0 auto;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
  }
  #sidebar.open {
    transform: translateX(0);
  }
  #main-wrapper {
    margin-left: 0;
  }
}
