/* Reset and base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f7fa;
  color: #2c3e50;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Password Gate */
#password-gate {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#password-gate.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.gate-content {
  background: white;
  padding: 3rem 2.5rem;
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  text-align: center;
  max-width: 400px;
  width: 90%;
  animation: slideUp 0.5s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.gate-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.gate-content h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: #1a202c;
}

.gate-content p {
  color: #718096;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.gate-input-group {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

#password-input {
  flex: 1;
  padding: 0.875rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 1rem;
  transition: border-color 0.2s;
  outline: none;
}

#password-input:focus {
  border-color: #667eea;
}

#password-input.error {
  border-color: #e53e3e;
  animation: shake 0.5s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

#unlock-btn {
  padding: 0.875rem 1.5rem;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

#unlock-btn:hover {
  background: #5a67d8;
}

#unlock-btn:active {
  transform: scale(0.98);
}

#error-msg {
  color: #e53e3e;
  font-size: 0.875rem;
  min-height: 1.25rem;
}

/* Main App */
#app {
  opacity: 0;
  transition: opacity 0.5s ease;
}

#app.visible {
  opacity: 1;
}

/* Header */
.header {
  border-bottom: 1px solid #e2e8f0;
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1a202c;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-box {
  position: relative;
}

.search-box input {
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.875rem;
  width: 200px;
  transition: width 0.3s, border-color 0.2s;
  outline: none;
}

.search-box input:focus {
  width: 280px;
  border-color: #667eea;
}

.search-box::before {
  content: "🔍";
  position: absolute;
  left: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.875rem;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
}

/* Layout */
.main-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  gap: 1.5rem;
}

/* Sidebar */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  position: sticky;
  top: 80px;
  height: calc(100vh - 100px);
  overflow-y: auto;
}

.sidebar-nav {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sidebar-nav h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a0aec0;
  margin-bottom: 0.75rem;
  padding: 0 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 0.25rem;
  font-size: 0.9375rem;
}

.nav-item:hover {
  background: #f7fafc;
}

.nav-item.active {
  background: #667eea;
  color: white;
}

.nav-item .nav-icon {
  font-size: 1.25rem;
  width: 1.5rem;
  text-align: center;
}

.nav-item .nav-count {
  margin-left: auto;
  font-size: 0.75rem;
  background: #edf2f7;
  color: #4a5568;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-weight: 600;
}

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

/* Content */
.content {
  flex: 1;
  min-width: 0;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1a202c;
  margin-bottom: 0.25rem;
}

.page-header p {
  color: #718096;
  font-size: 0.9375rem;
}

/* Category Cards (Dashboard) */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.category-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  z-index: 1;
}

.category-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.category-card-image {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: #f7fafc;
  border-bottom: 1px solid #e2e8f0;
}

.category-card-body {
  padding: 1rem 1.25rem;
}

.category-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: #1a202c;
}

.category-card-meta {
  font-size: 0.875rem;
  color: #718096;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Category Detail View */
.overview-section {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.overview-section h3 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
  color: #1a202c;
}

.overview-image {
  width: 100%;
  border-radius: 8px;
  cursor: zoom-in;
  transition: transform 0.2s;
}

.overview-image:hover {
  transform: scale(1.01);
}

.tests-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 1.25rem;
}

.test-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s, box-shadow 0.2s;
}

.test-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.test-card-header {
  padding: 1rem 1.25rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.test-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1a202c;
}

.test-card-abbr {
  font-size: 0.75rem;
  color: #a0aec0;
  background: #f7fafc;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.test-card-image {
  width: 100%;
  padding: 0.75rem 1.25rem 1.25rem;
}

.test-card-image img {
  width: 100%;
  border-radius: 8px;
  cursor: zoom-in;
}

/* Image Modal */
.image-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  padding: 2rem;
}

.image-modal.active {
  opacity: 1;
  visibility: visible;
}

.image-modal img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
}

.image-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  font-size: 2rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.image-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Mobile Bottom Nav */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid #e2e8f0;
  padding: 0.5rem;
  z-index: 99;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.mobile-nav-items {
  display: flex;
  gap: 0.25rem;
  min-width: max-content;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.875rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.6875rem;
  color: #718096;
  border: none;
  background: none;
  white-space: nowrap;
}

.mobile-nav-item.active {
  background: #667eea;
  color: white;
}

.mobile-nav-item .nav-icon {
  font-size: 1.25rem;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.breadcrumb a {
  color: #667eea;
  text-decoration: none;
  cursor: pointer;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb-separator {
  color: #a0aec0;
}

.breadcrumb-current {
  color: #4a5568;
  font-weight: 500;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: #a0aec0;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* Responsive */
@media (max-width: 1024px) {
  .tests-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .header-content {
    padding: 0 1rem;
  }
  
  .header h1 {
    font-size: 1.1rem;
  }
  
  .search-box input {
    width: 140px;
  }
  
  .search-box input:focus {
    width: 180px;
  }
  
  .menu-toggle {
    display: block;
  }
  
  .main-container {
    padding: 1rem;
    flex-direction: column;
  }
  
  .sidebar {
    display: none;
    position: fixed;
    inset: 0;
    top: 65px;
    width: 100%;
    height: calc(100vh - 65px);
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    padding: 0;
  }
  
  .sidebar.open {
    display: block;
  }
  
  .sidebar-nav {
    border-radius: 0;
    height: 100%;
    overflow-y: auto;
  }
  
  .mobile-nav {
    display: block;
  }
  
  .content {
    padding-bottom: 80px;
  }
  
  .category-grid {
    grid-template-columns: 1fr;
  }
  
  .category-card-image {
    height: 200px;
  }
  
  .page-header h2 {
    font-size: 1.5rem;
  }
  
  .gate-content {
    padding: 2rem 1.5rem;
  }
}

@media (max-width: 480px) {
  .search-box {
    display: none;
  }
  
  .tests-grid {
    gap: 1rem;
  }
  
  .test-card-header {
    padding: 0.875rem 1rem 0;
  }
  
  .test-card-image {
    padding: 0.625rem 1rem 1rem;
  }
}

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 8px;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}
