/* 
   ACCESIBILIDAD
*/
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 
     LAYOUT PRINCIPAL
     Calculadora (izq) + Sidebar (der)
  */
.calc-layout {
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 0 3rem;
    align-items: start;
}

.calc-main {
    min-width: 0;
    /* evita overflow en grid */
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* 
     SIDEBAR
  */
.calc-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sticky-ad {
    position: static;
    top: 72px;
    align-self: center;
    /* debajo del nav sticky */
}

/* Skyscraper AdSense */
.ad-skyscraper {
    width: 160px;
    min-height: 600px;
}

/* Calculadoras relacionadas */
.related-calcs {
    background: var(--bg-soft);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.2rem;
}

.related-calcs h3 {
    font-family: var(--font-primary);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.9rem;
}

.related-calcs ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.related-calcs li a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.7rem;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-color);
    transition: all var(--transition);
}

.related-calcs li a:hover {
    background: var(--primary-color);
    color: #fff;
}

.related-calcs li a i {
    color: var(--secondary-color);
    font-size: 0.8rem;
    width: 14px;
    flex-shrink: 0;
    transition: color var(--transition);
}

.related-calcs li a:hover i {
    color: #fff;
}

/* 
     HEADER DE CALCULADORA
  */
.calc-header {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    padding: 1.5rem 0 0.5rem;
}

.calc-title-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.25);
}

.calc-header h1 {
    font-family: var(--font-primary);
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.2;
    margin-bottom: 0.2rem;
}

.calc-header p {
    color: var(--text-muted);
    font-size: 0.92rem;
}

/* 
     FORMULARIO
  */
.calc-form-section {
    position: relative;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.8rem;
    padding-top: 3rem;
    box-shadow: var(--shadow);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem 1.5rem;
    margin-bottom: 1.5rem;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.field-group label {
    font-family: var(--font-primary);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-color);
    letter-spacing: 0.02em;
}

.input-wrapper {
    display: flex;
    align-items: center;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-prefix,
.input-suffix {
    padding: 0 0.7rem;
    background: var(--bg-soft);
    color: var(--text-muted);
    font-family: var(--font-primary);
    font-size: 0.9rem;
    font-weight: 600;
    border-right: 1px solid var(--border-color);
    height: 100%;
    display: flex;
    align-items: center;
    white-space: nowrap;
    align-self: stretch;
}

.input-suffix {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

.input-wrapper input,
.input-wrapper select {
    flex: 1;
    padding: 0.6rem 0.8rem;
    border: none;
    outline: none;
    font-family: var(--font-secondary);
    font-size: 1rem;
    color: var(--text-color);
    background: transparent;
    min-width: 0;
}

/* Select personalizado */
.select-wrapper {
    position: relative;
}

.select-wrapper select {
    appearance: none;
    cursor: pointer;
    padding-right: 2rem;
}

.select-arrow {
    position: absolute;
    right: 0.7rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    pointer-events: none;
}

.field-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.3;
}

/* Botón calcular */
.btn-calc {
    width: 100%;
    padding: 0.85rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: var(--font-primary);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    transition: all var(--transition);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
    letter-spacing: 0.02em;
}

.btn-calc:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.btn-calc:active {
    transform: translateY(0);
}

/* 
     RESULTADOS
  */
.results-section {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.8rem;
    box-shadow: var(--shadow);
}

.results-section h2,
.chart-section h2,
.table-section h2,
.seo-block h2,
.faq-section h2 {
    font-family: var(--font-primary);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1.1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-color);
    display: inline-block;
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.result-card {
    background: var(--bg-soft);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.result-card.result-main {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-color: transparent;
    grid-column: 1 / -1;
}

.result-label {
    font-size: 0.78rem;
    font-family: var(--font-primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.result-main .result-label {
    color: rgba(255, 255, 255, 0.75);
}

.result-value {
    font-family: var(--font-primary);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1.1;
}

.result-main .result-value {
    color: #fff;
    font-size: 2rem;
}

.result-positive {
    color: #059669;
}

.result-neutral {
    color: var(--secondary-color);
}

.result-muted {
    color: var(--text-muted);
    font-size: 1.2rem !important;
}

/* Barra de proporción */
.proportion-bar-wrap {
    margin-top: 0.5rem;
}

.proportion-bar {
    display: flex;
    height: 10px;
    border-radius: 50px;
    overflow: hidden;
    background: var(--border-color);
    margin-bottom: 0.6rem;
}

.bar-capital {
    background: var(--secondary-color);
    transition: width 0.6s ease;
    border-radius: 50px 0 0 50px;
}

.bar-intereses {
    background: var(--accent-color);
    transition: width 0.6s ease;
    border-radius: 0 50px 50px 0;
}

.proportion-legend {
    display: flex;
    gap: 1.2rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-primary);
}

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.3rem;
    vertical-align: middle;
}

.dot-capital {
    background: var(--secondary-color);
}

.dot-intereses {
    background: var(--accent-color);
}

/* 
     GRÁFICO
  */
.chart-section {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.8rem;
    box-shadow: var(--shadow);
}

.chart-wrap {
    width: 100%;
    overflow-x: auto;
}

#chartSvg {
    display: block;
    width: 100%;
    min-width: 300px;
}

.chart-legend {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.8rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    font-family: var(--font-primary);
}

/* 
     TABLA
  */
.table-section {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.8rem;
    box-shadow: var(--shadow);
}

.table-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}

