/* ============================================================
   CalculaRD — Hoja de estilos compartida para todo el sitio
   ============================================================ */

:root {
    --primary: #0A2540;
    --accent: #00D4FF;
    --success: #00C851;
    --error: #ff4444;
    --bg-light: #F0F4F8;
    --text-dark: #1A1F36;
    --text-light: #4F566B;
    --white: #FFFFFF;
    --shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.1);
    --card-radius: 16px;
    --input-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --primary-glow: 0 0 15px rgba(0, 212, 255, 0.3);
}

/* --- Animations --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.fade-in-up { animation: fadeInUp 0.6s ease-out forwards; }
.float-anim { animation: float 3s ease-in-out infinite; }

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100vw;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    padding-bottom: 40px;
}

img,
canvas {
    max-width: 100%;
}

table {
    max-width: 100%;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Typography & Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

h1,
h2,
h3 {
    color: var(--primary);
    font-weight: 700;
}

.text-center {
    text-align: center;
}

.text-sm {
    font-size: 0.85rem;
    color: var(--text-light);
}

.flex {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}

/* ============================================================
   SITE HEADER & NAVIGATION (compartido)
   ============================================================ */
.site-header {
    background: linear-gradient(135deg, var(--primary), #1a3b5c);
    color: var(--white);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(10, 37, 64, 0.25);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.9rem 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.nav-logo {
    color: var(--white);
    font-size: 1.5rem;
    font-weight: 800;
    text-decoration: none;
    letter-spacing: -0.5px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.nav-logo span { color: var(--accent); }

.nav-menu {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    list-style: none;
    flex-wrap: wrap;
}

.nav-menu a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 8px;
    transition: var(--transition);
    white-space: nowrap;
}

.nav-menu a:hover,
.nav-menu a.active {
    color: var(--white);
    background: rgba(255, 255, 255, 0.12);
}

/* Mobile nav toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.6rem;
    cursor: pointer;
}

@media (max-width: 900px) {
    .nav-toggle { display: block; }
    .nav-menu {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
        padding-top: 0.5rem;
    }
    .nav-menu.open { display: flex; }
    .nav-menu a { padding: 10px 12px; }
}

/* Page hero (compact, on top of calculator/article pages) */
.page-hero {
    background: linear-gradient(135deg, var(--primary), #1a3b5c);
    color: var(--white);
    padding: 2.5rem 0;
    text-align: center;
    margin-bottom: 2rem;
}

.page-hero h1 {
    color: var(--white);
    font-size: 2rem;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.page-hero p {
    opacity: 0.85;
    font-size: 1.05rem;
    max-width: 700px;
    margin: 0 auto;
}

/* ============================================================
   HOME HERO (big gradient hero on index)
   ============================================================ */
.home-hero {
    text-align: center;
    background: linear-gradient(-45deg, #0A2540, #1a3b5c, #00D4FF, #0A2540);
    background-size: 400% 400%;
    animation: gradientShift 10s ease infinite;
    color: #fff;
    padding: 5rem 2rem;
    border-radius: var(--card-radius);
    margin-bottom: 3rem;
    box-shadow: var(--shadow);
}

/* Cards & Forms */
.card {
    background: var(--white);
    border-radius: var(--card-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
    border: 1px solid rgba(0,0,0,0.03);
    position: relative;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.15);
    border-color: var(--accent);
}

.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 2px solid #E6EBF1;
    border-radius: var(--input-radius);
    font-size: 1rem;
    transition: var(--transition);
    background: #FAFBFC;
    color: var(--text-dark);
    font-weight: 500;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--white);
    box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.15);
}

.form-control.error {
    border-color: var(--error);
    box-shadow: 0 0 0 4px rgba(255, 68, 68, 0.1);
}

.error-msg {
    color: var(--error);
    font-size: 0.8rem;
    margin-top: 4px;
    display: none;
    font-weight: 500;
}

/* Results Section */
.result-highlight {
    background: linear-gradient(135deg, #0A2540, #0f3457);
    color: var(--white);
    text-align: center;
    padding: 2.5rem;
    border-radius: var(--card-radius);
    margin-bottom: 2rem;
    box-shadow: 0 10px 30px rgba(10, 37, 64, 0.25);
    position: relative;
}

.result-highlight::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(0, 212, 255, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.monthly-payment {
    font-size: 3rem;
    font-weight: 800;
    margin: 0.5rem 0 1.5rem 0;
    background: linear-gradient(to right, #fff, #00D4FF);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.result-item {
    background: rgba(255, 255, 255, 0.08);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: var(--transition);
}

.result-item:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
}

.result-item span {
    display: block;
    font-size: 0.85rem;
    opacity: 0.7;
    margin-bottom: 4px;
}

.result-item strong {
    font-size: 1.2rem;
    margin-bottom: 0;
    display: block;
}

/* Tables & Charts */
.table-container {
    overflow-x: auto;
    max-height: 400px;
    margin-top: 1.5rem;
    border-radius: 8px;
    border: 1px solid #E6EBF1;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th,
td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid #E6EBF1;
}

th {
    background-color: #FAFBFC;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    color: var(--text-light);
}

tr:hover {
    background-color: #F8FAFC;
}

td {
    font-variant-numeric: tabular-nums;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.9rem 2rem;
    border: none;
    border-radius: var(--input-radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    font-size: 1rem;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #00b8e6);
    color: var(--primary);
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 212, 255, 0.4);
}

.btn-outline {
    background: transparent;
    border: 2px solid #E6EBF1;
    color: var(--text-light);
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #FAFBFC;
}

/* Helper Classes */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Comparative Box */
.comparator-wrap {
    background: #FFF8E1;
    border: 1px solid #FFE082;
    padding: 1.5rem;
    border-radius: 12px;
    margin-top: 1.5rem;
    border-left: 6px solid #FFC107;
}

/* ===== EXPENSE CALCULATOR ===== */
.expense-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.75rem;
    animation: fadeIn 0.3s ease;
}

.expense-row input {
    padding: 0.75rem 1rem;
    border: 2px solid #E6EBF1;
    border-radius: var(--input-radius);
    font-size: 0.95rem;
    font-family: 'Outfit', sans-serif;
    background: #FAFBFC;
    color: var(--text-dark);
    transition: var(--transition);
    width: 100%;
}

.expense-row input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--white);
    box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.15);
}

