/* Container & layout */

.lyfery-calc {
    border-radius: 24px;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    padding: 24px;
    margin: 24px 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
}

.lyfery-calc-inner {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.lyfery-calc-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.lyfery-tab {
    border-radius: 999px;
    border: 1px solid #ff4b8c;
    padding: 6px 22px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    color: #ff4b8c;
}

.lyfery-tab-active {
    background: #ff4b8c;
    border-color: #ff4b8c;
    color: #fff;
}

.lyfery-calc-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
}

.lyfery-calc-left,
.lyfery-calc-right {
    flex: 1 1 280px;
}

/* Field groups & sliders */

.lyfery-field-group {
    margin-bottom: 18px;
}

.lyfery-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    margin-bottom: 6px;
}

/* Info / tooltip icon */

.lyfery-info {
    border: none;
    padding: 0;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    background: #f3e4ff;
    color: #a60c6e;
}

/* Styled slider similar to original calc */

.lyfery-slider input[type="range"].lyfery-range {
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
  height: 32px;
}

/* progress support */
.lyfery-slider input[type="range"].lyfery-range.slider-progress {
  --min: 0;
  --max: 100;
  --value: 0;
  --range: calc(var(--max) - var(--min));
  --ratio: calc((var(--value) - var(--min)) / var(--range));
  --sx: calc(0.5 * 1.6em + var(--ratio) * (100% - 1.6em));
}

.lyfery-slider input[type="range"].lyfery-range:focus {
  outline: none;
}

/* webkit */
.lyfery-slider input[type="range"].lyfery-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 30px;
  height: 30px;
  border-radius: 15px;
  background: #005724;
  margin-top: -5px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
  border: 2px solid #ffffff;
  cursor: pointer;
}

.lyfery-slider input[type="range"].lyfery-range::-webkit-slider-runnable-track {
  width: 100%;
  height: 24px;
  border-radius: 999px;
  border: 1px solid #e0e4d8;
  background: #f5f8ef;
}

