/*
 * LabConnect LIS Common Enterprise Design Tokens & Base Styles
 * Shadcn-inspired Blue Theme (minimalist typography, light/zinc backgrounds, sharp borders).
 */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

:root {
  --color-primary: #2563eb; /* Shadcn Blue */
  --color-primary-hover: #1d4ed8;
  --color-sidebar: #ffffff; /* Clean White Sidebar */
  --color-background: #fafafa; /* Minimalist Background */
  --color-card: #ffffff;
  --color-text-dark: #09090b; /* Zinc 950 */
  --color-text-muted: #71717a; /* Zinc 500 */
  --color-border: #e4e4e7; /* Zinc 200 */
  --color-border-focus: #2563eb;
  --color-danger: #ef4444;
  --color-danger-bg: #fef2f2;
  --color-success: #10b981;
  --color-success-bg: #ecfdf5;

  --radius-standard: 8px; /* Shadcn standard rounded-lg */
  --shadow-subtle: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-large:
    0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.02);
  --font-primary:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
  font-family: var(--font-primary);
  background-color: var(--color-background);
  color: var(--color-text-dark);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Typography Defaults */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 600;
  color: var(--color-text-dark);
}

/* 1. Reusable Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-standard);
  border: 1px solid transparent;
  cursor: pointer;
  width: 100%;
  height: 38px;
  outline: none;
  transition: all 0.15s ease;
}

.btn-primary {
  background-color: var(--color-primary);
  color: #ffffff;
  box-shadow: 0 1px 2px 0 rgba(37, 99, 235, 0.1);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--color-primary-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-outline {
  background-color: #ffffff;
  color: var(--color-text-dark);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-subtle);
}

.btn-outline:hover:not(:disabled) {
  background-color: #f4f4f5; /* Zinc 100 */
}

.btn-danger {
  background-color: var(--color-danger);
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  background-color: #dc2626;
}

/* 2. Reusable Inputs */
.form-group {
  margin-bottom: 1rem;
  width: 100%;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-dark);
  margin-bottom: 0.375rem;
}

.form-control {
  width: 100%;
  height: 38px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-standard);
  background-color: #ffffff;
  color: var(--color-text-dark);
  outline: none;
  transition: all 0.15s ease;
}

.form-control:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* Password Input Wrapper with Icon */
.password-wrapper {
  position: relative;
  width: 100%;
}

.password-wrapper .form-control {
  padding-right: 2.75rem;
}

.password-toggle-btn {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
}

.password-toggle-btn:hover {
  color: var(--color-text-dark);
}

/* Checkbox Styles */
.form-checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-checkbox {
  width: 15px;
  height: 15px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
}

.form-checkbox-label {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--color-text-dark);
  cursor: pointer;
}

/* 3. Reusable Alerts */
.alert {
  display: flex;
  align-items: flex-start;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-standard);
  font-size: 0.8125rem;
  margin-bottom: 1rem;
  width: 100%;
}

.alert-error {
  background-color: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid rgba(239, 68, 68, 0.15);
}

.alert-success {
  background-color: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.15);
}

.text-danger {
  color: var(--color-danger);
  font-size: 0.75rem;
  margin-top: 0.25rem;
  display: block;
}

/* 4. Spinner Loader */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(37, 99, 235, 0.1);
  border-radius: 50%;
  border-top-color: var(--color-primary);
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

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

/* 5. Toast Notifications */
#toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  background-color: #09090b;
  color: #ffffff;
  border-radius: var(--radius-standard);
  box-shadow: var(--shadow-large);
  font-size: 0.8125rem;
  min-width: 250px;
  border: 1px solid #27272a;
}

/* 6. Empty State Component */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
}

.empty-state-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.empty-state-description {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* 7. Common Table & Grid UI */
.card {
  background-color: #ffffff;
  border-radius: var(--radius-standard);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-subtle);
  padding: 1.25rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.8125rem;
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  background-color: #fafafa;
  color: var(--color-text-muted);
  font-weight: 500;
}

.data-table tr:hover td {
  background-color: #f9fafb;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  border: 1px solid transparent;
}

.status-active {
  background-color: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.status-inactive {
  background-color: #fef2f2;
  color: #991b1b;
  border-color: #fca5a5;
}

.action-link {
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-primary);
  cursor: pointer;
}

.action-link:hover {
  text-decoration: underline;
}

/* 8. Layout Styles: Left Sidebar, Top Bar, Workspace */
.app-layout {
  display: flex;
  min-height: 100vh;
  background-color: var(--color-background);
}

.app-sidebar {
  width: 204px;
  background-color: #ffffff;
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.75rem;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text-dark);
  margin-bottom: 1.75rem;
  cursor: pointer;
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 24px;
  height: 24px;
  background-color: var(--color-primary);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.75rem;
}

.sidebar-logo-text {
  font-weight: 700;
  font-size: 0.9375rem;
  color: #09090b;
  letter-spacing: -0.03em;
}