.table-header-row h2 {
    margin-bottom: 0;
}

.btn-toggle-table {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 1rem;
    border: 1.5px solid var(--secondary-color);
    border-radius: 50px;
    background: transparent;
    color: var(--secondary-color);
    font-family: var(--font-primary);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-toggle-table:hover {
    background: var(--secondary-color);
    color: #fff;
}

.table-wrapper {
    overflow-x: auto;
    margin-top: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

thead th {
    background: var(--primary-color);
    color: #fff;
    font-family: var(--font-primary);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.7rem 1rem;
    text-align: right;
}

thead th:first-child {
    text-align: left;
    border-radius: 6px 0 0 0;
}

thead th:last-child {
    border-radius: 0 6px 0 0;
}

tbody tr:nth-child(even) {
    background: var(--bg-soft);
}

tbody tr:hover {
    background: #dbeafe;
}

tbody td {
    padding: 0.6rem 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
    font-variant-numeric: tabular-nums;
}

tbody td:first-child {
    text-align: left;
    font-weight: 600;
    color: var(--primary-color);
    font-family: var(--font-primary);
    font-size: 0.82rem;
}

.td-positive {
    color: #059669;
    font-weight: 600;
}

.td-total {
    font-weight: 700;
    color: var(--primary-color);
}

/* 
     SEO BLOCK
  */
.seo-block {
    background: var(--bg-soft);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.8rem;
}

.seo-block h3 {
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 1.2rem 0 0.5rem;
}

.seo-block p {
    font-size: 0.92rem;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 0.5rem;
}

.formula-box {
    background: var(--primary-color);
    color: #fff;
    border-radius: 8px;
    padding: 1rem 1.3rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    overflow-x: auto;
    margin: 0.5rem 0;
    letter-spacing: 0.02em;
}

.formula-legend {
    list-style: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem 1.5rem;
    margin: 0.8rem 0;
    padding-left: 0.2rem;
}

.formula-legend li {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.formula-legend strong {
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
}

/* 
     FAQ
  */
.faq-section {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.8rem;
    box-shadow: var(--shadow);
}

.faq-item {
    border-bottom: 1px solid var(--border-color);
    padding: 0.2rem 0;
}

.faq-item:last-child {
    border-bottom: none;
}

.faq-item summary {
    font-family: var(--font-primary);
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-color);
    padding: 0.85rem 0.4rem;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: color var(--transition);
    user-select: none;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: '+';
    font-size: 1.2rem;
    color: var(--secondary-color);
    flex-shrink: 0;
    transition: transform var(--transition);
}

.faq-item[open] summary::after {
    transform: rotate(45deg);
}

.faq-item summary:hover {
    color: var(--secondary-color);
}

.faq-item p {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.65;
    padding: 0 0.4rem 1rem;
}

/* 
     BREADCRUMB
  */
.breadcrumb {
    padding: 0.8rem 0 0;
}

.breadcrumb ol {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    flex-wrap: wrap;
}

.breadcrumb li {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.breadcrumb li+li::before {
    content: '/';
    margin-right: 0.5rem;
    color: var(--border-color);
}

.breadcrumb a {
    color: var(--secondary-color);
    transition: color var(--transition);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.breadcrumb a:hover {
    color: var(--primary-color);
}

.breadcrumb li[aria-current="page"] {
    color: var(--text-color);
    font-weight: 600;
}

.nav-active {
    background-color: var(--primary-color) !important;
    color: #fff !important;
    border-color: var(--primary-color) !important;
}

/* 
     RESPONSIVE
  */
@media (max-width: 960px) {
    .calc-layout {
        grid-template-columns: 1fr;
    }

    .calc-sidebar {
        display: none;
        /* sidebar se oculta en móvil para no distraer */
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .result-main .result-value {
        font-size: 1.6rem;
    }
}

@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .calc-header h1 {
        font-size: 1.3rem;
    }

    .formula-legend {
        grid-template-columns: 1fr;
    }

    .table-header-row {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* BADGE Indicativo */
.badge-start-here {
    position: absolute;
    top: -13px;
    left: 1.8rem;
    margin-bottom: 0;

    display: inline-flex;
    align-items: center;
    gap: 0.50rem;
    margin-bottom: 1.2rem;
    padding: 0.35rem 0.9rem 0.35rem 0.75rem;
    background: linear-gradient(135deg, rgb(194, 4, 4), rgb(196, 12, 12));
    color: #fff;
    border: none;
    border-radius: 03px;
    font-family: var(--font-primary);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 1px 5px rgba(194, 4, 4, 0.26);
    transition: opacity 0.3s ease, transform 0.3s ease, box-shadow 0.2s ease;
}

.badge-start-here:hover {
    transform: translateY(-1px);
}

.badge-start-here i {
    font-size: 0.72rem;
    animation: badge-arrow-bounce 1.4s ease-in-out infinite;
}

@keyframes badge-arrow-bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(1.5px);
    }
}

@media (max-width: 640px) {
    .badge-start-here {
        font-size: 0.75rem;
        padding: 0.3rem 0.8rem 0.3rem 0.65rem;
    }
}