:root {
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-hover: #1e293b;
  --sidebar-active: #3b82f6;
  --bg-main: #f8fafc;
  --card-bg: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --accent-yellow: #facc15;
  --border-color: #e2e8f0;
  --radius: 8px;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.sidebar-header {
  padding: 0 24px 24px;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 24px;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 24px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.95rem;
  transition: all 0.2s;
  border-left: 4px solid transparent;
}

.nav-item:hover {
  background-color: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background-color: var(--sidebar-hover);
  color: #fff;
  border-left-color: var(--sidebar-active);
}

.nav-item i {
  margin-right: 12px;
  width: 20px;
  text-align: center;
}

.sidebar-stats {
  margin-top: auto;
  padding: 24px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.85rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--sidebar-text);
}

.stat-value {
  color: var(--accent-yellow);
  font-weight: 700;
}

/* Main Content */
.main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.header {
  height: 64px;
  background-color: var(--sidebar-bg); /* Dark header as per image */
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  flex-shrink: 0;
}

.header-title {
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Dashboard Grid */
.content {
  padding: 24px;
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 24px;
}

/* Patient Summary Card */
.patient-summary {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.patient-photo {
  width: 120px;
  height: 120px;
  background: #f1f5f9;
  border-radius: 50%;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.patient-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-row {
  display: flex;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.detail-label {
  width: 100px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.detail-value {
  font-weight: 500;
  color: var(--text-primary);
  background: #f1f5f9;
  padding: 4px 12px;
  border-radius: 4px;
  width: 100%;
}

/* Tabs & Clinical Data */
.clinical-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: #f8fafc;
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}

.tab {
  padding: 12px 24px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-right: 1px solid var(--border-color);
  text-transform: uppercase;
  transition: all 0.2s;
}

.tab:hover {
  background: #f1f5f9;
}

.tab.active {
  background: var(--accent-yellow);
  color: var(--text-primary);
}

.tab-content {
  padding: 24px;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-field {
  display: flex;
  /* align-items: center; */
  gap: 12px;
}

.form-field label {
  width: 110px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: right;
}

.form-field input {
  flex-grow: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.9rem;
}

.unit {
  font-size: 0.75rem;
  color: var(--text-secondary);
  width: 50px;
}

/* History Table */
.history-title {
  background: #f8fafc;
  padding: 10px 24px;
  font-size: 0.8rem;
  font-weight: 600;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  text-align: center;
  color: var(--text-secondary);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.history-table th {
  text-align: left;
  padding: 12px;
  background: #f8fafc;
  color: var(--text-secondary);
  font-weight: 500;
}

.history-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
}

.footer {
  margin-top: auto;
  padding: 16px 24px;
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: #fff;
  border-top: 1px solid var(--border-color);
}

/* Responsive Media Queries */
@media (max-width: 1024px) {
  .content {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  body {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: fixed;
    top: 56px; /* Below dark header */
    left: -100%;
    z-index: 1000;
    height: calc(100vh - 56px);
    transition: left 0.3s ease;
  }

  .sidebar.active {
    left: 0;
  }

  .header {
    height: 56px;
    padding: 0 16px;
    z-index: 1001;
    position: sticky;
    top: 0;
  }

  .header-title {
    font-size: 0.8rem;
  }

  .main {
    margin-top: 0;
  }

  .content {
    padding: 16px;
    gap: 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .menu-toggle {
    display: block !important;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    margin-right: 12px;
  }

  .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
  }

  .patient-summary {
    padding: 16px;
  }

  .tab {
    padding: 10px 12px;
    font-size: 0.75rem;
  }
}

/* Base Utility */
.menu-toggle {
  display: none;
}


/* Patient Photo Styles */
.patient-photo {
  position: relative;
  cursor: pointer;
  transition: transform 0.2s;
}

.patient-photo:hover {
  transform: scale(1.05);
}

.photo-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0;
  transition: opacity 0.2s;
  border-radius: 50%;
  font-size: 0.8rem;
  gap: 4px;
}

.patient-photo:hover .photo-overlay {
  opacity: 1;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 3000; /* Higher than sidebar */
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.8);
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: #fff;
  padding: 24px;
  border-radius: var(--radius);
  max-width: 500px;
  width: 95%;
  text-align: center;
}

#camera-preview {
  width: 100%;
  max-width: 400px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  background: #000;
  transform: scaleX(-1); /* Mirror view */
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}

.btn-photo {
  padding: 10px 20px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-capture { background: var(--sidebar-active); color: #fff; }
.btn-cancel { background: #e2e8f0; color: #475569; }
.btn-upload-trigger { background: var(--accent-yellow); color: var(--text-primary); }
