/**
 * Margin Calculator - Stylesheet
 * Exact clone matching Calculator.net financial suite
 */

/* ==========================================================================
   Page Layout & Typography
   ========================================================================== */
.margin-page-container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 14px 20px 40px;
  font-family: Arial, Helvetica, sans-serif;
  color: #333333;
}

.margin-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 10px;
}

.margin-breadcrumbs {
  font-size: 13px;
  color: #006699;
}

.margin-breadcrumbs a {
  color: #006699;
  text-decoration: none;
}

.margin-breadcrumbs a:hover {
  text-decoration: underline;
}

.margin-breadcrumbs .sep {
  margin: 0 4px;
  color: #666;
}

.margin-breadcrumbs .current {
  color: #006699;
  font-weight: normal;
}

.margin-top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.margin-top-btn {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  color: #334155;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.margin-top-btn:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #0f172a;
}

.margin-top-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.margin-badge {
  background: #0844a4;
  color: #ffffff;
  font-size: 10px;
  font-weight: bold;
  padding: 1px 5px;
  border-radius: 10px;
  margin-left: 3px;
}

.margin-page-title {
  font-size: 26px;
  font-weight: bold;
  color: #0844a4;
  margin: 0 0 10px 0;
}

/* ==========================================================================
   Instruction Banner
   ========================================================================== */
.margin-banner {
  background-color: #336699;
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 2px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.margin-banner-icon {
  background: #ffffff;
  color: #336699;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  flex-shrink: 0;
}

/* ==========================================================================
   Main Grid Layout (Left Content + Right Sidebar)
   ========================================================================== */
.margin-layout-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 30px;
  align-items: start;
}

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

.margin-main-content {
  min-width: 0;
}

/* ==========================================================================
   Calculator Section Cards
   ========================================================================== */
.calc-card {
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid #e2e8f0;
}

.calc-card:last-of-type {
  border-bottom: none;
}

.calc-card-title {
  font-size: 20px;
  font-weight: bold;
  color: #0844a4;
  margin: 0 0 8px 0;
}

.calc-card-desc {
  font-size: 13.5px;
  color: #333333;
  line-height: 1.5;
  margin: 0 0 16px 0;
}

/* Calculator Inner Columns: Form Box + Result Box */
.calc-inner-columns {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.calc-form-box {
  background: #f4f6f9;
  border: 1px solid #d0d7de;
  border-radius: 3px;
  padding: 12px 14px;
  width: 270px;
  flex-shrink: 0;
}

.calc-table-form {
  width: 100%;
  border-collapse: collapse;
}

.calc-table-form tr {
  margin-bottom: 6px;
}

.calc-table-form td {
  padding: 4px 2px;
  vertical-align: middle;
  font-size: 13px;
  color: #333333;
}

.calc-table-form td.label-col {
  width: 42%;
  font-weight: normal;
  text-align: right;
  padding-right: 8px;
}

.calc-input-wrapper {
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid #7f9db9;
  border-radius: 1px;
  padding: 0 4px;
}

.calc-input-wrapper:focus-within {
  border-color: #0844a4;
  outline: 1px solid #0844a4;
}

.calc-prefix,
.calc-suffix {
  font-size: 13px;
  color: #555555;
  user-select: none;
}

.calc-prefix {
  margin-right: 2px;
}

.calc-suffix {
  margin-left: 2px;
}

.calc-input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 4px 2px;
  font-size: 13px;
  font-family: inherit;
  color: #111111;
  outline: none;
}

.calc-select {
  width: 100%;
  border: 1px solid #7f9db9;
  background: #ffffff;
  padding: 4px 2px;
  font-size: 13px;
  font-family: inherit;
  color: #111111;
  border-radius: 1px;
}

.calc-select:focus {
  border-color: #0844a4;
  outline: 1px solid #0844a4;
}

.calc-button-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 6px;
}

.btn-calculate {
  background: #2e7d32;
  color: #ffffff;
  border: 1px solid #1b5e20;
  padding: 5px 16px;
  font-size: 13px;
  font-weight: bold;
  border-radius: 3px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease;
}

.btn-calculate:hover {
  background: #1b5e20;
}

.btn-calculate .play-icon {
  display: inline-block;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid #ffffff;
}

