/* ==========================================================================
   Central da Farmácia — HSAG
   Design tokens (Light & Dark) + Architectural clinical layout
   ========================================================================== */

:root {
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --radius-card: 18px;
  --radius-icon: 18px;
  --radius-brand: 14px;
  --radius-pill: 999px;
  --container-max: 1180px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --transition-theme: 120ms ease;
}

/* Light Mode — Porcelain Clinical & Soft Eucalyptus Gradient */
[data-theme="light"] {
  color-scheme: light;

  --bg-base: #f5faf7;
  --bg-gradient: linear-gradient(132deg, #fbfdfc 0%, #f1f8f5 54%, #e2f2eb 100%);
  --bg-glow-tr: radial-gradient(ellipse 62% 58% at 91% 10%, rgba(164, 232, 209, 0.56) 0%, rgba(196, 239, 224, 0.24) 44%, transparent 74%);
  --bg-glow-bl: radial-gradient(ellipse 46% 42% at 10% 94%, rgba(208, 236, 225, 0.38) 0%, transparent 72%);

  --ink-primary: #0c1f19;
  --ink-secondary: #425d54;
  --ink-muted: #587269;

  --brand-box-bg: rgba(255, 255, 255, 0.65);
  --brand-box-border: #203d34;
  --brand-logo-color: #10251e;

  --switch-track-bg: rgba(182, 211, 201, 0.56);
  --switch-track-border: rgba(142, 182, 169, 0.42);
  --switch-active-bg: linear-gradient(180deg, #ffffff 0%, #f7fbf9 100%);
  --switch-active-shadow: 0 3px 10px -2px rgba(12, 34, 27, 0.14), 0 1px 2px rgba(12, 34, 27, 0.08);
  --switch-active-ink: #0d211b;
  --switch-inactive-ink: #38534a;

  --card-bg: linear-gradient(180deg, #ffffff 0%, #f3faf7 100%);
  --card-bg-hover: linear-gradient(180deg, #ffffff 0%, #eaf6f1 100%);
  --card-border: #d1e2da;
  --card-border-hover: #a6cabd;
  --card-shadow: 0 12px 28px -12px rgba(13, 45, 35, 0.12), 0 2px 6px rgba(13, 45, 35, 0.045);
  --card-shadow-hover: 0 18px 36px -14px rgba(13, 45, 35, 0.18), 0 4px 12px rgba(13, 45, 35, 0.06);
  --card-top-highlight: rgba(255, 255, 255, 0.9);
  --card-accent-height: 4px;

  --arrow-bg: #e1eee8;
  --arrow-bg-hover: #cfe4db;
  --arrow-border: transparent;
  --arrow-ink: #4e6b61;
  --arrow-ink-hover: #0e261e;

  --divider: rgba(25, 68, 54, 0.13);
  --focus-ring: #0e765a;

  --toast-bg: #0f261f;
  --toast-ink: #f1f9f6;
  --toast-border: rgba(255, 255, 255, 0.12);
  --toast-dot: #38c99d;

  /* Clinical module gradients — Light */
  --grad-codigos: linear-gradient(145deg, #0c6950 0%, #168b6c 55%, #20a581 100%);
  --bar-codigos: linear-gradient(90deg, #0d6e54 0%, #1d9675 100%);
  --shadow-codigos: 0 10px 22px -8px rgba(14, 114, 87, 0.44);

  --grad-folha: linear-gradient(145deg, #13556d 0%, #1d7390 55%, #2a91ae 100%);
  --bar-folha: linear-gradient(90deg, #155c75 0%, #2788a6 100%);
  --shadow-folha: 0 10px 22px -8px rgba(21, 95, 120, 0.42);

  --grad-kits: linear-gradient(145deg, #955312 0%, #b76f20 55%, #d18834 100%);
  --bar-kits: linear-gradient(90deg, #9c5814 0%, #c97f2d 100%);
  --shadow-kits: 0 10px 22px -8px rgba(158, 92, 22, 0.42);

  --grad-label: linear-gradient(145deg, #1e4372 0%, #2a5b94 55%, #3a73b4 100%);
  --bar-label: linear-gradient(90deg, #21497a 0%, #376dab 100%);
  --shadow-label: 0 10px 22px -8px rgba(34, 75, 126, 0.42);
}

/* Dark Mode — Deep Forest Slate & Restrained Emerald Gradient */
[data-theme="dark"] {
  color-scheme: dark;

  --bg-base: #08120f;
  --bg-gradient: linear-gradient(135deg, #07100d 0%, #0b1814 55%, #091411 100%);
  --bg-glow-tr: radial-gradient(ellipse 56% 54% at 88% 12%, rgba(28, 134, 102, 0.28) 0%, rgba(16, 84, 64, 0.14) 45%, transparent 74%);
  --bg-glow-bl: radial-gradient(ellipse 46% 42% at 12% 92%, rgba(20, 92, 72, 0.14) 0%, transparent 70%);

  --ink-primary: #eff7f4;
  --ink-secondary: #8ea89f;
  --ink-muted: #7c968d;

  --brand-box-bg: linear-gradient(180deg, #172b24 0%, #11211c 100%);
  --brand-box-border: #2a473d;
  --brand-logo-color: #edf6f2;

  --switch-track-bg: rgba(16, 33, 28, 0.88);
  --switch-track-border: #27443a;
  --switch-active-bg: linear-gradient(180deg, #233f36 0%, #1b332b 100%);
  --switch-active-shadow: 0 3px 10px -2px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --switch-active-ink: #f1f8f5;
  --switch-inactive-ink: #7e9a91;

  --card-bg: linear-gradient(180deg, #182c25 0%, #101f1a 100%);
  --card-bg-hover: linear-gradient(180deg, #1d352d 0%, #13251f 100%);
  --card-border: #264138;
  --card-border-hover: #365c4f;
  --card-shadow: 0 14px 32px -14px rgba(0, 0, 0, 0.56);
  --card-shadow-hover: 0 20px 40px -14px rgba(0, 0, 0, 0.7);
  --card-top-highlight: rgba(255, 255, 255, 0.065);
  --card-accent-height: 0px;

  --arrow-bg: rgba(255, 255, 255, 0.055);
  --arrow-bg-hover: rgba(255, 255, 255, 0.11);
  --arrow-border: rgba(255, 255, 255, 0.07);
  --arrow-ink: #b9d0c8;
  --arrow-ink-hover: #ffffff;

  --divider: rgba(202, 232, 221, 0.1);
  --focus-ring: #38c99d;

  --toast-bg: #1a332b;
  --toast-ink: #eef7f4;
  --toast-border: #315448;
  --toast-dot: #3ad1a3;

  /* Clinical module gradients — Dark */
  --grad-codigos: linear-gradient(145deg, #127d60 0%, #1b9b78 55%, #25b58d 100%);
  --bar-codigos: linear-gradient(90deg, #16906f 0%, #27ba91 100%);
  --shadow-codigos: 0 10px 24px -8px rgba(18, 148, 113, 0.42);

  --grad-folha: linear-gradient(145deg, #186884 0%, #2387a8 55%, #30a4c8 100%);
  --bar-folha: linear-gradient(90deg, #1c7898 0%, #30a4c8 100%);
  --shadow-folha: 0 10px 24px -8px rgba(28, 128, 160, 0.4);

  --grad-kits: linear-gradient(145deg, #a76017 0%, #c87b26 55%, #e1953c 100%);
  --bar-kits: linear-gradient(90deg, #b56a1c 0%, #e1953c 100%);
  --shadow-kits: 0 10px 24px -8px rgba(196, 118, 34, 0.4);

  --grad-label: linear-gradient(145deg, #27538a 0%, #346db1 55%, #4787d1 100%);
  --bar-label: linear-gradient(90deg, #2c5e9b 0%, #4787d1 100%);
  --shadow-label: 0 10px 24px -8px rgba(52, 110, 179, 0.42);
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg-base);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-theme), color var(--transition-theme);
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:focus-visible {
  outline: 2.5px solid var(--focus-ring);
  outline-offset: 3px;
}

/* Layered architectural gradient canvas */
.ambientCanvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--bg-glow-tr), var(--bg-glow-bl), var(--bg-gradient);
  background-repeat: no-repeat;
  background-size: cover;
  transition: opacity var(--transition-theme);
}

/* ==========================================================================
   Page Shell
   ========================================================================== */

.pageShell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: clamp(24px, 3.8vw, 44px) clamp(20px, 4.5vw, 56px) clamp(20px, 2.8vw, 32px);
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Header / Topbar
   ========================================================================== */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brandMark {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: var(--radius-brand);
  background: var(--brand-box-bg);
  border: 1.5px solid var(--brand-box-border);
  display: grid;
  place-items: center;
  color: var(--brand-logo-color);
  transition: background var(--transition-theme), border-color var(--transition-theme), color var(--transition-theme);
}

.brandMark svg {
  width: 40px;
  height: 40px;
  display: block;
}

.brandText {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brandTitle {
  font-size: clamp(1rem, 1.45vw, 1.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink-primary);
}

.brandSubtitle {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink-secondary);
}

/* Theme Segmented Switch */
.themeSwitch {
  display: inline-flex;
  align-items: center;
  padding: 4px;
  gap: 2px;
  border-radius: var(--radius-pill);
  background: var(--switch-track-bg);
  border: 1px solid var(--switch-track-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background var(--transition-theme), border-color var(--transition-theme);
}

.themeBtn {
  appearance: none;
  border: 0;
  background: transparent;
  min-height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--switch-inactive-ink);
  transition: background 180ms var(--ease-out), color 180ms ease, box-shadow 180ms var(--ease-out);
}

.themeBtn:hover:not([aria-pressed="true"]) {
  color: var(--ink-primary);
}

.themeBtn[aria-pressed="true"] {
  background: var(--switch-active-bg);
  color: var(--switch-active-ink);
  box-shadow: var(--switch-active-shadow);
}

.themeIcon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ==========================================================================
   Main Content & Intro
   ========================================================================== */

.mainContent {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(32px, 5vh, 56px) 0 clamp(36px, 5.5vh, 60px);
}

.intro {
  margin-bottom: clamp(28px, 4.2vh, 44px);
}

.pageTitle {
  margin: 0;
  font-size: clamp(2rem, 3.7vw, 3.05rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.08;
  color: var(--ink-primary);
}

.pageSubtitle {
  margin: 12px 0 0;
  font-size: clamp(0.98rem, 1.35vw, 1.1875rem);
  font-weight: 400;
  line-height: 1.48;
  color: var(--ink-secondary);
  max-width: 60ch;
}

/* ==========================================================================
   2x2 Architectural Module Grid
   ========================================================================== */

.moduleGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(18px, 2.2vw, 28px);
}

.moduleTile {
  position: relative;
  overflow: hidden;
  appearance: none;
  width: 100%;
  min-height: 156px;
  padding: 28px 26px;
  border-radius: var(--radius-card);
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  box-shadow: var(--card-shadow), inset 0 1px 0 var(--card-top-highlight);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  text-align: left;
  transition:
    transform 220ms var(--ease-out),
    border-color 220ms ease,
    box-shadow 220ms var(--ease-out),
    background 220ms ease;
}

.moduleTile:hover {
  transform: translateY(-2px);
  background: var(--card-bg-hover);
  border-color: var(--card-border-hover);
  box-shadow: var(--card-shadow-hover), inset 0 1px 0 var(--card-top-highlight);
}

.moduleTile:active {
  transform: translateY(0) scale(0.994);
}

/* Signature top color bar (active in Light mode, clean subtle accent on hover in Dark) */
.moduleAccent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--card-accent-height);
  pointer-events: none;
  transition: height 200ms var(--ease-out), opacity 200ms ease;
}

[data-theme="dark"] .moduleTile:hover .moduleAccent {
  height: 2px;
  opacity: 0.9;
}

.moduleTile[data-module="codigos"] .moduleAccent { background: var(--bar-codigos); }
.moduleTile[data-module="folha"] .moduleAccent   { background: var(--bar-folha); }
.moduleTile[data-module="kits"] .moduleAccent    { background: var(--bar-kits); }
.moduleTile[data-module="label"] .moduleAccent   { background: var(--bar-label); }

/* Module Icon Squircle Tile */
.moduleIconTile {
  width: 86px;
  height: 86px;
  border-radius: var(--radius-icon);
  display: grid;
  place-items: center;
  color: #ffffff;
  flex-shrink: 0;
  position: relative;
  transition: transform 240ms var(--ease-out);
}

.moduleIconTile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), inset 0 -1px 0 rgba(0, 0, 0, 0.14);
  pointer-events: none;
}

.moduleIconTile svg {
  width: 48px;
  height: 48px;
  display: block;
}

.iconCodigos { background: var(--grad-codigos); box-shadow: var(--shadow-codigos); }
.iconFolha   { background: var(--grad-folha);   box-shadow: var(--shadow-folha); }
.iconKits    { background: var(--grad-kits);    box-shadow: var(--shadow-kits); }
.iconLabel   { background: var(--grad-label);   box-shadow: var(--shadow-label); }

.moduleTile:hover .moduleIconTile {
  transform: scale(1.03);
}

/* Module Text */
.moduleBody {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.moduleTitle {
  font-size: clamp(1.22rem, 1.65vw, 1.44rem);
  font-weight: 800;
  letter-spacing: -0.012em;
  line-height: 1.18;
  color: var(--ink-primary);
}

.moduleDesc {
  font-size: clamp(0.9rem, 1.08vw, 0.985rem);
  font-weight: 400;
  line-height: 1.46;
  color: var(--ink-secondary);
  max-width: 27ch;
}

/* Directional Chevron Button */
.moduleArrow {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--arrow-bg);
  border: 1px solid var(--arrow-border);
  color: var(--arrow-ink);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 180ms ease, color 180ms ease, transform 220ms var(--ease-out);
}

.moduleArrow svg {
  width: 20px;
  height: 20px;
  display: block;
}

.moduleTile:hover .moduleArrow,
.moduleTile:focus-visible .moduleArrow {
  background: var(--arrow-bg-hover);
  color: var(--arrow-ink-hover);
  transform: translateX(3px);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-muted);
}

/* ==========================================================================
   Feedback Toast (only visible after clicking an unlinked module)
   ========================================================================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(12px);
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  border: 1px solid var(--toast-border);
  box-shadow: 0 14px 32px -8px rgba(0, 0, 0, 0.35);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.35;
  width: max-content;
  max-width: calc(100vw - 32px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 220ms var(--ease-out);
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toastDot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--toast-dot);
  flex-shrink: 0;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 900px) {
  .moduleGrid {
    grid-template-columns: 1fr;
  }

  .moduleTile {
    min-height: 128px;
    padding: 22px 20px;
    gap: 18px;
  }

  .moduleIconTile {
    width: 68px;
    height: 68px;
    border-radius: 16px;
  }

  .moduleIconTile svg {
    width: 34px;
    height: 34px;
  }

  .moduleDesc {
    max-width: none;
  }
}

@media (max-width: 600px) {
  .topbar {
    align-items: flex-start;
    gap: 16px;
  }

  .brandMark {
    width: 48px;
    height: 48px;
    border-radius: 12px;
  }

  .brandMark svg {
    width: 34px;
    height: 34px;
  }

  .themeSwitch {
    margin-left: auto;
  }

  .themeBtn {
    min-height: 36px;
    padding: 0 13px;
    font-size: 0.8125rem;
  }

  .mainContent {
    justify-content: flex-start;
    padding: 28px 0 32px;
  }

  .moduleTile {
    padding: 18px 16px;
    gap: 14px;
    min-height: 110px;
  }

  .moduleIconTile {
    width: 58px;
    height: 58px;
    border-radius: 14px;
  }

  .moduleIconTile svg {
    width: 30px;
    height: 30px;
  }

  .moduleArrow {
    width: 34px;
    height: 34px;
  }

  .footer {
    font-size: 0.8125rem;
  }
}

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