.sidebar-logo-accent {
  color: var(--color-primary);
  font-weight: 400;
  margin-left: 0.05rem;
}

.sidebar-group-title {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

/* Redesigned Quick Intake Widget */
.quick-create-widget {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 0.55rem 0.875rem !important;
  background-color: var(--color-primary) !important;
  color: #ffffff !important;
  border-radius: 6px !important;
  font-size: 0.8125rem !important;
  font-weight: 500 !important;
  margin-bottom: 1.25rem !important;
  cursor: pointer !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  box-shadow: 0 2px 4px 0 rgba(37, 99, 235, 0.15) !important;
  border: none !important;
  width: 100% !important;
}

.quick-create-widget:hover {
  background-color: var(--color-primary-hover) !important;
  box-shadow: 0 4px 8px 0 rgba(37, 99, 235, 0.2) !important;
}

.sidebar-kbd {
  font-family: var(--font-primary) !important;
  font-size: 0.6875rem !important;
  opacity: 0.9 !important;
  background-color: rgba(255, 255, 255, 0.18) !important;
  padding: 0.125rem 0.375rem !important;
  border-radius: 4px !important;
  color: #ffffff !important;
  font-weight: 500 !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.sidebar-menu-item a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.625rem;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-menu-item a:hover {
  background-color: #f4f4f5; /* Zinc 100 */
  color: var(--color-text-dark);
}

.sidebar-menu-item.active a {
  background-color: #eff6ff; /* Soft Blue */
  color: var(--color-primary);
  font-weight: 600;
  box-shadow: inset 3px 0 0 0 var(--color-primary);
}

.sidebar-icon {
  width: 13px;
  height: 13px;
  stroke-width: 1.6;
  flex-shrink: 0;
  opacity: 0.88;
  transition: opacity 0.15s ease;
}

.sidebar-menu-item a:hover .sidebar-icon,
.sidebar-menu-item.active a .sidebar-icon {
  opacity: 1;
}

.sidebar-group-icon {
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

.sidebar-dropdown-toggle:hover .sidebar-group-icon {
  opacity: 1;
}

/* Sidebar User Widget */
.sidebar-user-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.5rem 0.25rem 0.5rem;
  border-top: 1px solid var(--color-border);
  margin-top: auto;
  font-size: 0.75rem;
}

.app-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top-bar {
  height: 56px;
  background-color: #ffffff;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  flex-shrink: 0;
}

.top-bar-search {
  position: relative;
  width: 240px;
}

.top-bar-search-input {
  width: 100%;
  height: 32px;
  background-color: #fafafa;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding-left: 0.75rem;
  padding-right: 2.5rem;
  font-size: 0.75rem;
  outline: none;
  transition: all 0.15s ease;
  color: var(--color-text-dark);
}

.top-bar-search-input:focus {
  background-color: #ffffff;
  border-color: var(--color-primary);
}

.top-bar-search-shortcut {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.625rem;
  color: var(--color-text-muted);
  background-color: #ffffff;
  border: 1px solid var(--color-border);
  padding: 0.125rem 0.25rem;
  border-radius: 4px;
  font-family: monospace;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.notification-bell {
  position: relative;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 0.9375rem;
}

.notification-badge {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 5px;
  height: 5px;
  background-color: #ef4444;
  border-radius: 50%;
}

.user-profile-widget {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.user-profile-avatar {
  width: 28px;
  height: 28px;
  background-color: #e4e4e7;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-dark);
  font-weight: 500;
  font-size: 0.75rem;
  border: 1px solid var(--color-border);
}

.user-profile-info {
  display: flex;
  flex-direction: column;
}

.user-profile-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-dark);
  line-height: 1.2;
}

.user-profile-role {
  font-size: 0.625rem;
  color: var(--color-text-muted);
}

.app-layout {
  display: flex;
  min-height: 100vh;
  background-color: var(--color-background);
  max-width: 100vw;
  overflow-x: hidden;
}

.app-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.workspace-content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* Global Responsive Table Container */
.table-responsive {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-x pan-y !important;
  margin-bottom: 0;
  box-sizing: border-box;
}

.table-responsive::-webkit-scrollbar {
  height: 6px !important;
  display: block !important;
}

.table-responsive::-webkit-scrollbar-track {
  background: #f1f5f9 !important;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: #94a3b8 !important;
  border-radius: 4px !important;
}

/* Sidebar User Widget (matching ui.shadcn.com bottom profile style) */
.sidebar-user-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-top: 1px solid var(--color-border);
  margin-top: auto;
  font-size: 0.75rem;
}

/* Mobile Navigation Bar & Drawer Styles */
.mobile-navbar {
  display: none;
  height: 52px;
  background-color: #ffffff;
  border-bottom: 1px solid var(--color-border);
  padding: 0 1rem;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1030;
  width: 100%;
}

.mobile-navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.9375rem;
  color: #09090b;
  text-decoration: none;
  cursor: pointer;
}

.mobile-menu-toggle {
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0f172a;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
}

