﻿:root {
  --primary: #0f766e;
  --primary-text: #ffffff;
  --page-bg: #f5f7fb;
  --card-bg: #ffffff;
  --card-radius: 16px;
  --cards-per-row: 4;
  --card-shadow: 0 14px 45px rgba(16, 35, 58, .09);
  --text: #172033;
  --muted: #667085;
  --border: #e5e7eb;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --warning: #92400e;
  --warning-bg: #fffbeb;
  --success: #067647;
  --success-bg: #ecfdf3;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--page-bg);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

body.modal-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.site-header {
  background:
    linear-gradient(
      135deg,
      var(--primary),
      color-mix(
        in srgb,
        var(--primary) 78%,
        #000 22%
      )
    );
  color: var(--primary-text);
  padding: 28px 20px 34px;
}

.header-inner {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 7px;
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .88;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 3rem);
  line-height: 1.08;
  letter-spacing: -.035em;
}

.intro {
  max-width: 650px;
  margin: 12px 0 0;
  color: color-mix(
    in srgb,
    var(--primary-text) 88%,
    transparent
  );
}

.storefront {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 22px 20px 80px;
}

.store-section {
  margin-bottom: 24px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-label {
  margin: 0 0 3px;
  color: var(--primary);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.section-heading h2,
.track-card h2,
.modal-card h2,
.result-card h2 {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.65rem);
  line-height: 1.2;
  letter-spacing: -.025em;
}

.secondary,
.primary {
  min-height: 44px;
  border-radius: 11px;
  padding: 10px 17px;
  font-weight: 750;
  border: 1px solid transparent;
  transition:
    transform .15s ease,
    box-shadow .15s ease,
    background .15s ease;
}

.primary {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
  box-shadow: 0 8px 20px rgba(15, 118, 110, .18);
}

.secondary {
  background: var(--card-bg);
  color: var(--text);
  border-color: var(--border);
}

.primary:hover:not(:disabled),
.secondary:hover:not(:disabled) {
  transform: translateY(-1px);
}

.primary:hover:not(:disabled) {
  box-shadow: 0 10px 25px rgba(15, 118, 110, .24);
}

.share-button {
  flex: 0 0 auto;
}

.network-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  padding: 6px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 15px;
  box-shadow: var(--card-shadow);
}

.network-tab {
  min-height: 48px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  padding: 9px 12px;
  transition:
    background .15s ease,
    color .15s ease,
    transform .15s ease;
}

.network-tab:hover:not(:disabled) {
  background: #f2f4f7;
  color: var(--text);
}

.network-tab.active {
  background: var(--primary);
  color: var(--primary-text);
  box-shadow: 0 5px 14px rgba(0, 0, 0, .08);
}

.bundle-count {
  color: var(--muted);
  font-size: .86rem;
  font-weight: 650;
}

.bundle-grid {
  display: grid;
  grid-template-columns:
    repeat(
      var(--cards-per-row),
      minmax(0, 1fr)
    );
  gap: 12px;
}

.bundle-card {
  min-width: 0;
  min-height: 112px;
  padding: 15px 13px;
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  background: var(--card-bg);
  color: var(--text);
  box-shadow: var(--card-shadow);
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  transition:
    transform .15s ease,
    border-color .15s ease,
    box-shadow .15s ease;
}

.bundle-card:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 17px 38px rgba(16, 35, 58, .13);
}

.bundle-size {
  font-size: 1.35rem;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: -.025em;
}

.bundle-name {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: .78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bundle-price {
  margin-top: 5px;
  color: var(--primary);
  font-size: .96rem;
}

.loading-state,
.empty-state {
  padding: 28px;
  border: 1px dashed var(--border);
  border-radius: var(--card-radius);
  background: var(--card-bg);
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  color: var(--text);
  margin-bottom: 5px;
}

.empty-state p {
  margin: 0;
}

.track-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
}

.track-card p:not(.section-label) {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: .9rem;
}

.result-card {
  margin: 0 0 25px;
  padding: 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
}

.result-card p {
  margin: 8px 0;
}

.error {
  color: var(--danger);
  font-weight: 650;
}

.small {
  color: var(--muted);
  font-size: .85rem;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .62);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(460px, 100%);
  max-height: min(720px, calc(100vh - 36px));
  overflow-y: auto;
  padding: 25px 21px 21px;
  background: var(--card-bg);
  border-radius: 20px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, .22);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 11px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: #f2f4f7;
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
}

.modal-description {
  margin: 8px 0 19px;
  color: var(--muted);
}

.modal-card label {
  display: block;
  margin-top: 10px;
  font-size: .88rem;
  font-weight: 750;
}

.modal-card input {
  display: block;
  width: 100%;
  min-height: 52px;
  margin-top: 7px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: none;
  background: var(--card-bg);
  color: var(--text);
  font-size: 1.05rem;
}

.modal-card input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(
    in srgb,
    var(--primary) 15%,
    transparent
  );
}

