/* =============================================================
   YASHFIN MEDICAL LABORATORY — Main Stylesheet
   Color Palette: Deep Purple / White / Light Gray
   Font: Inter, Poppins
   ============================================================= */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --purple-900: #1a0533;
  --purple-800: #2d0d57;
  --purple-700: #3d1470;
  --purple-600: #5a1e96;
  --purple-500: #7c3aed;
  --purple-400: #a855f7;
  --purple-300: #c084fc;
  --purple-200: #e9d5ff;
  --purple-100: #f5f0ff;
  --purple-50:  #faf5ff;

  --gray-900: #111827;
  --gray-800: #1f2937;
  --gray-700: #374151;
  --gray-600: #4b5563;
  --gray-400: #9ca3af;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50:  #f9fafb;

  --white: #ffffff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger:  #ef4444;
  --info:    #3b82f6;

  --sidebar-width: 260px;
  --navbar-height: 60px;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.14);
  --transition: all 0.25s ease;
}

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
}

/* ============================================================
   LAYOUT: Sidebar + Main Content
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

.page-content {
  flex: 1;
  padding: 24px;
  padding-top: calc(var(--navbar-height) + 24px);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--purple-900) 0%, var(--purple-800) 60%, var(--purple-700) 100%);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition);
  box-shadow: 4px 0 20px rgba(0,0,0,0.3);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

/* Sidebar Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-decoration: none;
}

.sidebar-logo-img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(255,255,255,0.12);
  padding: 4px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand-name {
  color: var(--white);
  font-family: 'Poppins', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-tagline {
  color: var(--purple-300);
  font-size: 0.65rem;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
}

.nav-section-label {
  color: var(--purple-300);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 12px 8px 6px;
  opacity: 0.8;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--border-radius-sm);
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 2px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.nav-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--purple-300);
  border-radius: 0 2px 2px 0;
  transform: scaleY(0);
  transition: transform 0.2s ease;
}

.nav-item:hover {
  background: rgba(255,255,255,0.1);
  color: var(--white);
  transform: translateX(2px);
}

.nav-item.active {
  background: rgba(255,255,255,0.15);
  color: var(--white);
}

.nav-item.active::before { transform: scaleY(1); }

.nav-item i { font-size: 1rem; flex-shrink: 0; }

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-info { display: flex; align-items: center; gap: 10px; flex: 1; overflow: hidden; }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: white; font-size: 1.3rem;
}

.user-details { display: flex; flex-direction: column; overflow: hidden; }

.user-name {
  color: var(--white);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.user-role {
  background: rgba(255,255,255,0.2);
  color: var(--purple-200);
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  width: fit-content;
  padding: 1px 6px;
}

.btn-logout {
  color: rgba(255,255,255,0.6);
  font-size: 1.2rem;
  text-decoration: none;
  transition: color 0.2s;
  flex-shrink: 0;
}
.btn-logout:hover { color: #ff6b6b; }

/* ============================================================
   TOP NAVBAR
   ============================================================ */
.top-navbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--navbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  z-index: 900;
  box-shadow: var(--shadow-sm);
  transition: left var(--transition);
}

.sidebar-toggle {
  border: none; background: none;
  color: var(--gray-600);
  font-size: 1.4rem;
  cursor: pointer; padding: 4px 8px;
  border-radius: var(--border-radius-sm);
  display: none;
  transition: var(--transition);
}

.sidebar-toggle:hover { background: var(--gray-100); color: var(--purple-600); }

.navbar-title h5 {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--gray-800);
}

.navbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.navbar-datetime {
  display: flex; align-items: center;
  color: var(--gray-500);
  font-size: 0.8rem;
  background: var(--gray-100);
  padding: 6px 12px;
  border-radius: 20px;
}

.btn-purple {
  background: linear-gradient(135deg, var(--purple-600), var(--purple-500));
  border: none; color: var(--white);
  font-weight: 600;
  border-radius: var(--border-radius-sm);
  transition: var(--transition);
}
.btn-purple:hover {
  background: linear-gradient(135deg, var(--purple-700), var(--purple-600));
  color: var(--white);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124,58,237,0.35);
}

.btn-user-menu {
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-700);
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 14px;
  transition: var(--transition);
}
.btn-user-menu:hover { border-color: var(--purple-400); color: var(--purple-600); background: var(--purple-50); }

/* ============================================================
   CARDS
   ============================================================ */
.stat-card {
  background: var(--white);
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  transition: var(--transition);
  overflow: hidden;
  position: relative;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent, var(--purple-500));
  border-radius: var(--border-radius) var(--border-radius) 0 0;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 16px;
}

