/* ==========================================================================
   Calculent.com - Standardized High-Performance Calculator Components Styles
   ========================================================================== */

/* Main calculator workspace frame layout */
.calculator-container {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2rem;
  align-items: start;
  margin-top: 1rem;
}

@media (max-width: 900px) {
  .calculator-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

/* Calculator input/output card borders */
.calculator-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: var(--transition);
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-body {
  padding: 1.5rem;
}

/* ==========================================================================
   Left Panel Inputs Styles (Touch Target sizes >= 44px, Inputs Font >= 16px)
   ========================================================================== */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

.label-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.label-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
}

/* Base text inputs with a minimum font size of 16px for iOS zoom prevention */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix, .input-suffix {
  position: absolute;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 600;
  pointer-events: none;
}

.input-prefix { left: 1rem; }
.input-suffix { right: 1rem; }

.form-input {
  width: 100%;
  min-height: 48px; /* Touch target >= 44px */
  padding: 0.75rem 1rem;
  font-size: 1rem; /* >= 16px to prevent iOS auto-zoom */
  font-weight: 600;
  border: 1px solid var(--border);
  background-color: var(--bg-card);
  color: var(--text-primary);
  border-radius: var(--radius);
  outline: none;
  transition: var(--transition);
}

.input-has-prefix { padding-left: 2rem; }
.input-has-suffix { padding-right: 2.25rem; }

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Custom styled modern range slider controls */
.slider-container {
  margin-top: 0.5rem;
}

input[type="range"].form-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  margin: 0.75rem 0;
  cursor: pointer;
}

/* Thumb styles */
input[type="range"].form-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg-card);
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s;
}

input[type="range"].form-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

input[type="range"].form-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg-card);
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s;
  cursor: pointer;
}

/* Modern Segmented Select toggles */
.toggle-group {
  display: flex;
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem;
  gap: 0.25rem;
}

.toggle-btn {
  flex: 1;
  border: none;
  background: none;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  transition: var(--transition);
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toggle-btn.active {
  background-color: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Base buttons */
.btn-primary {
  display: flex;
  width: 100%;
  min-height: 48px;
  background-color: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 1rem;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

/* ==========================================================================
   Right Panel Results & Graphic Views
   ========================================================================== */
.results-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.results-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.results-title {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 700;
}

.result-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.result-summary-item {
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: var(--transition);
}

.result-summary-item.highlight {
  border-color: var(--success);
  background-color: var(--success-bg);
}

.result-item-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result-item-val {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
}

.result-summary-item.highlight .result-item-val {
  color: var(--success);
}

/* Dynamic SVG graph container to prevent LCP layout shifts */
.chart-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 220px;
  width: 100%;
  max-width: 220px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.chart-svg {
  width: 100%;
  height: 100%;
  max-width: 220px;
  max-height: 220px;
  transform: rotate(-90deg);
  border-radius: 50%;
}

/* Reserved ad slot heights for layout stability */
[id$="-ads-hero"] {
  height: 90px;
}

[id$="-ads-results"] {
  height: 250px;
}

[id$="-ads-faq"] {
  height: 90px;
}

@media (max-width: 768px) {
  [id$="-ads-hero"], [id$="-ads-faq"] {
    height: 100px;
  }
  [id$="-ads-results"] {
    height: 250px;
  }
}

/* Export and share actions bar */
.results-actions {
  display: flex;
  gap: 0.75rem;
}

.btn-secondary {
  flex: 1;
  min-height: 40px;
  font-size: 0.875rem;
  font-weight: 600;
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: var(--transition);
}

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

/* ==========================================================================
   Technical SEO Educational Section Styles
   ========================================================================== */
.seo-educational-content {
  margin-top: 3.5rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  box-shadow: var(--shadow-sm);
}

.seo-educational-content h2 {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.seo-educational-content p {
  color: var(--text-secondary);
  font-size: 0.975rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.formula-block {
  margin-bottom: 2.5rem;
}

.formula-box {
  background-color: var(--bg-primary);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1.25rem 1.5rem;
  font-size: 1.15rem;
  font-family: 'Courier New', Courier, monospace;
  font-weight: 700;
  margin: 1rem 0 1.5rem;
  overflow-x: auto;
  white-space: nowrap;
}

/* Fix for informational/instruction cards using .formula-box class to prevent off-screen visual stretching */
div.formula-box[id] {
  white-space: normal !important;
  font-family: var(--font-sans) !important;
  font-weight: 500 !important;
  font-size: 0.925rem !important;
  line-height: 1.6 !important;
  border-radius: var(--radius) !important;
  border-left-width: 4px !important;
}

div.formula-box[id] h4, div.formula-box[id] h5 {
  font-family: var(--font-title) !important;
  font-weight: 700 !important;
  margin-top: 0 !important;
  margin-bottom: 0.5rem !important;
}


.example-calculation {
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.5rem;
}

/* ==========================================================================
   Responsive Tables & Detailed Schedules (CLS Prevention)
   ========================================================================== */
.table-container {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 1.5rem;
  box-shadow: var(--shadow-sm);
  background-color: var(--bg-card);
}

table.schedule-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

table.schedule-table th, table.schedule-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

table.schedule-table th {
  background-color: var(--bg-primary);
  font-weight: 600;
  color: var(--text-primary);
}

table.schedule-table tr:last-child td {
  border-bottom: none;
}

table.schedule-table tr:hover td {
  background-color: var(--bg-primary);
}

/* ==========================================================================
   FAQ Accordions Styles
   ========================================================================== */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  background-color: var(--bg-primary);
  border: none;
  outline: none;
  padding: 1rem 1.25rem;
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
}

.faq-question:hover {
  background-color: var(--border);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease-out;
  background-color: var(--bg-card);
}

.faq-answer p {
  padding: 1rem 1.25rem;
  margin: 0;
  font-size: 0.925rem;
  line-height: 1.6;
}

.faq-item.active .faq-answer {
  max-height: 500px; /* arbitrary height to slide open nicely */
}

.faq-icon-arrow {
  transition: transform 0.2s ease;
  font-weight: bold;
}

.faq-item.active .faq-icon-arrow {
  transform: rotate(90deg);
}

/* ==========================================================================
   Related Tools Panel Styles
   ========================================================================== */
.related-tools-section {
  margin-top: 3rem;
}

.related-tools-section h3 {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

.related-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.related-tool-link {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  transition: var(--transition);
}

.related-tool-link:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* ==========================================================================
   Multi-Device Visual Layout Enhancements & Mobile Adaptations
   ========================================================================== */

/* Responsive flex row for side-by-side inputs and segmented toggles */
.responsive-flex-row {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.responsive-flex-row .input-wrapper {
  flex: 1;
  min-width: 0; /* Prevents input from overflowing flex container */
}

/* Margin bottom utility matching other form groups */
.mb-3 {
  margin-bottom: 0.75rem;
}

/* Mobile responsive rules for layout spacing & wrapping */
@media (max-width: 600px) {
  /* Wrap card headers into vertical stack to prevent title overlap with currency switches */
  .card-header {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.75rem;
  }
  
  .card-header .toggle-group {
    width: 100% !important;
  }
}

@media (max-width: 480px) {
  /* Stack side-by-side inputs and toggles vertically on tiny viewports */
  .responsive-flex-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  
  /* Force side-by-side toggle groups to span full width when stacked */
  .responsive-flex-row .toggle-group {
    width: 100% !important;
  }
}