.input-help {
  margin: 7px 0 13px;
  color: var(--muted);
  font-size: .78rem;
}

.network-detection,
.network-warning {
  margin: 12px 0;
  padding: 11px 12px;
  border-radius: 10px;
  font-size: .86rem;
}

.network-detection {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #abefc6;
}

.network-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid #fedf89;
}

.full-width {
  width: 100%;
  margin-top: 12px;
}

.confirmation-details {
  margin: 18px 0;
  border: 1px solid var(--border);
  border-radius: 13px;
  overflow: hidden;
}

.confirmation-details div {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
}

.confirmation-details div:last-child {
  border-bottom: 0;
}

.confirmation-details span {
  color: var(--muted);
  font-size: .84rem;
}

.confirmation-details strong {
  text-align: right;
}

.confirmation-warning {
  margin: 14px 0;
  padding: 12px;
  background: var(--warning-bg);
  border: 1px solid #fedf89;
  border-radius: 10px;
  color: var(--warning);
  font-size: .83rem;
}

.back-to-top {
  position: fixed;
  right: 17px;
  bottom: 17px;
  z-index: 900;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-text);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
  font-size: 1.3rem;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity .2s ease,
    transform .2s ease;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .bundle-grid {
    grid-template-columns:
      repeat(
        4,
        minmax(115px, 1fr)
      );
  }
}