.stat-value {
  font-family: 'Poppins', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  color: var(--gray-500);
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Card colors */
.card-purple { --accent: var(--purple-500); }
.card-purple .stat-icon { background: var(--purple-100); color: var(--purple-600); }
.card-green  { --accent: var(--success); }
.card-green  .stat-icon { background: #d1fae5; color: var(--success); }
.card-blue   { --accent: var(--info); }
.card-blue   .stat-icon { background: #dbeafe; color: var(--info); }
.card-orange { --accent: var(--warning); }
.card-orange .stat-icon { background: #fef3c7; color: var(--warning); }
.card-red    { --accent: var(--danger); }
.card-red    .stat-icon { background: #fee2e2; color: var(--danger); }

/* ============================================================
   TABLES
   ============================================================ */
.data-table-wrapper {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.table-header {
  padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.table-title {
  font-family: 'Poppins', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-800);
  margin: 0;
}

.table { margin: 0; }
.table thead th {
  background: var(--purple-900);
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 16px;
  border: none;
}
.table tbody td {
  padding: 12px 16px;
  vertical-align: middle;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}
.table tbody tr:hover td { background: var(--purple-50); }
.table tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   FORMS & CARDS
   ============================================================ */
.form-card {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  padding: 24px;
  margin-bottom: 24px;
}

.form-card-title {
  font-family: 'Poppins', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--purple-200);
  display: flex; align-items: center; gap: 8px;
}
.form-card-title i { color: var(--purple-600); font-size: 1.1rem; }

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.form-control, .form-select {
  border: 1.5px solid var(--gray-200);
  border-radius: var(--border-radius-sm);
  font-size: 0.875rem;
  padding: 9px 12px;
  transition: var(--transition);
  background: var(--white);
  color: var(--gray-800);
}
.form-control:focus, .form-select:focus {
  border-color: var(--purple-400);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
  outline: none;
}

/* ============================================================
   BADGES & STATUS
   ============================================================ */
.badge-status {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.badge-complete  { background: #d1fae5; color: #065f46; }
.badge-pending   { background: #fef3c7; color: #92400e; }

/* ============================================================
   ACTION BUTTONS (table row)
   ============================================================ */
.btn-action {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.875rem;
  text-decoration: none;
  transition: var(--transition);
  cursor: pointer;
}
.btn-view   { background: #dbeafe; color: #1d4ed8; }
.btn-edit   { background: #fef3c7; color: #92400e; }
.btn-print  { background: #d1fae5; color: #065f46; }
.btn-delete { background: #fee2e2; color: #991b1b; }

.btn-action:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-view:hover   { background: #1d4ed8; color: white; }
.btn-edit:hover   { background: #d97706; color: white; }
.btn-print:hover  { background: #059669; color: white; }
.btn-delete:hover { background: #dc2626; color: white; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap; gap: 12px;
}
.page-header-title {
  font-family: 'Poppins', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0;
}
.page-header-subtitle {
  color: var(--gray-500);
  font-size: 0.85rem;
  margin: 0;
}
.page-header-breadcrumb {
  font-size: 0.78rem;
  color: var(--gray-500);
}
.page-header-breadcrumb a { color: var(--purple-600); text-decoration: none; }
.page-header-breadcrumb a:hover { text-decoration: underline; }

/* ============================================================
   SEARCH BOX
   ============================================================ */
.search-box {
  position: relative;
}
.search-box input {
  padding-left: 36px;
  border-radius: 20px;
  font-size: 0.85rem;
}
.search-box .search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
}

/* ============================================================
   TEST SECTION HEADERS (Report Form)
   ============================================================ */
.test-section {
  margin-bottom: 16px;
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-sm);
  overflow: hidden;
}

.test-section-header {
  background: var(--purple-900);
  color: var(--white);
  padding: 10px 16px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: flex; align-items: center; justify-content: space-between;
}

.test-item {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid var(--gray-100);
  gap: 12px;
  transition: background 0.15s;
}
.test-item:last-child { border-bottom: none; }
.test-item:hover { background: var(--purple-50); }
.test-item.disabled { opacity: 0.4; }

.test-check { flex-shrink: 0; }
.test-check input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--purple-600); }

.test-name { flex: 1; font-size: 0.85rem; font-weight: 500; color: var(--gray-800); }
.test-ref   { font-size: 0.75rem; color: var(--gray-500); white-space: nowrap; }
.test-unit  { font-size: 0.75rem; color: var(--gray-400); min-width: 50px; text-align: right; white-space: nowrap; }
.test-result-input {
  width: 130px;
  flex-shrink: 0;
  font-size: 0.85rem;
}

/* ============================================================
   ALERTS / FLASH
   ============================================================ */
.alert { border-radius: var(--border-radius-sm); font-size: 0.875rem; font-weight: 500; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--purple-900) 0%, var(--purple-700) 50%, var(--purple-600) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  top: -200px; right: -200px;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  bottom: -150px; left: -100px;
}

.login-card {
  background: var(--white);
  border-radius: 20px;
  padding: 40px;
  width: 100%; max-width: 420px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.35);
  position: relative; z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}
.login-logo img {
  height: 80px;
  object-fit: contain;
  margin-bottom: 12px;
}
.login-lab-name {
  font-family: 'Poppins', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--purple-800);
  margin: 0;
}
.login-tagline {
  font-size: 0.8rem;
  color: var(--gray-500);
  font-style: italic;
}

.login-title {
  font-family: 'Poppins', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 6px;
}
.login-subtitle { color: var(--gray-500); font-size: 0.875rem; margin-bottom: 28px; }

/* ============================================================
   REPORT FORM GRID
   ============================================================ */
.report-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 768px) { .report-grid-2 { grid-template-columns: 1fr; } }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}
.empty-state i { font-size: 3.5rem; display: block; margin-bottom: 16px; }
.empty-state p { font-size: 0.9rem; margin: 0; }

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .top-navbar { left: 0; }
  .sidebar-toggle { display: flex; }

  /* Overlay for mobile sidebar */
  .sidebar-overlay {
    display: none; position: fixed;
    inset: 0; background: rgba(0,0,0,0.5);
    z-index: 999;
  }
  .sidebar-overlay.active { display: block; }
}

@media (max-width: 576px) {
  .page-content { padding: 16px; padding-top: calc(var(--navbar-height) + 16px); }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 1.5rem; }
  .login-card { padding: 28px 20px; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-purple { color: var(--purple-600) !important; }
.bg-purple   { background: var(--purple-600) !important; }
.border-purple { border-color: var(--purple-300) !important; }
.font-poppins { font-family: 'Poppins', sans-serif; }

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--purple-400); }

/* ============================================================
   OVERLAY on mobile
   ============================================================ */
#sidebarOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
}
#sidebarOverlay.active { display: block; }