.btn-clear {
  background: #94a3b8;
  color: #ffffff;
  border: 1px solid #64748b;
  padding: 5px 14px;
  font-size: 13px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-clear:hover {
  background: #64748b;
}

/* Result Box */
.calc-result-box {
  flex: 1;
  min-width: 260px;
  border: 1px solid #4f7942;
  border-radius: 3px;
  overflow: hidden;
  background: #ffffff;
}

.calc-result-header {
  background: #4f7942;
  color: #ffffff;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.save-action-icon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: normal;
  cursor: pointer;
  color: #ffffff;
  opacity: 0.9;
  transition: opacity 0.15s ease;
  background: transparent;
  border: none;
  padding: 0;
}

.save-action-icon:hover {
  opacity: 1;
  text-decoration: underline;
}

.save-action-icon svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.calc-result-body {
  padding: 14px 16px;
}

.result-metric-row {
  margin-bottom: 8px;
  font-size: 13.5px;
  line-height: 1.4;
}

.result-metric-row.primary {
  font-size: 15px;
  font-weight: bold;
  color: #111111;
  margin-bottom: 6px;
}

.result-highlight-green {
  font-size: 16px;
  font-weight: bold;
  color: #2e7d32;
}

/* Donut Chart Styling */
.donut-chart-container {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #d0d7de;
}

.donut-svg-wrapper {
  position: relative;
  width: 100px;
  height: 100px;
  flex-shrink: 0;
}

.donut-chart-legend {
  font-size: 12.5px;
  color: #333333;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.legend-color-box {
  width: 12px;
  height: 12px;
  display: inline-block;
  border-radius: 1px;
}

.legend-color-box.cost {
  background-color: #2b74b9;
}

.legend-color-box.margin {
  background-color: #84bd00;
}

/* Explanatory Definitions List below Form */
.calc-definitions-list {
  font-size: 13px;
  color: #333333;
  line-height: 1.6;
  margin-top: 8px;
}

.calc-definitions-list p {
  margin: 3px 0;
}

.calc-definitions-list strong {
  color: #111111;
}

/* ==========================================================================
   Fraction Arithmetic & Ratio Solver Section
   ========================================================================== */
.fraction-solver-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 16px 20px;
  margin-top: 24px;
}

.fraction-solver-title {
  font-size: 18px;
  font-weight: bold;
  color: #0844a4;
  margin: 0 0 6px 0;
}

.fraction-solver-sub {
  font-size: 13px;
  color: #64748b;
  margin: 0 0 16px 0;
}

.fraction-arithmetic-grid {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.fraction-unit {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  width: 70px;
}

.fraction-input {
  width: 100%;
  text-align: center;
  font-size: 14px;
  padding: 4px;
  border: 1px solid #7f9db9;
  border-radius: 2px;
  background: #ffffff;
}

.fraction-bar {
  width: 100%;
  height: 2px;
  background: #334155;
  margin: 3px 0;
}

.fraction-op-select {
  padding: 6px 8px;
  font-size: 15px;
  font-weight: bold;
  border: 1px solid #7f9db9;
  border-radius: 2px;
  background: #ffffff;
}

.fraction-eq-sign {
  font-size: 18px;
  font-weight: bold;
  color: #334155;
}

.fraction-result-display {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: #e2e8f0;
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: bold;
  font-size: 15px;
  color: #0f172a;
}

.fraction-result-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.fraction-result-frac .num {
  border-bottom: 2px solid #0f172a;
  padding-bottom: 2px;
  width: 100%;
  text-align: center;
}

.fraction-result-frac .den {
  padding-top: 2px;
  text-align: center;
}

.fraction-result-dec {
  font-size: 13.5px;
  color: #2563eb;
}

/* Margin Proportion Visual Track */
.margin-proportion-track {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #cbd5e1;
}

.proportion-bar-wrapper {
  height: 20px;
  width: 100%;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  margin: 6px 0 4px 0;
}

.proportion-fill-cost {
  background: #2b74b9;
  color: #ffffff;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  white-space: nowrap;
}

.proportion-fill-profit {
  background: #84bd00;
  color: #ffffff;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  white-space: nowrap;
}

/* ==========================================================================
   Right Sidebar
   ========================================================================== */
.margin-sidebar {
  width: 100%;
}

.sidebar-search-box {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}

.sidebar-search-input {
  flex: 1;
  border: 1px solid #7f9db9;
  padding: 5px 8px;
  font-size: 13px;
  outline: none;
}

.sidebar-search-input:focus {
  border-color: #0844a4;
}

.sidebar-search-btn {
  background: #336699;
  color: #ffffff;
  border: 1px solid #204d74;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.15s ease;
}

.sidebar-search-btn:hover {
  background: #204d74;
}

.sidebar-dropdown-results {
  position: absolute;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border-radius: 3px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
  width: 280px;
  display: none;
}

.sidebar-card {
  border: 1px solid #b0c4de;
  border-radius: 2px;
  background: #ffffff;
  overflow: hidden;
  margin-bottom: 20px;
}

.sidebar-card-header {
  background: #336699;
  color: #ffffff;
  padding: 7px 12px;
  font-size: 14px;
  font-weight: bold;
}

.sidebar-links-grid {
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
  font-size: 12.5px;
}

.sidebar-links-grid a {
  color: #006699;
  text-decoration: none;
}

.sidebar-links-grid a:hover {
  text-decoration: underline;
}

.sidebar-more-link {
  grid-column: 1 / -1;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed #e2e8f0;
}

.sidebar-footer-nav {
  padding: 8px 12px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  font-size: 12px;
  color: #64748b;
  text-align: center;
}

.sidebar-footer-nav a {
  color: #006699;
  text-decoration: none;
  margin: 0 4px;
}

.sidebar-footer-nav a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Educational, AEO, and GEO Content Section
   ========================================================================== */
.margin-edu-section {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid #e2e8f0;
  color: #334155;
  line-height: 1.65;
  font-size: 13.5px;
}

.margin-edu-section h2 {
  font-size: 20px;
  font-weight: bold;
  color: #0844a4;
  margin: 0 0 12px 0;
}

.margin-edu-section h3 {
  font-size: 16px;
  font-weight: bold;
  color: #1e293b;
  margin: 20px 0 8px 0;
}

.margin-edu-section p {
  margin: 0 0 12px 0;
}

.margin-edu-section ul {
  margin: 0 0 14px 20px;
  padding: 0;
}

.margin-edu-section li {
  margin-bottom: 6px;
}

.edu-formula-box {
  background: #f1f5f9;
  border-left: 4px solid #0844a4;
  padding: 10px 16px;
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
  margin: 12px 0;
  border-radius: 0 4px 4px 0;
  color: #0f172a;
}

/* AEO FAQ Accordion / Cards */
.aeo-faq-container {
  display: grid;
  gap: 12px;
  margin: 16px 0 24px;
}

.aeo-faq-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 12px 16px;
}