@media (max-width: 700px) {
  .site-header {
    padding: 22px 15px 27px;
  }

  .header-inner {
    display: block;
  }

  .share-button {
    width: 100%;
    margin-top: 17px;
  }

  .storefront {
    padding: 17px 14px 70px;
  }

  .network-tabs {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .network-tabs::-webkit-scrollbar {
    display: none;
  }

  .network-tab {
    flex: 0 0 auto;
    min-width: 112px;
  }

  .bundle-grid {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    padding: 3px 2px 12px;
    margin-right: -14px;
    padding-right: 14px;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }

  .bundle-card {
    flex: 0 0 112px;
    min-height: 105px;
    scroll-snap-align: start;
  }

  .section-heading {
    align-items: flex-end;
  }

  .track-card {
    display: block;
  }

  .track-card .secondary {
    width: 100%;
    margin-top: 14px;
  }

  .modal {
    padding: 10px;
    align-items: end;
  }

  .modal-card {
    width: 100%;
    max-height: calc(100vh - 20px);
    border-radius: 20px 20px 12px 12px;
    padding: 23px 17px 17px;
  }
}

@media (max-width: 430px) {
  .site-header h1 {
    font-size: 1.85rem;
  }

  .intro {
    font-size: .9rem;
  }

  .section-heading h2 {
    font-size: 1.25rem;
  }

  .bundle-card {
    flex-basis: 106px;
    min-height: 100px;
    padding: 13px 11px;
  }

  .bundle-size {
    font-size: 1.25rem;
  }

  .bundle-price {
    font-size: .88rem;
  }

  .network-tab {
    min-width: 105px;
    font-size: .86rem;
  }

  .modal-card h2 {
    font-size: 1.35rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
/* =========================================================
   CampusTech Storefront — Appearance + Contrast Fix
   Keeps Admin Appearance settings as the source of truth.
   Adds readable automatic light/dark presentation.
   ========================================================= */

:root {
  color-scheme: light dark;

  /* Keep the existing Appearance variables when available. */
  --store-primary:
    var(--primary-color, var(--primary, #06b6d4));

  --store-primary-text:
    var(--primary-text-color, var(--primary-text, #ffffff));

  --store-page:
    var(--page-background, var(--page-bg, #ffffff));

  --store-card:
    var(--card-background, var(--card-bg, #ffffff));

  /* Accessible defaults for text. */
  --store-text-light: #102a43;
  --store-muted-light: #486581;
  --store-border-light: #bcccdc;

  --store-text-dark: #f7fafc;
  --store-muted-dark: #cbd5e1;
  --store-border-dark: #64748b;
}

/* -------------------------
   LIGHT MODE
   ------------------------- */

@media (prefers-color-scheme: light) {
  body {
    background: var(--store-page) !important;
    color: var(--store-text-light) !important;
  }

  .store-section,
  .track-card,
  .bundle-card,
  .result-card {
    color: var(--store-text-light) !important;
  }

  .section-heading h2,
  .bundles-section h2,
  .track-card h2,
  .bundle-card h3,
  .modal-card h2 {
    color: var(--store-text-light) !important;
  }

  .section-heading p,
  .track-card p,
  .modal-description,
  .input-help {
    color: var(--store-muted-light) !important;
  }

  .bundle-card {
    background: var(--store-card) !important;
    border-color: var(--store-border-light) !important;
  }

  .bundle-card .bundle-size,
  .bundle-card small,
  .bundle-count {
    color: var(--store-muted-light) !important;
  }

  .bundle-card .bundle-price {
    color: var(--store-primary) !important;
  }

  .network-tabs {
    border-color: var(--store-border-light) !important;
  }

  .network-tab {
    color: var(--store-muted-light) !important;
  }

  .network-tab.active {
    color: var(--store-primary-text) !important;
    background: var(--store-primary) !important;
  }

  .track-card {
    background: var(--store-card) !important;
    border-color: var(--store-border-light) !important;
  }

  input,
  select,
  textarea {
    color: var(--store-text-light) !important;
    background: var(--store-card) !important;
    border-color: var(--store-border-light) !important;
  }

  input::placeholder,
  textarea::placeholder {
    color: var(--store-muted-light) !important;
    opacity: 1 !important;
  }

  .secondary,
  .share-button,
  #check-link {
    color: var(--store-primary) !important;
    border-color: var(--store-primary) !important;
    background: transparent !important;
  }

  .secondary:hover,
  .share-button:hover,
  #check-link:hover {
    color: var(--store-primary-text) !important;
    background: var(--store-primary) !important;
  }
}

/* -------------------------
   DARK MODE
   ------------------------- */

@media (prefers-color-scheme: dark) {
  body {
    /*
      The admin-selected page background still influences the result,
      but the dark theme prevents a white/light appearance from becoming
      an unreadable dark-text-on-dark-background combination.
    */
    background:
      color-mix(
        in srgb,
        var(--store-page) 18%,
        #090b0f
      ) !important;

    color: var(--store-text-dark) !important;
  }

  .store-section,
  .track-card,
  .bundle-card,
  .result-card {
    color: var(--store-text-dark) !important;
  }

  .section-heading h2,
  .bundles-section h2,
  .track-card h2,
  .bundle-card h3,
  .modal-card h2 {
    color: var(--store-text-dark) !important;
  }

  .section-heading p,
  .track-card p,
  .modal-description,
  .input-help {
    color: var(--store-muted-dark) !important;
  }

  .bundle-card {
    background:
      color-mix(
        in srgb,
        var(--store-card) 22%,
        #171a1f
      ) !important;

    border-color: var(--store-border-dark) !important;
  }

  .bundle-card .bundle-size,
  .bundle-card small,
  .bundle-count {
    color: var(--store-muted-dark) !important;
  }

  .bundle-card .bundle-price {
    color: var(--store-primary) !important;
  }

  .network-tabs {
    border-color: var(--store-border-dark) !important;
  }

  .network-tab {
    color: var(--store-muted-dark) !important;
  }

  .network-tab.active {
    color: var(--store-primary-text) !important;
    background: var(--store-primary) !important;
  }

  .track-card {
    background:
      color-mix(
        in srgb,
        var(--store-card) 22%,
        #171a1f
      ) !important;

    border-color: var(--store-border-dark) !important;
  }

  input,
  select,
  textarea {
    color: var(--store-text-dark) !important;

    background:
      color-mix(
        in srgb,
        var(--store-card) 20%,
        #0f1216
      ) !important;

    border-color: var(--store-border-dark) !important;

    caret-color: var(--store-primary) !important;
  }

  input::placeholder,
  textarea::placeholder {
    color: #94a3b8 !important;
    opacity: 1 !important;
  }

  .secondary,
  .share-button,
  #check-link {
    color: var(--store-primary) !important;
    border-color: var(--store-primary) !important;
    background: transparent !important;
  }

  .secondary:hover,
  .share-button:hover,
  #check-link:hover {
    color: var(--store-primary-text) !important;
    background: var(--store-primary) !important;
  }

  .modal-card {
    color: var(--store-text-dark) !important;
    background:
      color-mix(
        in srgb,
        var(--store-card) 25%,
        #15181d
      ) !important;
  }

  .confirmation-details span {
    color: var(--store-muted-dark) !important;
  }

  .confirmation-details strong {
    color: var(--store-text-dark) !important;
  }

  .network-detection {
    color: var(--store-text-dark) !important;
  }

  .network-warning {
    color: #fde68a !important;
  }
}

/* -------------------------
   GENERAL CONTRAST SAFETY
   ------------------------- */

button,
input,
select,
textarea {
  font: inherit;
}

.bundle-card h3,
.section-heading h2,
.track-card h2 {
  text-shadow: none !important;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--store-primary) !important;
  outline-offset: 2px !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* Final dark-mode contrast fix for detected-network status */
@media (prefers-color-scheme: dark) {
  .network-detection {
    color: #123b2a !important;
    background: #dff7e9 !important;
    border-color: #8fd3aa !important;
    font-weight: 700 !important;
  }

  .network-warning {
    color: #4a3200 !important;
    background: #fff3cd !important;
    border-color: #e4c76a !important;
    font-weight: 600 !important;
  }
}

/* Keep detection text readable in light mode too */
@media (prefers-color-scheme: light) {
  .network-detection {
    color: #123b2a !important;
    background: #dff7e9 !important;
    border-color: #8fd3aa !important;
    font-weight: 700 !important;
  }

  .network-warning {
    color: #4a3200 !important;
    background: #fff3cd !important;
    border-color: #e4c76a !important;
    font-weight: 600 !important;
  }
}