.lyfery-slider input[type="range"].lyfery-range.slider-progress::-webkit-slider-runnable-track {
  background: linear-gradient(to right, #6AE9A2, #6AE9A2) 0/var(--sx) 100% no-repeat, #F5F8EF;
}

/* firefox */
.lyfery-slider input[type="range"].lyfery-range::-moz-range-thumb {
  width: 30px;
  height: 30px;
  border-radius: 15px;
  background: #005724;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
  cursor: pointer;
}

.lyfery-slider input[type="range"].lyfery-range::-moz-range-track {
  width: 100%;
  height: 24px;
  border-radius: 999px;
  border: 1px solid #e0e4d8;
  background: #f5f8ef;
}

.lyfery-slider input[type="range"].lyfery-range.slider-progress::-moz-range-track {
  background: linear-gradient(to right, #6AE9A2, #6AE9A2) 0/var(--sx) 100% no-repeat, #F5F8EF;
}

/* slider labels */

.lyfery-slider-values {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-top: 4px;
    color: #777;
}

.lyfery-output {
    font-weight: 600;
}

/* Monthly summary & donut */

.lyfery-summary {
    border-radius: 18px;
    background: #f8faf7;
    padding: 16px;
    margin-bottom: 16px;
}

.lyfery-summary h3 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 18px;
}

.lyfery-donut {
    position: relative;
    width: 260px;
    height: 260px;
    margin: 8px auto 12px;
}

.lyfery-donut-svg {
    width: 100%;
    height: 100%;
}

.donut-track,
.donut-life,
.donut-disability,
.donut-critical,
.donut-dividends {
    fill: none;
    stroke-width: 20;
    stroke-linecap: round;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}

.donut-track {
    stroke: #f5f8ef;
}
.donut-life {
    stroke: #005724;
}
.donut-disability {
    stroke: #ff843b;
}
.donut-critical {
    stroke: #059142;
}
.donut-dividends {
    stroke: url(#lyfery-diagonal);
}

/* center content */

.lyfery-donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.lyfery-total-amount {
    font-size: 26px;
    font-weight: 700;
}

.lyfery-total-label {
    font-size: 13px;
    color: #555;
}

/* breakdown list */

.lyfery-breakdown {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 14px;
}

.lyfery-breakdown li {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px dashed #e3e3e3;
}

.lyfery-breakdown li:last-child {
    border-bottom: none;
}

/* CTA button */

.lyfery-cta-wrap {
    margin-top: 14px;
    text-align: center;
}

.lyfery-cta-wrap-comparison {
    margin-top: 20px;
    margin-bottom: 25px;
}

.lyfery-compare-disclaimer{
    margin-top: 14px;
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.35;
    opacity: 0.8;
    text-align: center;
}


.lyfery-cta {
    display: inline-block;
    padding: 10px 28px;
    border-radius: 999px;
    background: #ff7200;
    color: #fff !important;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}

/* comparison */

.lyfery-summary-comparison .lyfery-comparison-grid {
    display: flex;
    gap: 8px;
    margin: 12px 0;
}

.lyfery-comp-col {
    flex: 1 1 auto;
    padding: 8px;
    text-align: center;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.lyfery-comp-label {
    font-size: 13px;
    color: #666;
}

.lyfery-comp-value {
    font-size: 16px;
    font-weight: 600;
    margin-top: 4px;
}

.lyfery-comparison-wins {
    font-size: 13px;
    margin-bottom: 8px;
}

.lyfery-comparison-chart {
    height: 220px;
}

.lyfery-comparison-chart canvas {
    width: 100% !important;
    height: 220px !important;
}

/* Views visibility */

.lyfery-view {
    display: none;
}
.lyfery-view-monthly {
    display: block;
}
.lyfery-summary-comparison {
    display: none;
}

.lyfery-calc[data-mode="comparison"] .lyfery-view-monthly {
    display: none;
}
.lyfery-calc[data-mode="comparison"] .lyfery-view-comparison {
    display: block;
}
.lyfery-calc[data-mode="comparison"] .lyfery-summary-monthly {
    display: none;
}
.lyfery-calc[data-mode="comparison"] .lyfery-summary-comparison {
    display: block;
}

.lyfery-calc[data-mode="monthly"] .lyfery-view-monthly {
    display: block;
}
.lyfery-calc[data-mode="monthly"] .lyfery-view-comparison {
    display: none;
}
.lyfery-calc[data-mode="monthly"] .lyfery-summary-monthly {
    display: block;
}
.lyfery-calc[data-mode="monthly"] .lyfery-summary-comparison {
    display: none;
}

/* Both mode; JS toggles active view */

.lyfery-calc[data-mode="both"] .lyfery-view-monthly,
.lyfery-calc[data-mode="both"] .lyfery-view-comparison,
.lyfery-calc[data-mode="both"] .lyfery-summary-monthly,
.lyfery-calc[data-mode="both"] .lyfery-summary-comparison {
    display: none;
}

/* Modal */

.lyfery-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.lyfery-modal.is-open {
    display: flex;
}

.lyfery-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
}

.lyfery-modal-dialog {
    position: relative;
    background: #fff;
    border-radius: 16px;
    max-width: 520px;
    width: 90%;
    padding: 18px 22px 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    z-index: 1;
}

.lyfery-modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    border: none;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
}

.lyfery-modal-content {
    font-size: 14px;
    margin-top: 10px;
}

/* Responsive */

@media (max-width: 768px) {
    .lyfery-calc {
        padding: 16px;
    }
    .lyfery-donut {
        width: 220px;
        height: 220px;
    }
}


/* Breakdown color squares */
.lyfery-breakdown-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.lyf-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
    flex-shrink: 0;
}

.lyf-dot-life { background: #005724; }
.lyf-dot-disability { background: #ff843b; }
.lyf-dot-critical { background: #059142; }

.lyf-dot-dividend {
    background-color: #dae861;
    background-image: repeating-linear-gradient(45deg,#dae861 0,#dae861 2px,#6ae9a2 2px,#6ae9a2 4px);
}


/* Schedule (Näidis maksegraafik) */
.lyfery-summary-schedule { display:none; }
.lyfery-schedule-chart { margin-top: 14px; height: 360px; }
.lyfery-schedule-chart canvas { width: 100% !important; height: 360px !important; }

.lyfery-schedule-divsum { font-weight: 700; margin-top: 8px; }

.lyfery-table-scroll { overflow:auto; margin-top: 14px; border-radius: 14px; border: 1px solid rgba(0,0,0,0.06); }
.lyfery-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.lyfery-table th, .lyfery-table td { padding: 10px 12px; border-bottom: 1px solid rgba(0,0,0,0.06); text-align: right; white-space: nowrap; }
.lyfery-table th:first-child, .lyfery-table td:first-child { text-align: left; }
.lyfery-table thead th { background: rgba(0,0,0,0.03); font-weight: 700; }
.lyfery-table tbody tr:hover { background: rgba(0,0,0,0.02); }
.lyfery-table td.lyfery-td-bold { font-weight: 700; }


/* Schedule view should be full width */
.lyfery-view-schedule,
.lyfery-summary-schedule {
    grid-column: 1 / -1;
    width: 100%;
}

/* Ensure schedule chart is visible */
.lyfery-schedule-chart {
    width: 100%;
    height: 420px;
}
.lyfery-schedule-chart canvas {
    width: 100% !important;
    height: 420px !important;
    display: block;
}


/* Schedule tab: full-width layout (no left sliders column) */
.lyfery-calc.is-schedule .lyfery-calc-left { display: none !important; }
.lyfery-calc.is-schedule .lyfery-calc-right { flex: 1 1 100% !important; width: 100% !important; }
.lyfery-calc.is-schedule .lyfery-summary-schedule { display: block; }

.lyfery-summary-schedule .chartjs-legend, .lyfery-summary-schedule canvas { max-width: 100%; }


/* Hook class for Näidis maksegraafik tab */
.lyfery-calc.lyfery-schedule-active {}

/* Force true full-width when schedule is active */
.lyfery-calc.lyfery-schedule-active .lyfery-calc-layout { display: block !important; }
.lyfery-calc.lyfery-schedule-active .lyfery-calc-right { width: 100% !important; max-width: 100% !important; }
.lyfery-calc.lyfery-schedule-active .lyfery-summary-schedule { width: 100% !important; max-width: 100% !important; }
.lyfery-calc.lyfery-schedule-active .lyfery-schedule-table-wrap { width: 100% !important; }

.lyfery-schedule-extra-legend{
  display:flex;
  justify-content:center;
  gap:18px;
  margin-top:10px;
  color:#666;
  font-size:14px;
}
.lyfery-schedule-extra-legend .lyf-leg-item{display:inline-flex; align-items:center; gap:8px;}
.lyfery-schedule-extra-legend .lyf-leg-swatch{width:46px; height:14px; border-radius:4px; display:inline-block;}


/* Legend styling */
.lyfery-schedule-legend{
    display:flex;
    flex-wrap:wrap;
    gap:16px;
    margin-top:20px;
}
.lyf-legend-item{
    display:flex;
    align-items:center;
    gap:8px;
    font-size:14px;
}
.lyf-legend-swatch{
    width:14px;
    height:14px;
    border-radius:2px; /* square */
    display:inline-block;
}
.lyf-legend-swatch-dividend{
    background:
      repeating-linear-gradient(
        45deg,
        rgba(106,233,162,0.8),
        rgba(106,233,162,0.8) 4px,
        rgba(218,232,97,0.4) 4px,
        rgba(218,232,97,0.4) 8px
      );
    border:1px solid rgba(106,233,162,0.9);
}


/* Comparison chart expand button */
.lyfery-comparison-chart{ position:relative; }
.lyfery-chart-expand{
    position:absolute;
    top:10px;
    right:10px;
    width:34px;
    height:34px;
    border-radius:999px;
    border:1px solid rgba(0,0,0,0.08);
    background:#fff;
    cursor:pointer;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:18px;
    line-height:1;
    box-shadow:0 6px 18px rgba(0,0,0,0.08);
}
.lyfery-chart-expand:hover{ transform:translateY(-1px); }
.lyfery-chart-expand:active{ transform:translateY(0); }

/* Modal */
.lyfery-modal{
    display:none;
    position:fixed;
    inset:0;
    z-index:99999;
}
.lyfery-modal.lyfery-modal-open{ display:block; }
.lyfery-modal-backdrop{
    position:absolute;
    inset:0;
    background:rgba(0,0,0,0.55);
}
.lyfery-modal-panel{
    position:relative;
    width:min(1100px, calc(100% - 24px));
    margin:12px auto;
    background:#fff;
    border-radius:18px;
    box-shadow:0 30px 80px rgba(0,0,0,0.35);
    overflow:hidden;
}
.lyfery-modal-body{ padding:18px 18px 8px; }
.lyfery-modal-title{ margin:0 0 10px; font-size:18px; }
.lyfery-modal-chart{
    height:calc(100vh - 180px);
    min-height:420px;
}
.lyfery-modal-close{
    position:absolute;
    top:10px;
    right:10px;
    width:38px;
    height:38px;
    border-radius:999px;
    border:1px solid rgba(0,0,0,0.08);
    background:#fff;
    cursor:pointer;
    font-size:26px;
    line-height:1;
    display:flex;
    align-items:center;
    justify-content:center;
}
body.lyfery-modal-open-body{ overflow:hidden; }


/* Ensure expand button is clickable above canvas */
.lyfery-comparison-chart{ position:relative; }
.lyfery-comparison-chart canvas{ position:relative; z-index:1; }
.lyfery-chart-expand{ z-index:50; pointer-events:auto; }


.lyfery-calc.lyfery-compare-expanded .lyfery-view-comparison .lyfery-comparison-chart canvas{
  width: 100% !important;
  height: 100% !important;
}
.lyfery-calc.lyfery-compare-expanded .lyfery-view-comparison{
  align-items: stretch;
}


/* Comparison chart expand (full-width within calc) */
.lyfery-view-comparison .lyfery-comparison-chart{
  position: relative;
  height: 260px;
  transition: height 220ms ease;
}
.lyfery-calc.lyfery-compare-expanded .lyfery-view-comparison .lyfery-comparison-chart{
  height: min(70vh, 720px);
}
.lyfery-calc.lyfery-compare-expanded .lyfery-view-comparison .lyfery-comparison-chart canvas{
  width: 100% !important;
  height: 100% !important;
}


/* Comparison chart FULL expand (cover calculator container) */
.lyfery-calc.lyfery-compare-full .lyfery-calc-left{
  display:none !important;
  width:0 !important;
  flex:0 0 0 !important;
}
.lyfery-calc.lyfery-compare-full .lyfery-calc-right{
  width:100% !important;
  max-width:100% !important;
  flex:1 1 100% !important;
}
.lyfery-calc.lyfery-compare-full .lyfery-view-comparison .lyfery-comparison-chart{
  height:min(70vh, 720px) !important;
}
.lyfery-calc.lyfery-compare-full .lyfery-view-comparison .lyfery-comparison-chart canvas{
  width:100% !important;
  height:100% !important;
}

.lyfery-comparison-chart{ position:relative; }
.lyfery-comparison-chart canvas{ position:relative; z-index:1; }
.lyfery-chart-expand{ position:absolute; top:10px; right:10px; z-index:50; }

/* Comparison view: CI slider does not participate */
.lyfery-view-comparison input.lyfery-range[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}
.lyfery-note.lyfery-note-muted {
  font-size: 12px;
  opacity: 0.75;
  margin-top: -6px;
  margin-bottom: 8px;
}

/* Disclaimer icons */
.lyfery-info-disclaimer i {
  font-size: 18px;
}


/* Comparison legend (outside chart) */
.lyfery-compare-legend{
  display:flex;
  flex-wrap:wrap;
  gap:14px 18px;
  margin: 8px 0 12px;
}
.lyfery-compare-legend .lyfery-legend-item{
  flex: 1 1 calc(33.333% - 18px);
  min-width: 210px;
  display:flex;
  align-items:flex-start;
  gap:10px;
}
.lyfery-compare-legend .lyfery-legend-swatch{
  width:14px;
  height:14px;
  border-radius: 2px;
  flex: 0 0 14px;
  margin-top:3px;
}
.lyfery-compare-legend .lyfery-legend-text{
  line-height:1.2;
  font-weight:600;
  font-size:14px;
  color:#0b1a10;
  word-break: break-word;
}
@media (max-width: 991px){
  .lyfery-compare-legend .lyfery-legend-item{
    flex: 1 1 calc(50% - 18px);
    min-width: 180px;
  }
}
@media (max-width: 520px){
  .lyfery-compare-legend .lyfery-legend-item{
    flex: 1 1 100%;
    min-width: 0;
  }
}