.aeo-faq-question {
  font-weight: bold;
  color: #0844a4;
  font-size: 14px;
  margin: 0 0 6px 0;
}

.aeo-faq-answer {
  margin: 0;
  font-size: 13px;
  color: #334155;
}

/* ==========================================================================
   Modals (Instant Tool, Saved Scenarios, Print Report)
   ========================================================================== */
.margin-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.margin-modal-box {
  background: #ffffff;
  border-radius: 4px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.margin-modal-header {
  background: #255784;
  color: #ffffff;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
  font-size: 15px;
}

.margin-modal-close {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.margin-modal-body {
  padding: 16px 20px;
  font-size: 13.5px;
  color: #333333;
}

.instant-input-group {
  margin-bottom: 14px;
}

.instant-input-label {
  display: block;
  font-weight: bold;
  font-size: 13px;
  color: #334155;
  margin-bottom: 4px;
}

.instant-input-field {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #7f9db9;
  border-radius: 3px;
  font-size: 14px;
  outline: none;
}

.instant-input-field:focus {
  border-color: #0844a4;
}

.btn-instant-compute {
  background: #255784;
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: 3px;
  font-size: 13.5px;
  font-weight: bold;
  cursor: pointer;
  margin-top: 6px;
  transition: background 0.15s ease;
}

.btn-instant-compute:hover {
  background: #1b3e5f;
}

.instant-results-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 4px;
  padding: 12px;
  margin-top: 14px;
  display: none;
}

/* ==========================================================================
   Print Stylesheet (@media print)
   ========================================================================== */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .margin-top-actions,
  .margin-banner,
  .margin-sidebar,
  .calc-button-row,
  .fraction-solver-box,
  .margin-modal-backdrop,
  header,
  footer,
  #lang-selector-container {
    display: none !important;
  }

  .margin-layout-grid {
    display: block !important;
  }

  .margin-page-container {
    max-width: 100% !important;
    padding: 0 !important;
  }

  .calc-card {
    page-break-inside: avoid;
    border-bottom: 1px solid #cccccc !important;
    margin-bottom: 20px !important;
  }

  .calc-inner-columns {
    display: flex !important;
  }

  .calc-form-box {
    border: 1px solid #000000 !important;
    background: #ffffff !important;
  }

  .calc-result-box {
    border: 1px solid #000000 !important;
  }

  .calc-result-header {
    background: #333333 !important;
    color: #ffffff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
