@layer reset, base, components, layout, state;

@layer reset {
  *, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }
  
  html {
    -moz-text-size-adjust: none;
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
  }
  
  body {
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }
  
  img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
  }
  
  input, button, textarea, select {
    font: inherit;
  }
  
  a {
    text-decoration: none;
    color: inherit;
  }
}

@layer base {
  :root {
    --primary-color: #682A8F; /* Tohoku Purple */
    --primary-light: #9c6fc2;
    --primary-dark: #4a148c;
    --accent-color: #f39c12;
    --bg-color: #f8f9fc;
    --card-bg: #ffffff;
    --text-main: #2c3e50;
    --text-muted: #6c757d;
    --border-color: #e9ecef;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    --header-height: 70px;
    --sidebar-width: 280px;
    --container-max: 1300px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
  }

  body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.03'/%3E%3C/svg%3E");
  }

  h1, h2, h3, h4 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--primary-dark);
  }
}

@layer layout {
  .container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 2rem;
  }

  .site-header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
  }

  .header-content {
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .main-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    gap: 3rem;
    padding: 2rem 0 5rem;
  }

  /* Breadcrumbs */
  .breadcrumbs {
    padding: 1rem 0;
    font-size: 0.875rem;
    color: var(--text-muted);
  }
  
  .breadcrumbs span::after {
    content: '/';
    margin: 0 0.5rem;
  }
  
  .breadcrumbs span:last-child::after {
    content: '';
  }

  .breadcrumbs a:hover {
    color: var(--primary-color);
  }
}

@layer components {
  /* Logo */
  .logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }
  
  .logo-mark {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 1.5rem;
  }

  .logo-text {
    display: flex;
    flex-direction: column;
  }

  .logo-title {
    font-size: 1.125rem;
    font-weight: 800;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .logo-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
  }

  /* Sidebar Filters */
  .sidebar {
    position: sticky;
    top: calc(var(--header-height) + 2rem);
    height: fit-content;
  }

  .filter-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
  }

  .filter-section h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    color: var(--text-muted);
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 0.5rem;
  }

  /* Search Input */
  .search-box {
    position: relative;
    margin-bottom: 1rem;
  }

  .search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
  }

  .search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(104, 42, 143, 0.1);
  }

  .search-box::before {
    content: '🔍';
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    opacity: 0.5;
  }

  /* Nav Pills */
  .nav-pills {
    list-style: none;
  }

  .nav-pills li {
    margin-bottom: 0.25rem;
  }

  .pill {
    width: 100%;
    text-align: left;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-main);
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .pill:hover {
    background: var(--bg-color);
    color: var(--primary-color);
  }

  .pill.active {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
  }

  /* Grid Area */
  .results-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
  }

  .results-header h1 {
    font-size: 2rem;
  }

  .results-count {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.9rem;
  }

  .lab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 2rem;
  }

  /* Footer */
  .site-footer {
    background: var(--primary-dark);
    color: white;
    padding: 4rem 0;
    margin-top: auto;
  }

  .footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 4rem;
  }

  .footer-logo {
    margin-bottom: 1.5rem;
  }

  .footer-links h4 {
    color: white;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
  }

  .footer-links ul {
    list-style: none;
  }

  .footer-links li {
    margin-bottom: 0.75rem;
    opacity: 0.8;
  }

  .footer-links a:hover {
    opacity: 1;
    text-decoration: underline;
  }
}

@layer state {
  .hidden {
    display: none !important;
  }
}

@media (max-width: 1024px) {
  .main-layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .sidebar {
    position: static;
  }
}