/* ==========================================================================
   LME Glaucoma — Premium Design System
   ========================================================================== */

/* --- Design Tokens ------------------------------------------------------ */

:root {
  --bg: #0B0D15;
  --bg-glow-1: rgba(52, 211, 153, 0.07);
  --bg-glow-2: rgba(129, 140, 248, 0.05);

  --surface: #131620;
  --surface-elevated: #191D28;
  --surface-glass: rgba(255, 255, 255, 0.03);

  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.10);
  --border-focus: rgba(255, 255, 255, 0.18);
  --border-active: #34D399;

  --primary: #34D399;
  --primary-dark: #10B981;
  --primary-subtle: rgba(52, 211, 153, 0.12);

  --text: #F1F5F9;
  --text-secondary: rgba(255, 255, 255, 0.55);
  --text-muted: rgba(255, 255, 255, 0.30);
  --text-inverse: #0B0D15;

  --error: #F87171;
  --error-bg: rgba(248, 113, 113, 0.10);
  --success: #34D399;
  --success-bg: rgba(52, 211, 153, 0.10);

  --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;

  --radius-inner: 14px;
  --radius-outer: 20px;
  --radius-pill: 9999px;

  --cubic-smooth: cubic-bezier(0.32, 0.72, 0, 1);
  --cubic-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --cubic-out: cubic-bezier(0.16, 1, 0.3, 1);

  --duration: 0.6s;
}

/* --- Reset -------------------------------------------------------------- */

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

/* --- Body --------------------------------------------------------------- */

body {
  font-family: var(--font);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 90% 50% at 50% -15%, var(--bg-glow-1), transparent),
    radial-gradient(ellipse 50% 35% at 85% 90%, var(--bg-glow-2), transparent);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* --- Subtle Noise Overlay ---------------------------------------------- */

body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* --- Container ---------------------------------------------------------- */

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 24px 48px;
  position: relative;
  z-index: 1;
}

/* --- Header (Double-Bezel) --------------------------------------------- */

.header-shell {
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-outer);
  padding: 1px;
  margin: 44px auto 40px;
  max-width: 560px;
  position: relative;
}

.header-shell::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: calc(var(--radius-outer) + 1px);
  padding: 1px;
  background: conic-gradient(from 180deg at 50% 50%,
    rgba(52, 211, 153, 0.15),
    rgba(129, 140, 248, 0.08),
    rgba(52, 211, 153, 0.02),
    rgba(129, 140, 248, 0.08),
    rgba(52, 211, 153, 0.15)
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.header {
  background: var(--surface-elevated);
  border-radius: calc(var(--radius-outer) - 1px);
  padding: 32px 24px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.header::after {
  content: '';
  position: absolute;
  top: -60%;
  left: -20%;
  width: 140%;
  height: 140%;
  background: radial-gradient(ellipse at 30% 40%, rgba(52, 211, 153, 0.04), transparent 60%);
  pointer-events: none;
}

.header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text);
  margin-bottom: 6px;
  position: relative;
}

.header .subtitle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  position: relative;
}

.header .subtitle::before,
.header .subtitle::after {
  content: '';
  width: 16px;
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
}

/* --- Card Shell (Double-Bezel Architecture) ---------------------------- */

.card-shell {
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-outer);
  padding: 1px;
  margin-bottom: 16px;
  transition: opacity var(--duration) var(--cubic-smooth),
              transform var(--duration) var(--cubic-smooth);
}

