:root {
  --primary: #9f46ee;
  --primary-light: #9575cd;
  --primary-dark: #311b92;
  --bg: #f5f5f5;
  --fg: #212121;
  --card-bg: #ffffff;
  --border: #e0e0e0;
  --muted: #757575;
  --input-bg: #f5f5f5;
  --input-border: #bdbdbd;
  --highlight-bg: rgba(103, 58, 183, 0.1);
  --highlight-color: #673ab7;
  --shadow-1: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-2: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
}

[data-theme="dark"] {
  --primary: #bb86fc;
  --primary-light: #cf9cff;
  --primary-dark: #3700b3;
  --bg: #121212;
  --fg: #ffffff;
  --card-bg: #1e1e1e;
  --border: #333333;
  --muted: #b0b0b0;
  --input-bg: #2c2c2c;
  --input-border: #444444;
  --highlight-bg: rgba(187, 134, 252, 0.15);
  --highlight-color: #bb86fc;
  --shadow-1: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 3px 6px rgba(0, 0, 0, 0.25), 0 3px 6px rgba(0, 0, 0, 0.4);
}

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

body {
  background-color: var(--bg);
  color: var(--fg);
  font-family: "Lexend", sans-serif;
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.sticky-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--card-bg);
  box-shadow: var(--shadow-2);
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.main-content {
  padding-top: 2rem;
}

.container {
  max-width: 1024px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.title {
  font-size: 2rem;
  font-weight: bolder;
  color: var(--primary);
  margin: 0;
}

.subtitle {
  font-size: 1rem;
  font-weight: bold;
  color: var(--primary);
  margin: 0;
}

.theme-toggle {
  background: none;
  color: var(--fg);
  border: none;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1.25rem;
}

.theme-toggle:hover {
  transform: translateY(-2px);
}

.search-container {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.875rem 1rem 0.875rem 2.5rem;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  background-color: var(--input-bg);
  font-size: 0.95rem;
  transition: all 0.3s ease;
  color: var(--fg);
  box-shadow: var(--shadow);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.search-input::placeholder {
  color: var(--muted);
}

.product-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background-color: var(--card-bg);
  border-radius: 16px;
  overflow: hidden;
  font-size: 0.95rem;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.product-table thead {
  background-color: var(--card-bg);
  color: var(--muted);
  text-align: left;
  font-weight: 500;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.product-table th,
.product-table td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.product-table th:first-child,
.product-table td:first-child {
  padding-left: 2rem;
}

.product-table th:last-child,
.product-table td:last-child {
  padding-right: 2rem;
}

.product-table tbody tr:last-child td {
  border-bottom: none;
}

.product-table tbody tr {
  transition: background-color 0.2s ease;
}

.product-table tbody tr:hover {
  background-color: var(--input-bg);
}

mark {
  background-color: var(--highlight-bg);
  color: var(--highlight-color);
  padding: 0.15em 0.25em;
  border-radius: 3px;
  font-weight: 500;
}

.bottom-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.pagination-wrapper {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.select {
  background-color: var(--card-bg);
  color: var(--fg);
  border: 1px solid var(--input-border);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1em;
}

.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.pagination {
  display: flex;
  gap: 0.5rem;
}

.pagination button {
  background-color: var(--card-bg);
  color: var(--fg);
  border: 1px solid var(--input-border);
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.pagination button:hover:not(:disabled) {
  border-color: var(--primary-light);
  background-color: var(--highlight-bg);
  color: var(--primary);
}

.pagination button.active {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
  font-weight: 500;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination .ellipsis {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  color: var(--muted);
}

.pagination .prev-btn,
.pagination .next-btn {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mrp {
  font-weight: 500;
  color: var(--primary-dark);
}

.drug-code {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.9rem;
  color: var(--muted);
  letter-spacing: 0.5px;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  vertical-align: middle;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  color: var(--muted);
}

.empty-state h3 {
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.9rem;
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 0 1rem;
  }

  .sticky-header {
    padding: 1rem;
  }

  .header {
    margin-bottom: 1rem;
  }

  .product-table {
    font-size: 0.85rem;
  }

  .product-table th,
  .product-table td {
    padding: 0.75rem 1rem;
  }

  .product-table th:first-child,
  .product-table td:first-child {
    padding-left: 1rem;
  }

  .product-table th:last-child,
  .product-table td:last-child {
    padding-right: 1rem;
  }

  .bottom-controls {
    flex-direction: column;
    align-items: center;
  }

  .pagination {
    width: 100%;
    justify-content: center;
    margin-top: 1rem;
  }
}

@media (max-width: 640px) {
  .container {
    max-width: 100%;
    padding: 0 0.5rem;
  }

  .sticky-header {
    padding: 1rem 0.5rem;
  }

  .product-table {
    display: block;
    overflow-x: auto;
    border-radius: 12px;
  }

  .title {
    font-size: 1.25rem;
  }

  .logo {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
}

.loading {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 1s linear infinite;
}

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

.footer-note {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 1.5rem;
  padding-right: 1rem;
}