/* Compound Interest Comparison Calculator styles */
/* All scoped with .cic- to avoid clashes */

.cic-app {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #0b1f2a;
    font-size: 16px;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    box-sizing: border-box;
    padding: 0 1rem;
}

.cic-wrapper {
    border: 1px solid #083141;
    border-radius: 12px;
    padding: 20px;
    background: #ffffff;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    box-sizing: border-box;
}

.cic-header-actions {
    margin-bottom: 20px;
    text-align: right;
}

@media (max-width: 640px) {
    .cic-header-actions {
        text-align: center;
    }
}

.cic-header {
    margin-bottom: 1.5rem;
}

.cic-title {
    font-size: 1.6rem;
    margin: 0 0 0.25rem 0;
}

.cic-intro {
    margin: 0;
    font-size: 0.95rem;
    color: #47616b;
}

.cic-layout-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Cards */

.cic-card {
    border: 1px solid #d6e2ea;
    background: #f7fbfd;
    border-radius: 8px;
    padding: 14px 14px 16px;
}

.cic-card--results {
    background: #ffffff;
}

.cic-card-title {
    margin: 0 0 8px 0;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.3;
    color: #083141;
}

.cic-card-text {
    margin: 0 0 16px 0;
    font-size: 0.95rem;
    color: #42586a;
    line-height: 1.5;
}

/* Grid */

.cic-grid {
    display: grid;
    gap: 12px;
}

.cic-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cic-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1024px) {
    .cic-grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .cic-grid-2,
    .cic-grid-3 {
        grid-template-columns: 1fr;
    }
}

/* Fields and inputs */

.cic-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 60px;
    justify-content: flex-start;
}

.cic-field--inline {
    margin-top: 0;
}

.cic-field--actions {
    align-items: flex-start;
    justify-content: flex-start;
    min-width: 80px;
    min-height: 60px;
    padding-top: 24px;
}

.cic-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1c3444;
    margin: 0;
    line-height: 1.4;
    min-height: 1.4em;
}

.cic-input-wrap {
    display: flex;
    align-items: stretch;
    border-radius: 6px;
    border: 1px solid #d1d8dd;
    background: #ffffff;
    overflow: hidden;
    min-height: 38px;
}

.cic-input-wrap--prefix .cic-input-prefix,
.cic-input-wrap--suffix .cic-input-suffix {
    padding: 8px 10px;
    font-size: 0.9rem;
    border-right: 1px solid #d1d8dd;
    background: #ebf2f4;
    color: #274153;
    white-space: nowrap;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.cic-input-wrap--suffix .cic-input-suffix {
    border-right: none;
    border-left: 1px solid #d1d8dd;
}

.cic-input {
    flex: 1 1 auto;
    border: none;
    padding: 8px 10px;
    font-size: 0.95rem;
    min-width: 0;
    min-height: 38px;
    background: transparent;
    box-sizing: border-box;
}

.cic-input:focus {
    outline: none;
    box-shadow: 0 0 0 1px rgba(89, 116, 124, 0.3);
}

.cic-input::placeholder {
    color: #9aa7b4;
}

.cic-help-text {
    margin: 4px 0 8px 0;
    font-size: 0.85rem;
    color: #6c7d89;
    line-height: 1.4;
    font-weight: normal;
}

/* Radio group */

.cic-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 4px;
}

.cic-radio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: #1e3241;
}

/* Buttons */

.cic-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid #59747c;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    background: #f4fafb;
    color: #0b1f2a;
    min-height: 38px;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
    box-sizing: border-box;
}

.cic-btn:hover {
    background: #ebf2f4;
    border-color: #445c63;
}

.cic-btn:active {
    transform: translateY(1px);
}

.cic-btn--secondary {
    background: #59747c;
    color: #ffffff;
    border-color: #4a636a;
}

.cic-btn--secondary:hover {
    background: #4a636a;
}

