/* ================================================================
   AGE CALCULATOR - COMPACT FORM LAYOUT
   Ensures Calculate Age button is visible without scrolling
   ================================================================ */

/* Reduce form padding and spacing */
.agec-tool-panel {
  padding: 1.25rem 1.5rem;
}

.agec-tool-header {
  margin-bottom: 1rem;
}

.agec-tool-header h3 {
  font-size: 1.25rem;
  margin-bottom: 0.35rem;
}

.agec-tool-header p {
  font-size: 0.9rem;
  margin: 0;
}

/* Compact note text */
.agec-note {
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.agec-input-help {
  font-size: 0.9rem;
  margin-bottom: 0.85rem;
}

/* Reduce fieldset spacing */
.agec-fieldset {
  padding: 1rem 1.25rem;
  margin-bottom: 0.85rem;
}

.agec-legend {
  font-size: 1rem;
  padding-inline: 0.4rem;
}

/* Compact field grid - side by side on all screens */
.agec-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.agec-field-grid > * {
  min-width: 0;
}

.agec-label {
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
}

.agec-input {
  min-height: 44px;
  padding: 0.6rem 0.7rem;
  font-size: 1rem;
  width: 100%;
  box-sizing: border-box;
}

/* Compact format toggle */
.agec-format-toggle .agec-label {
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}

.agec-format-options {
  gap: 0.65rem;
  margin-top: 0.35rem;
}

.agec-format-options label {
  font-size: 0.9rem;
  min-height: 36px;
}

.agec-format-hint {
  font-size: 0.85rem;
  margin-top: 0.35rem;
  line-height: 1.4;
}

/* Compact advanced options */
.agec-advanced {
  margin-top: 0;
}

.agec-advanced .agec-label {
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}

.agec-advanced label {
  font-size: 0.9rem;
  min-height: 36px;
  gap: 0.5rem;
}

/* Compact button row */
.agec-cta-row {
  gap: 0.65rem;
  margin-top: 0;
  flex-wrap: wrap;
}

.agec-btn {
  min-height: 44px;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  border-radius: 10px;
}

/* Make primary button more prominent */
.agec-btn-primary {
  font-weight: 700;
  box-shadow:
    0 4px 12px rgba(99, 102, 241, 0.25),
    0 2px 6px rgba(79, 70, 229, 0.2);
}

.agec-btn-primary:hover {
  box-shadow:
    0 6px 16px rgba(99, 102, 241, 0.35),
    0 3px 8px rgba(79, 70, 229, 0.25);
}

/* Two-column layout for buttons on larger screens */
@media (min-width: 640px) {
  .agec-cta-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
  }

  .agec-btn-primary {
    grid-column: 1 / -1;
  }
}

/* Single column form on mobile */
@media (max-width: 767px) {
  .agec-tool-panel {
    padding: 1rem 1.25rem;
  }

  .agec-fieldset {
    padding: 0.85rem 1rem;
    margin-bottom: 0.75rem;
  }

  /* Stack date inputs vertically on small mobile */
  .agec-field-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .agec-cta-row {
    gap: 0.6rem;
  }

  .agec-btn {
    font-size: 0.9rem;
    padding: 0.6rem 0.9rem;
  }
}

/* Keep side-by-side on larger mobile/tablet */
@media (min-width: 480px) {
  .agec-field-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

/* Desktop: ensure form fits in viewport */
@media (min-width: 768px) {
  .agec-tool-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    align-items: start;
  }

  .agec-tool-panel {
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    padding: 1.5rem 1.75rem;
  }

  /* Make results panel sticky */
  .agec-results-panel {
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }

  /* Keep date inputs side-by-side */
  .agec-fieldset:first-of-type .agec-field-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  /* Full width for settings fieldset */
  .agec-fieldset:last-of-type .agec-field-grid {
    grid-template-columns: 1fr;
  }
}

/* Large desktop: more compact vertical spacing */
@media (min-width: 1024px) {
  .agec-tool-panel {
    padding: 1.5rem 2rem;
  }

  .agec-fieldset {
    padding: 1.15rem 1.5rem;
  }
}

/* Reduce vertical spacing in form */
.agec-tool-panel form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.agec-tool-panel fieldset + fieldset {
  margin-top: 0;
}

/* Ensure button row stays visible */
.agec-tool-panel .agec-cta-row {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,0.95) 15%, rgba(255,255,255,1) 100%);
  padding-top: 1.25rem;
  padding-bottom: 0.75rem;
  margin-left: -1.75rem;
  margin-right: -1.75rem;
  padding-left: 1.75rem;
  padding-right: 1.75rem;
  margin-bottom: -1.5rem;
  z-index: 10;
}

@media (max-width: 767px) {
  .agec-tool-panel .agec-cta-row {
    margin-left: -1.25rem;
    margin-right: -1.25rem;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
    margin-bottom: -1rem;
  }
}

/* Smooth scrolling for overflow */
.agec-tool-panel,
.agec-results-panel {
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #c4b5fd #f5f3ff;
}

.agec-tool-panel::-webkit-scrollbar,
.agec-results-panel::-webkit-scrollbar {
  width: 6px;
}

.agec-tool-panel::-webkit-scrollbar-track,
.agec-results-panel::-webkit-scrollbar-track {
  background: #f5f3ff;
  border-radius: 3px;
}

.agec-tool-panel::-webkit-scrollbar-thumb,
.agec-results-panel::-webkit-scrollbar-thumb {
  background: #c4b5fd;
  border-radius: 3px;
}

.agec-tool-panel::-webkit-scrollbar-thumb:hover,
.agec-results-panel::-webkit-scrollbar-thumb:hover {
  background: #a78bfa;
}

/* Prevent layout shift when results appear */
.agec-results {
  min-height: 300px;
  scroll-margin-top: 100px;
}

/* Smooth page scroll */
html {
  scroll-behavior: smooth;
}

/* Prevent scroll on desktop when results render */
@media (min-width: 768px) {
  .agec-tool-core {
    scroll-snap-type: y proximity;
  }

  .agec-tool-grid > * {
    scroll-snap-align: start;
  }
}