.card-inner {
  background: var(--surface);
  border-radius: calc(var(--radius-outer) - 1px);
  padding: 28px 24px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* --- Two-Column Layout -------------------------------------------------- */

.layout-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.col-left {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.col-left .card-shell {
  margin-bottom: 0;
}

.col-right .card-shell {
  margin-bottom: 0;
}

/* --- Entry Animations -------------------------------------------------- */

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card-shell {
  animation: cardIn var(--duration) var(--cubic-out) both;
}

.col-left .card-shell:nth-child(1) { animation-delay: 0.05s; }
.col-left .card-shell:nth-child(2) { animation-delay: 0.16s; }
.col-right .card-shell { animation-delay: 0.10s; }

/* --- Section Headings -------------------------------------------------- */

.card-inner h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
  letter-spacing: -0.1px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-clear {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
  flex-shrink: 0;
}

.btn-clear:hover {
  background: var(--error-bg);
  border-color: var(--error);
  color: var(--error);
}

.card-inner h2::before {
  content: '';
  width: 3px;
  height: 16px;
  background: var(--primary);
  border-radius: 2px;
  flex-shrink: 0;
}

.section-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: -14px;
  margin-bottom: 20px;
  padding-left: 13px;
}

/* --- Fields ------------------------------------------------------------- */

.field {
  margin-bottom: 16px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* --- Inputs (Glass) ----------------------------------------------------- */

.field input[type="text"],
.field input[type="date"],
.field input[type="number"],
.field select {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
  outline: none;
  transition:
    border-color var(--duration) var(--cubic-smooth),
    box-shadow var(--duration) var(--cubic-smooth),
    background var(--duration) var(--cubic-smooth);
  -webkit-appearance: none;
  appearance: none;
}

.field select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='rgba(255,255,255,0.55)' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.field select option {
  background: #191D28;
  color: var(--text);
}

.field input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.field input:hover,
.field select:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.06);
}

.field input:focus-visible,
.field select:focus-visible {
  border-color: var(--border-focus);
  background: rgba(255, 255, 255, 0.06);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.field input.error {
  border-color: var(--error);
  background: var(--error-bg);
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.2);
}

/* --- Field Error & Hint ------------------------------------------------- */

.field-error {
  font-size: 11px;
  font-weight: 500;
  color: var(--error);
  margin-top: 6px;
  min-height: 0;
  transition: opacity 0.3s ease;
  padding-left: 2px;
}

.field-error:empty {
  margin-top: 0;
  opacity: 0;
}

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding-left: 2px;
}

/* --- Field Row ---------------------------------------------------------- */

.field-row {
  display: flex;
  gap: 12px;
}

.field-row .field {
  flex: 1;
}

/* --- Medicações List (Bento Grid) -------------------------------------- */

.medicacoes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: visible;
}

.medicacoes-list > * {
  min-width: 0;
}

.med-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
  padding: 14px 14px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  overflow: visible;
  transition:
    border-color var(--duration) var(--cubic-smooth),
    background var(--duration) var(--cubic-smooth),
    transform 0.3s var(--cubic-spring);
}

.med-item:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.04);
}

.med-item:has(input[type="checkbox"]:checked) {
  border-color: var(--border-active);
  background: var(--primary-subtle);
}

.med-item.has-error {
  border-color: var(--error);
  background: var(--error-bg);
}

.med-item.static {
  cursor: default;
}

.med-item.static:hover {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.02);
}

/* --- Med Header --------------------------------------------------------- */

.med-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  font-size: 13px;
  font-weight: 500;
  padding: 0;
  border: none;
}



.med-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  user-select: none;
}

/* --- Eye Selection (Animated Accordion) --------------------------------- */

.med-olho {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.med-olho > .med-olho-inner {
  display: flex;
  gap: 14px;
  align-items: center;
}



.olho-option {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  transition: background 0.3s ease;
}

.olho-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.olho-option input[type="radio"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}

.olho-option label {
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.olho-error {
  font-size: 11px;
  font-weight: 500;
  color: var(--error);
  margin-left: auto;
}

.olho-error:empty {
  display: none;
}

/* --- Button (Pill with Nested Icon) ------------------------------------- */

.btn-primary {
  width: 100%;
  height: 52px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-inverse);
  background: var(--primary);
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 20px;
  position: relative;
  transition:
    background var(--duration) var(--cubic-smooth),
    transform 0.3s var(--cubic-spring),
    box-shadow var(--duration) var(--cubic-smooth);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow:
    0 8px 30px rgba(52, 211, 153, 0.2),
    0 2px 8px rgba(52, 211, 153, 0.1);
}

.btn-primary:active {
  transform: translateY(0) scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* --- Button Nested Arrow Icon ------------------------------------------- */

.btn-arrow {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.4s var(--cubic-spring);
}

.btn-arrow svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--text-inverse);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.4s var(--cubic-spring);
}