.btn-remove {
    background: #FFE9E9;
    color: #ff4444;
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-remove:hover {
    background: #ff4444;
    color: #fff;
    transform: scale(1.1);
}

.expense-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.expense-summary-card {
    background: linear-gradient(135deg, #0A2540, #0f3457);
    color: #fff;
    border-radius: 14px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 6px 20px rgba(10, 37, 64, 0.18);
    transition: var(--transition);
}

.expense-summary-card:hover {
    transform: translateY(-4px);
}

.expense-summary-card .label {
    font-size: 0.8rem;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.expense-summary-card .amount {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #fff, #00D4FF);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.expense-total-banner {
    background: linear-gradient(135deg, #00C851, #00a844);
    color: #fff;
    border-radius: 14px;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    font-weight: 600;
    font-size: 1.1rem;
}

.expense-total-banner span:last-child {
    font-size: 1.6rem;
    font-weight: 800;
}

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 1.2rem 0;
    color: var(--text-light);
    font-size: 0.85rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #E6EBF1;
}

/* Dynamic Info Section Styles */
.info-container {
    margin-top: 4rem;
    border-top: 1px solid #E6EBF1;
    padding-top: 3rem;
}

.info-block {
    animation: fadeIn 0.4s ease-out;
}

.info-card {
    background: #fff;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    margin-bottom: 2rem;
    border: 1px solid #E6EBF1;
}

.info-card h2 { font-size: 1.8rem; margin-bottom: 1.5rem; color: var(--primary); }
.info-card h3 { font-size: 1.3rem; margin-top: 1.5rem; margin-bottom: 1rem; color: var(--primary); }
.info-card h4 { font-size: 1.1rem; margin-top: 1.2rem; margin-bottom: 0.8rem; color: var(--text-dark); }

.info-card p { color: var(--text-light); margin-bottom: 1rem; font-size: 1rem; line-height: 1.7; }
.info-card ul { margin-left: 1.5rem; margin-bottom: 1.5rem; color: var(--text-light); }
.info-card li { margin-bottom: 0.5rem; }

.info-table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; background: #fafbfc; border-radius: 12px; overflow: hidden; }
.info-table th, .info-table td { padding: 12px 15px; border: 1px solid #e1e7ee; text-align: left; }
.info-table th { background: var(--primary); color: #fff; font-weight: 600; }

.pro-tip { background: #fff8e1; border-left: 5px solid #ffc107; padding: 1.5rem; border-radius: 8px; margin: 1.5rem 0; }
.pro-tip strong { color: #856404; display: block; margin-bottom: 5px; }

.formula-box { background: #f8fafc; border: 1px dashed var(--accent); padding: 1.5rem; border-radius: 12px; font-family: 'Courier New', Courier, monospace; overflow-x: auto; margin: 1rem 0; }

/* ============================================================
   ARTICLE / BLOG POST STYLES
   ============================================================ */
.article-body {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    border: 1px solid #E6EBF1;
    max-width: 820px;
    margin: 0 auto;
}
.article-body h2 { font-size: 1.6rem; margin: 2rem 0 1rem; color: var(--primary); }
.article-body h3 { font-size: 1.25rem; margin: 1.5rem 0 0.75rem; color: var(--primary); }
.article-body p { color: var(--text-light); margin-bottom: 1.1rem; line-height: 1.8; font-size: 1.02rem; }
.article-body ul, .article-body ol { margin: 0 0 1.3rem 1.5rem; color: var(--text-light); }
.article-body li { margin-bottom: 0.5rem; line-height: 1.7; }
.article-body a { color: #2563eb; text-decoration: underline; }
.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-light);
    padding-bottom: 1rem;
    border-bottom: 1px solid #E6EBF1;
    margin-bottom: 1.5rem;
}
.article-meta .author-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-dark);
}
.author-chip img {
    width: 34px;
    height: 38px;
    object-fit: cover;
    object-position: top;
    border-radius: 6px;
}
.callout {
    background: #eef2ff;
    border-left: 5px solid #4361ee;
    padding: 1.25rem 1.5rem;
    border-radius: 8px;
    margin: 1.5rem 0;
}
.callout strong { color: #3730a3; }

.related-links {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #E6EBF1;
}
.related-links ul { list-style: none; margin: 0.5rem 0 0 0; padding: 0; }
.related-links li { margin-bottom: 0.5rem; }

/* ============================================================
   FOOTER (compartido)
   ============================================================ */
.site-footer {
    background: var(--primary);
    color: rgba(255,255,255,0.85);
    padding: 3rem 20px 1.5rem 20px;
    margin-top: 3rem;
}
.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}
.footer-col h4 {
    color: #fff;
    font-size: 1rem;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { margin-bottom: 0.5rem; }
.footer-col a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}
.footer-col a:hover { color: var(--accent); }
.footer-brand { font-size: 1.4rem; font-weight: 800; color: #fff; margin-bottom: 0.5rem; }
.footer-brand span { color: var(--accent); }
.footer-desc { font-size: 0.88rem; line-height: 1.6; }
.footer-bottom {
    max-width: 1200px;
    margin: 2rem auto 0 auto;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.12);
    text-align: center;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
}

/* ============================================================
   AD CONTAINERS (AdSense)
   ============================================================ */
.ad-slot {
    display: block;
    margin: 2rem auto;
    max-width: 100%;
    overflow: hidden;
    text-align: center;
    min-height: 90px;
}
.ad-slot ins.adsbygoogle {
    display: block;
    margin: 0 auto;
}
.ad-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    opacity: 0.6;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .info-card { padding: 1.5rem; }
    .info-card h2 { font-size: 1.5rem; }
    .article-body { padding: 1.5rem; }
}

@media (max-width: 1024px) {
    html {
        font-size: 85%;
    }

    body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
        position: relative;
        box-sizing: border-box;
    }

    .container {
        padding: 10px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .card {
        padding: 1rem;
        box-sizing: border-box;
        width: 100%;
        overflow: hidden;
    }

    .grid.grid-2 {
        grid-template-columns: 1fr !important;
    }

    .page-hero { padding: 1.8rem 0; }
    .page-hero h1 { font-size: 1.6rem; padding: 0 12px; }

    .form-control {
        font-size: 0.92rem;
        padding: 0.75rem 0.85rem;
    }

    .form-group label {
        font-size: 0.88rem;
    }

    .result-highlight {
        text-align: center;
        width: 100%;
        box-sizing: border-box;
        padding: 1.5rem 1rem;
    }

    .monthly-payment {
        font-size: 1.7rem;
        word-break: break-all;
        overflow-wrap: anywhere;
        line-height: 1.2;
    }

    .result-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
        text-align: center;
    }

    .result-item {
        padding: 10px 8px;
    }

    .result-item span {
        font-size: 0.72rem;
    }

    .result-item strong {
        font-size: 0.85rem;
        word-break: break-all;
        overflow-wrap: anywhere;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 0;
        width: 100%;
        font-size: 0.78rem;
    }

    th,
    td {
        padding: 8px 10px;
        white-space: nowrap;
    }

    canvas {
        max-width: 100% !important;
        height: auto !important;
    }

    .btn {
        padding: 0.75rem 1.2rem;
        font-size: 0.9rem;
    }

    .expense-row {
        grid-template-columns: 1fr auto;
    }

    .expense-row .expense-amount-input {
        grid-column: 1 / -1;
    }

    .expense-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .expense-total-banner {
        flex-direction: column;
        gap: 4px;
        text-align: center;
    }

    .comparator-wrap {
        padding: 1rem;
        font-size: 0.85rem;
    }
}