.cic-btn--ghost {
    background: transparent;
    color: #5b1e1e;
    border-color: #e2b4b4;
}

.cic-btn--reset {
    font-size: 0.9rem;
    padding: 8px 16px;
    min-height: 38px;
    font-weight: 600;
    background: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
}

.cic-btn--reset:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.3);
}

.cic-btn--remove {
    font-size: 0.9rem;
    padding: 8px 16px;
    min-height: 38px;
    font-weight: 600;
    background: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
}

.cic-btn--remove:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.3);
}

/* Scenarios */

.cic-scenarios {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 8px;
}

.cic-scenario-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr auto;
    gap: 10px;
    padding: 16px;
    border-radius: 8px;
    border: 2px solid #d6e2ea;
    background: #ffffff;
    align-items: start;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.cic-investment-row {
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #ffffff;
}

.cic-investment-header {
    margin-bottom: 12px;
}

.cic-investment-title {
    margin: 0 0 12px 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #083141;
}

.cic-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 1024px) {
    .cic-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .cic-grid-4 {
        grid-template-columns: 1fr;
    }
}

.cic-scenario-row > .cic-field {
    min-width: 0;
}

.cic-scenario-row .cic-toggle-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    background: #f3f4f6;
    padding: 3px;
    border-radius: 8px;
}

.cic-scenario-row .cic-toggle {
    font-size: 0.85rem;
    padding: 6px 10px;
    min-height: 34px;
}

.cic-scenario-row--conservative {
    border-left: 4px solid #3b82f6;
    background: #eff6ff;
}

.cic-scenario-row--balanced {
    border-left: 4px solid #10b981;
    background: #f0fdf4;
}

.cic-scenario-row--growth {
    border-left: 4px solid #f59e0b;
    background: #fffbeb;
}

.cic-scenario-row--aggressive {
    border-left: 4px solid #ef4444;
    background: #fef2f2;
}

