.app {
  min-height: 100vh;
  padding: 3rem 1.5rem;
  max-width: 1000px;
  margin: 0 auto;
}

.view-switcher {
  display: flex;
  justify-content: center;
  background: var(--surface);
  padding: 5px;
  border-radius: 999px;
  border: 1px solid var(--border);
  box-shadow: var(--glass-shadow);
  width: fit-content;
  margin: 0 auto 3rem auto;
}

.view-switcher button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.8rem 2rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.view-switcher button:hover {
  color: var(--text-main);
}

.view-switcher button.active {
  background: var(--surface-muted);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--border);
}

.auth-btn {
  background: transparent;
  border: none;
  color: var(--primary);
  padding: 0.55rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.auth-btn:hover {
  background: var(--surface-muted);
}

.app-header {
  text-align: center;
  margin-bottom: 4rem;
  animation: fadeInDown 0.8s ease-out;
}

.app-header h1 {
  font-size: 3.5rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  color: var(--text-main);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.app-header h1::after {
  content: "";
  display: block;
  width: 3rem;
  height: 4px;
  margin: 1rem auto 0;
  background: var(--primary);
  border-radius: 2px;
}

.app-header p {
  font-size: 1.2rem;
  color: var(--text-muted);
  font-weight: 400;
  max-width: 28rem;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

.app-main {
  width: 100%;
}

.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.loading {
  text-align: center;
  color: var(--text-muted);
  font-size: 1.05rem;
  font-weight: 500;
  margin: 3rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.loading::after {
  content: "";
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.selected-medicine-section {
  margin-top: 2rem;
  animation: fadeInUp 0.6s ease-out;
}

.medicine-info {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--glass-shadow);
  border: 1px solid var(--border);
}

.medicine-info h2 {
  color: var(--text-main);
  margin-bottom: 1.2rem;
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.medicine-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.medicine-details span {
  font-size: 1rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.medicine-details strong {
  color: var(--text-main);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.back-button {
  background: var(--surface-muted);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 0.8rem 1.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.back-button:hover {
  background: var(--surface-card);
  border-color: var(--border-strong);
  transform: translateX(-3px);
}

.pharmacy-controls {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 1.5rem 0 0.5rem;
  flex-wrap: wrap;
}

.sort-distance-button {
  background: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 0.65rem 1.2rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.sort-distance-button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.sort-distance-button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.sort-distance-button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.location-error {
  color: #b91c1c;
  font-size: 0.85rem;
}

.location-source {
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 500;
}

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

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@media (max-width: 768px) {
  .app {
    padding: 1.5rem 1rem calc(5rem + env(safe-area-inset-bottom));
  }

  .app-header h1 {
    font-size: 2.35rem;
  }

  .app-header p {
    font-size: 1rem;
  }

  .medicine-info {
    padding: 1.5rem;
  }

  .medicine-info h2 {
    font-size: 1.65rem;
  }

  .view-switcher {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(0.75rem + env(safe-area-inset-bottom));
    z-index: 100;
    width: auto;
    max-width: 32rem;
    margin: 0 auto;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow:
      0 10px 30px rgba(28, 25, 23, 0.12),
      0 2px 6px rgba(28, 25, 23, 0.06);
    padding: 0.5rem;
    overflow: visible;
    justify-content: space-around;
    align-items: stretch;
    gap: 0.25rem;
  }

  .view-switcher button {
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.2rem;
    padding: 0.4rem 0.3rem 0.45rem;
    border-radius: 14px;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    position: relative;
    overflow: visible;
  }

  .view-switcher button:hover {
    background: transparent;
  }

  .view-switcher button .nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 999px;
    font-size: 1.05rem;
    line-height: 1;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
                background 0.2s ease,
                box-shadow 0.2s ease,
                width 0.2s ease,
                height 0.2s ease;
  }

  .view-switcher button .nav-label {
    font-size: 0.7rem;
    line-height: 1;
    max-width: none;
    color: inherit;
    transition: color 0.2s ease, font-weight 0.2s ease;
  }

  .view-switcher button.active {
    background: transparent;
    box-shadow: none;
    color: var(--text-main);
  }

  .view-switcher button.active .nav-icon {
    width: 2.7rem;
    height: 2.7rem;
    background: var(--surface);
    color: var(--primary);
    font-size: 1.3rem;
    border: 1px solid var(--border);
    box-shadow:
      0 0 0 5px var(--surface),
      0 10px 22px rgba(15, 118, 110, 0.22),
      0 4px 8px rgba(28, 25, 23, 0.08);
    transform: translateY(-1.1rem);
    margin-bottom: -0.6rem;
  }

  .view-switcher button.active .nav-label {
    font-weight: 700;
    color: var(--text-main);
  }

  .auth-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.2rem;
    padding: 0.4rem 0.3rem 0.45rem;
    border-radius: 14px;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 500;
    background: transparent;
  }

  .auth-btn:hover {
    background: transparent;
  }

  .auth-btn .nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.65rem;
    height: 1.65rem;
    font-size: 1.05rem;
    line-height: 1;
  }

  .auth-btn .nav-label {
    font-size: 0.7rem;
    line-height: 1;
  }
}