.mobile-menu-toggle:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
}

.mobile-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 1040;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.mobile-sidebar-overlay.active {
  display: block;
  opacity: 1;
}

.mobile-sidebar-close-btn {
  display: none;
}

@media (max-width: 768px) {
  .mobile-navbar {
    display: flex;
  }

  .mobile-sidebar-close-btn {
    display: flex !important;
  }

  .app-layout {
    flex-direction: column;
  }

  .app-sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    height: 100vh !important;
    width: 84vw !important;
    min-width: 270px !important;
    max-width: 320px !important;
    z-index: 1050;
    background-color: #ffffff;
    box-shadow: 6px 0 30px rgba(15, 23, 42, 0.2);
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
    display: flex !important;
    padding: 1.5rem 1rem !important;
    overflow-y: auto;
  }

  .app-sidebar.mobile-open {
    transform: translateX(0) !important;
  }

  /* Ensure items remain text visible inside mobile drawer */
  .app-sidebar .sidebar-logo-text,
  .app-sidebar .sidebar-group-title-text,
  .app-sidebar .sidebar-dropdown-arrow,
  .app-sidebar .menu-item-text,
  .app-sidebar .user-profile-info {
    display: inline-block !important;
  }

  .app-sidebar .sidebar-dropdown-group {
    margin-bottom: 0.75rem !important;
  }

  .app-sidebar .sidebar-dropdown-toggle {
    padding: 0.625rem 0.875rem !important;
  }

  .app-sidebar .sidebar-menu-item a {
    padding: 0.55rem 0.875rem !important;
    font-size: 0.84375rem !important;
    gap: 0.65rem !important;
  }

  .app-sidebar .sidebar-icon {
    width: 15px !important;
    height: 15px !important;
  }

  /* Hide desktop collapse chevron button on mobile screens */
  #sidebar-toggle-btn {
    display: none !important;
  }

  .app-workspace {
    flex: 1;
    width: 100%;
  }
}

/* ==============================================================================
   Sidebar Collapse & Dropdown Accordion Custom Styles
   ============================================================================== */
.app-sidebar {
  transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1), padding 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-collapsed {
  width: 70px !important;
  padding: 1.5rem 0.5rem !important;
}

/* Hide elements when collapsed */
.sidebar-collapsed .sidebar-logo-text,
.sidebar-collapsed .sidebar-group-title-text,
.sidebar-collapsed .sidebar-dropdown-arrow,
.sidebar-collapsed .menu-item-text,
.sidebar-collapsed .user-profile-info {
  display: none !important;
}

/* Squeeze & center logo when collapsed */
.sidebar-collapsed .sidebar-header-wrapper {
  justify-content: center !important;
}
.sidebar-collapsed .sidebar-logo {
  justify-content: center !important;
}

/* Adjust quick action button when collapsed */
.sidebar-collapsed .quick-create-widget {
  padding: 0.55rem 0 !important;
  justify-content: center !important;
  border-radius: 50% !important;
  width: 38px !important;
  height: 38px !important;
  margin: 0 auto 1.25rem auto !important;
}
.sidebar-collapsed .quick-create-widget span {
  justify-content: center !important;
  gap: 0 !important;
}

/* Dropdown Accordion Groups */
.sidebar-dropdown-group {
  margin-bottom: 0.5rem;
  width: 100%;
}

.sidebar-dropdown-toggle {
  width: 100%;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
  outline: none;
}

.sidebar-dropdown-toggle:hover {
  background-color: #f4f4f5;
  color: var(--color-text-dark);
}

.sidebar-group-title-wrapper {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.sidebar-group-title-text {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-dropdown-arrow {
  transition: transform 0.2s ease;
}

/* Open/Closed logic */
.sidebar-dropdown-group.closed .dropdown-menu {
  display: none !important;
}

.sidebar-dropdown-group.closed .sidebar-dropdown-arrow {
  transform: rotate(-90deg);
}

.sidebar-dropdown-group .dropdown-menu {
  margin-top: 0.125rem;
  padding-left: 0.375rem;
  list-style: none;
}

/* Align list items cleanly when collapsed */
.sidebar-collapsed .sidebar-dropdown-group .dropdown-menu {
  padding-left: 0 !important;
}

.sidebar-collapsed .sidebar-menu-item a {
  justify-content: center !important;
  padding: 0.5rem 0 !important;
}

.sidebar-collapsed .sidebar-dropdown-toggle {
  justify-content: center !important;
  padding: 0.5rem 0 !important;
}

.sidebar-collapsed .sidebar-group-title-wrapper {
  justify-content: center !important;
  gap: 0 !important;
}

.sidebar-collapsed .sidebar-user-footer {
  justify-content: center !important;
  padding: 0.75rem 0 0 0 !important;
}
.sidebar-collapsed .sidebar-avatar {
  margin: 0 auto !important;
}

.sidebar-toggle:hover {
  background-color: #f4f4f5;
  color: var(--color-text-dark);
}