@media (max-width: 1024px) {
    .cic-scenario-row {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .cic-scenario-row .cic-field--actions {
        grid-column: 1 / -1;
        align-items: flex-start;
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .cic-scenario-row {
        grid-template-columns: 1fr;
    }

    .cic-field--actions {
        align-items: flex-start;
        justify-content: flex-start;
    }

    .cic-chart-wrapper {
        height: 250px;
        padding: 8px;
    }

    .cic-comparison-grid {
        grid-template-columns: 1fr;
    }

    .cic-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .cic-grid-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1100px) {
    .cic-wrapper {
        padding: 15px;
    }
}

@media (max-width: 640px) {
    .cic-wrapper {
        padding: 12px;
        border-radius: 8px;
    }

    .cic-card {
        padding: 12px;
    }

    .cic-card-title {
        font-size: 1.1rem;
    }

    .cic-title {
        font-size: 1.4rem;
    }
}

/* Results */

.cic-results-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.cic-summary-line {
    margin: 0;
}

.cic-table-wrap {
    overflow-x: auto;
}

.cic-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    table-layout: fixed;
}

.cic-table th,
.cic-table td {
    padding: 4px 6px;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cic-table th:first-child,
.cic-table td:first-child {
    text-align: left;
    width: 10%;
}

.cic-table th:nth-child(2),
.cic-table td:nth-child(2) {
    width: 8%;
}

.cic-table th:nth-child(3),
.cic-table td:nth-child(3) {
    width: 6%;
}

.cic-table th:nth-child(4),
.cic-table td:nth-child(4) {
    width: 7%;
}

.cic-table th:nth-child(5),
.cic-table td:nth-child(5) {
    width: 12%;
}

.cic-table th:nth-child(6),
.cic-table td:nth-child(6) {
    width: 10%;
}

.cic-table th:nth-child(7),
.cic-table td:nth-child(7) {
    width: 11%;
}

.cic-table th:nth-child(8),
.cic-table td:nth-child(8) {
    width: 11%;
}

.cic-table th:nth-child(9),
.cic-table td:nth-child(9) {
    width: 12%;
}

.cic-table th:nth-child(10),
.cic-table td:nth-child(10) {
    width: 13%;
}

.cic-table thead th {
    background: #ebf2f4;
    border-bottom: 1px solid #d6e2ea;
    font-weight: 600;
}

.cic-table tbody tr:nth-child(even) {
    background: #f9fbfc;
}

.cic-table tbody tr:nth-child(odd) {
    background: #ffffff;
}

.cic-bar-cell {
    width: 120px;
    max-width: 100%;
    height: 14px;
    border-radius: 7px;
    background: #edf3f6;
    overflow: hidden;
}

.cic-bar-cell__bar {
    height: 100%;
    border-radius: 8px;
    background: #59747c;
    transition: width 0.3s ease;
}

/* Investment type selector */
.cic-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d8dd;
    border-radius: 6px;
    font-size: 0.95rem;
    background: #ffffff;
    cursor: pointer;
    min-height: 38px;
    box-sizing: border-box;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234b5563' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

.cic-select:focus {
    outline: none;
    border-color: #59747c;
    box-shadow: 0 0 0 1px rgba(89, 116, 124, 0.3);
}

/* Toggle for monthly/yearly */
.cic-toggle-group {
    display: flex;
    gap: 6px;
    margin-top: 4px;
    background: #f3f4f6;
    padding: 3px;
    border-radius: 8px;
}

.cic-toggle {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #d1d8dd;
    border-radius: 6px;
    background: #ffffff;
    cursor: pointer;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-sizing: border-box;
    position: relative;
}

.cic-toggle:hover {
    background: #f7fbfd;
    border-color: #9ca3af;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.cic-toggle--active {
    background: #59747c;
    color: #ffffff;
    border-color: #59747c;
    box-shadow: 0 2px 4px rgba(89, 116, 124, 0.3);
}

.cic-toggle--active:hover {
    background: #4a636a;
    border-color: #4a636a;
    box-shadow: 0 3px 6px rgba(89, 116, 124, 0.4);
    transform: translateY(-1px);
}

/* Charts */
.cic-chart-wrapper {
    width: 100%;
    height: 350px;
    margin: 20px 0;
    padding: 10px;
    background: #f9fbfc;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.cic-chart-canvas {
    width: 100%;
    height: 100%;
}

.cic-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 12px;
    padding: 12px;
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.cic-chart-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.cic-chart-legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
}

.cic-chart-legend-line {
    width: 40px;
    height: 3px;
    flex-shrink: 0;
    display: block;
}

.cic-chart-tooltip {
    background: rgba(8, 49, 65, 0.95);
    color: #ffffff;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    line-height: 1.5;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    max-width: 200px;
}

.cic-chart-tooltip strong {
    display: block;
    margin-bottom: 4px;
    font-size: 0.9rem;
    color: #ffffff;
}

.cic-chart-tooltip br {
    line-height: 1.6;
}

/* Comparison cards */
.cic-comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.cic-comparison-card {
    padding: 16px;
    background: #ffffff;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cic-comparison-card-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #1c3444;
}

.cic-comparison-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: #083141;
}

.cic-comparison-card-label {
    font-size: 0.8rem;
    color: #6c7d89;
    margin: 4px 0 0 0;
}

/* Return type indicator */
.cic-return-type {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #e5e7eb;
    color: #4b5563;
}

.cic-return-type--average {
    background: #dbeafe;
    color: #1e40af;
}

.cic-return-type--lumpy {
    background: #fef3c7;
    color: #92400e;
}

/* Misc */

.cic-empty {
    margin: 6px 0 0;
    font-size: 0.9rem;
    color: #6c7d89;
}

.cic-footer {
    margin-top: 14px;
    font-size: 0.8rem;
    color: #6c7d89;
}

.cic-footer-note {
    margin: 0;
}