.btn-primary:hover .btn-arrow {
  transform: translateX(2px) translateY(-1px);
}

.btn-primary:hover .btn-arrow svg {
  transform: translateX(1px);
}

/* Hide arrow when loading spinner is visible */
.btn-primary .spinner:not(.hidden) ~ .btn-arrow {
  display: none;
}

/* --- Spinner ------------------------------------------------------------ */

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-top-color: var(--text-inverse);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.hidden {
  display: none !important;
}

/* --- Feedback ----------------------------------------------------------- */

.feedback {
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: var(--radius-inner);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  animation: cardIn 0.4s var(--cubic-out) both;
}

.feedback.success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.15);
}

.feedback.error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(248, 113, 113, 0.15);
}

.btn-aza-submit {
  margin-top: 16px;
}

/* --- Footer ------------------------------------------------------------- */

.footer {
  text-align: center;
  padding: 40px 0 8px;
  position: relative;
}

.footer span {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.footer::before {
  content: '';
  display: block;
  width: 40px;
  height: 1px;
  background: var(--border);
  margin: 0 auto 16px;
}

/* --- Tab Bar ------------------------------------------------------------ */

.tab-bar {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin: -12px auto 28px;
}

.tab-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 22px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.tab-btn:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.tab-btn.active {
  background: var(--primary-subtle);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.dosagem-tipo {
  display: flex;
  gap: 8px;
}

.dosagem-radio {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  user-select: none;
}

.dosagem-radio:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.04);
}

.dosagem-radio:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-subtle);
  color: var(--primary);
}

.dosagem-radio input {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.field-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  padding: 8px 0;
}

/* --- Support Banner ----------------------------------------------------- */

.support-banner {
  text-align: center;
  margin: -8px auto 28px;
  max-width: 480px;
}

.support-banner p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 10px;
}

.support-banner strong {
  color: var(--primary);
  font-weight: 600;
}

.bmc-wrapper {
  display: flex;
  justify-content: center;
}

/* --- Responsive (Mobile) ------------------------------------------------ */

@media (max-width: 640px) {
  .container {
    padding: 0 12px 32px;
  }

  .header-shell {
    margin: 20px auto 28px;
  }

  .header {
    padding: 24px 18px 22px;
  }

  .header h1 {
    font-size: 20px;
  }

  .card-inner {
    padding: 22px 16px;
  }

  .layout-two-col {
    grid-template-columns: 1fr;
  }

  .col-left .card-shell:nth-child(1) { animation-delay: 0.05s; }
  .col-left .card-shell:nth-child(2) { animation-delay: 0.16s; }
  .col-right .card-shell { animation-delay: 0.10s; }

  .field-row {
    flex-direction: column;
    gap: 0;
  }

  .field input[type="text"],
  .field input[type="date"],
  .field input[type="number"],
  .field select {
    height: 44px;
    font-size: 14px;
  }

  .btn-primary {
    height: 48px;
    font-size: 14px;
  }
  .tab-bar {
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }

  .tab-btn {
    width: 100%;
    max-width: 280px;
    text-align: center;
  }
}

/* --- Reduced Motion ----------------------------------------------------- */

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

  .card-shell {
    animation: none;
  }

  .btn-primary:hover {
    transform: none;
  }

  .med-header input[type="checkbox"]:hover {
    transform: none;
  }
}