/* CSV export CTA (bottom of calculator) */
.cic-csv-cta {
    margin-top: 1.75rem;
    padding: 30px 24px;
    border-top: 3px solid #083141;
    background: linear-gradient(180deg, rgba(8, 49, 65, 0.08) 0%, rgba(8, 49, 65, 0.02) 100%);
    border-radius: 16px;
    text-align: center;
}

.cic-csv-cta-title {
    margin: 0 0 0.35rem 0;
    color: #083141;
    font-size: 1.15rem;
    font-weight: 800;
}

.cic-csv-cta-subtitle {
    margin: 0 0 1rem 0;
    color: #334155;
    font-size: 0.95rem;
}

.cic-btn--csv-cta {
    background: linear-gradient(135deg, #083141 0%, #0a4a63 100%);
    border: 3px solid #083141;
    color: #fff;
    padding: 18px 36px;
    font-size: 18px;
    font-weight: 800;
    min-height: 56px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 6px 20px rgba(8, 49, 65, 0.25);
    cursor: pointer;
    border-radius: 14px;
}

.cic-btn--csv-cta:hover:not(:disabled) {
    background: linear-gradient(135deg, #0a4a63 0%, #062a38 100%);
    border-color: #062a38;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(8, 49, 65, 0.3);
}

.cic-btn--csv-cta:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* MailerLite signup modal */
.cic-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    padding: 20px;
}

.cic-modal {
    background: #fff;
    border: 3px solid #9333ea;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    max-width: 540px;
    width: 100%;
    z-index: 1000000;
}

.cic-modal-header {
    padding: 28px;
    background: linear-gradient(135deg, #9333ea, #7e22ce);
    border-radius: 20px 20px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cic-modal-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    color: #fff;
}

.cic-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 28px;
    color: #fff;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    line-height: 1;
}

.cic-modal-body {
    padding: 28px;
}

.cic-modal-label {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 10px;
    display: block;
}

.cic-modal-input {
    font-size: 16px;
    padding: 14px 16px;
    border: 3px solid #9333ea;
    width: 100%;
    border-radius: 12px;
    box-sizing: border-box;
}

.cic-modal-trust {
    background: #f3e8ff;
    padding: 16px;
    border-radius: 12px;
    margin-top: 24px;
    font-size: 14px;
}

.cic-modal-footer {
    padding: 24px 28px;
    border-top: 3px solid #e9d5ff;
    display: flex;
    gap: 14px;
    justify-content: flex-end;
    background: #f3e8ff;
    flex-wrap: wrap;
}

.cic-modal-submit {
    min-width: 220px;
    min-height: 48px;
    border: 3px solid #9333ea;
    background: #9333ea;
    color: #fff;
    padding: 16px 32px;
    border-radius: 14px;
    font-weight: 800;
    cursor: pointer;
}

.cic-modal-submit:hover:not(:disabled) {
    background: #7e22ce;
}

.cic-modal-btn-secondary {
    border: 2px solid #e9d5ff;
    background: #fff;
    color: #0f172a;
    padding: 14px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    min-height: 48px;
}

.cic-modal-error {
    color: #dc2626;
    font-size: 14px;
    margin-top: 8px;
}

.cic-modal-success {
    font-size: 18px;
    font-weight: 700;
    color: #059669;
    text-align: center;
    padding: 24px;
}

@media (max-width: 540px) {
    .cic-modal {
        max-width: 100%;
        margin: 0 8px;
    }

    .cic-modal-footer {
        flex-direction: column;
    }

    .cic-modal-submit,
    .cic-modal-btn-secondary {
        min-width: 100%;
        min-height: 48px;
    }
}

/* Print */

@media print {
    .cic-wrapper {
        border: none;
        padding: 0;
        max-width: 100%;
    }

    .cic-csv-cta {
        display: none;
    }

    .cic-btn {
        display: none;
    }

    .cic-card {
        page-break-inside: avoid;
    }
}
