/**
 * Healthcare Cost by Income Widget Styles
 * Standalone widget version for embedding
 */

:root {
    --primary: #008BFF;
    --primary-dark: #0070CC;
    --text: #32373c;
    --text-light: #666;
    --background: #f2f2f2;
    --border: #eaeaea;
    --white: #ffffff;
    --green: #10b981;
    --red: #F32B44;
    --red-dark: #b91c1c;
    --orange: #f59e0b;
    --purple: #8b5cf6;
    --yellow: #eab308;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    overflow: visible;
    height: auto;
}

body {
    font-family: 'Open Sans', Arial, sans-serif;
    color: var(--text);
    background: #008BFF;
    line-height: 1.6;
    padding: 20px;
    display: flex;
    justify-content: center;
}

.healthcare-widget {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.widget-header {
    text-align: center;
    background: var(--white);
    border-radius: 12px;
    padding: 20px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 20px;
}

.widget-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.widget-subtitle {
    color: var(--text-light);
    font-size: 0.95rem;
}

.cost-demo {
    background: transparent;
    border-radius: 12px;
    padding: 28px;
}

.input-section {
    background: transparent;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.results-section {
    background: var(--white);
    border-radius: 12px;
    padding: 28px;
}

.income-visual {
    background: transparent;
    padding: 0;
}

.cost-demo h4 {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

.income-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.income-btn {
    flex: 1;
    min-width: 80px;
    padding: 6px 6px;
    border: 2px solid var(--primary);
    background: var(--white);
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    color: var(--primary);
}

.income-btn:hover {
    background: var(--primary);
    color: white;
    border-color: white;
}

.income-btn.active {
    background: var(--primary);
    color: white;
    border-color: white;
}

.income-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--background);
    border-color: var(--border);
    color: var(--text-light);
}

.income-btn.disabled:hover {
    background: var(--background);
    border-color: var(--border);
    color: var(--text-light);
}

.income-btn .income-label {
    display: block;
    font-size: 0.7rem;
    opacity: 0.8;
    margin-top: 2px;
}

.income-btn .income-pct {
    display: block;
    font-size: 0.65rem;
    opacity: 0.7;
    margin-top: 3px;
    font-weight: 700;
}

/* Button text wrap - hide br on desktop */
.btn-text-wrap br {
    display: none;
}

.state-selector {
    margin-bottom: 16px;
}

.state-selector select {
    width: 100%;
    padding: 10px 32px 10px 12px;
    font-size: 0.9rem;
    font-family: inherit;
    border: 2px solid var(--primary);
    border-radius: 6px;
    background: var(--white);
    color: var(--primary);
    cursor: pointer;
    transition: border-color 0.2s;
    text-align: center;
}

.state-selector select:hover,
.state-selector select:focus {
    border-color: var(--primary);
    outline: none;
}


.cost-comparison-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.cost-left-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cost-breakdown-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 165px;
}

.income-bar-section {
    margin-top: 8px;
}

.system-comparison {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
}

.system-comparison-header {
    font-size: 1.1rem;
    font-weight: 700;
    color: #000000;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    text-align: center;
}

.cost-breakdown-header {
    font-size: 1.1rem;
    font-weight: 700;
    color: #000000;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    text-align: center;
}

/* Show full title by default, hide short title */
.cost-breakdown-header .short-title {
    display: none;
}

.cost-breakdown-header .full-title {
    display: inline;
}

.cost-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 30px 8px 10px;
    background: var(--primary);
    border-radius: 4px;
    font-size: 0.85rem;
    position: relative;
}

.cost-line .cost-line-label {
    color: white;
}

.cost-line .cost-line-amount {
    color: white;
}

.cost-line.hidden-cost {
    background: rgba(139, 92, 246, 0.08);
    border: 1px dashed rgba(139, 92, 246, 0.3);
}

.cost-line.hidden-cost .cost-line-amount {
    color: var(--purple);
}

.hidden-tag {
    font-size: 0.7rem;
    background: var(--purple);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 6px;
    font-weight: 600;
}

.cost-line.total {
    background: var(--text);
    color: white;
    font-weight: 600;
    margin-top: 4px;
}

.cost-line.total .cost-line-amount {
    color: white;
    font-size: 1rem;
}

.cost-line-label {
    color: var(--text);
}

.cost-line.total .cost-line-label {
    color: white;
}

.cost-line-amount {
    font-weight: 600;
    color: var(--text);
}

.income-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 6px;
}

.income-bar-label strong {
    color: var(--text);
}

.income-bar {
    height: 32px;
    background: var(--border);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.income-bar-fill {
    height: 100%;
    display: flex;
    transition: width 0.5s ease-out;
}

.income-bar-segment {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
    transition: width 0.5s ease-out;
}

.income-bar-segment.your-share {
    background: var(--red-dark);
}

.income-bar-segment.employer-share {
    background: var(--purple);
}

.income-bar-segment.oop-share {
    background: var(--red);
}

.income-bar-segment.remaining {
    background: var(--green);
}

.bar-legend {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.75rem;
    margin-top: 8px;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-light);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.legend-dot.your-share { background: var(--red-dark); }
.legend-dot.employer-share { background: var(--purple); }
.legend-dot.oop-share { background: var(--red); }
.legend-dot.remaining { background: var(--green); }

.bar-legend.empty .legend-dot {
    background: #ccc !important;
}

.income-compare-box {
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.info-icon {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 14px;
    height: 14px;
    background: rgba(255, 255, 255, 0.5);
    color: white;
    border-radius: 50%;
    font-size: 0.6rem;
    font-weight: 700;
    font-style: italic;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    opacity: 0.6;
}

.info-icon:hover {
    opacity: 1;
}

.info-icon .tooltip {
    display: none;
    position: absolute;
    top: 20px;
    right: 0;
    width: 200px;
    padding: 8px 10px;
    background: var(--text);
    color: white;
    font-size: 0.75rem;
    font-style: normal;
    font-weight: 400;
    line-height: 1.4;
    border-radius: 6px;
    text-align: left;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.info-icon:hover .tooltip {
    display: block;
}

.info-icon-inline {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    background: #999;
    color: white;
    border-radius: 50%;
    font-size: 0.6rem;
    font-weight: 700;
    font-style: italic;
    cursor: help;
    flex-shrink: 0;
}

.info-icon-inline:hover {
    background: #666;
}

.info-icon-inline .tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 8px;
    width: 220px;
    padding: 8px 10px;
    background: var(--text);
    color: white;
    font-size: 0.75rem;
    font-style: normal;
    font-weight: 400;
    line-height: 1.4;
    border-radius: 6px;
    text-align: left;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.info-icon-inline:hover .tooltip {
    display: block;
}

.income-compare-box.current {
    background: var(--red);
    border: none;
}

.income-compare-box.universal {
    background: var(--primary);
    border: none;
}

.income-compare-label {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: white;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.income-compare-pct {
    font-size: 1rem;
    font-weight: 600;
    color: white;
}

.income-compare-detail {
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    margin-top: 4px;
}

.income-impact {
    margin-top: 16px;
    padding: 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.income-impact::before {
    flex-shrink: 0;
    font-size: 1.2rem;
    line-height: 1;
}

.income-impact.regressive {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--text);
}

.income-impact.regressive::before {
    content: "⚠";
    color: var(--red);
}

.income-impact.regressive strong {
    color: var(--red);
}

.income-impact.medicaid {
    background: rgba(0, 139, 255, 0.1);
    border: 1px solid rgba(0, 139, 255, 0.2);
    color: var(--text);
}

.income-impact.medicaid::before {
    content: "";
    width: 24px;
    height: 24px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24px' viewBox='0 -960 960 960' width='24px' fill='%235087e5'%3E%3Cpath d='M320-120v-200H120v-320h200v-200h320v200h200v320H640v200H320Zm80-80h160v-200h200v-160H560v-200H400v200H200v160h200v200Zm80-280Z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

.income-impact.medicaid strong {
    color: var(--primary);
}

.income-impact.affordable {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: var(--text);
}

.income-impact.affordable::before {
    content: "";
    width: 24px;
    height: 24px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24px' viewBox='0 -960 960 960' width='24px' fill='%2322c55e'%3E%3Cpath d='M160-120q-33 0-56.5-23.5T80-200v-440q0-33 23.5-56.5T160-720h160v-80q0-33 23.5-56.5T400-880h160q33 0 56.5 23.5T640-800v80h160q33 0 56.5 23.5T880-640v440q0 33-23.5 56.5T800-120H160Zm240-600h160v-80H400v80Zm400 360H600v80H360v-80H160v160h640v-160Zm-360 0h80v-80h-80v80Zm-280-80h200v-80h240v80h200v-200H160v200Zm320 40Z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

.income-impact.affordable strong {
    color: var(--green);
}

.insight-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.insight-content strong {
    font-size: 1rem;
    display: block;
}

.insight-content p {
    margin: 0;
    line-height: 1.5;
}

.inline-source {
    font-size: 0.75rem;
    color: var(--text-light);
}

.inline-source a {
    color: var(--primary);
    text-decoration: none;
}

.inline-source a:hover {
    text-decoration: underline;
}

/* Grayed out state for results panels */
.results-disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* Reset demo button */
.reset-demo-btn {
    display: block;
    width: 100%;
    margin-top: 16px;
    padding: 14px 24px;
    background: var(--red);
    color: white;
    border: 2px solid var(--red);
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.reset-demo-btn:hover {
    background: var(--red-dark);
    border-color: var(--red-dark);
}

.reset-demo-btn:active {
    transform: scale(0.98);
}

@media (max-width: 700px) {
    .cost-comparison-row {
        grid-template-columns: 1fr;
    }

    .system-comparison {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .system-comparison-header {
        grid-column: 1 / -1;
        text-align: center;
    }

    .system-comparison .income-compare-box {
        flex: 1;
    }

    .income-bar-section {
        margin-top: 12px;
    }
}

@media (max-width: 600px) {
    body {
        padding: 8px;
    }

    .cost-demo {
        padding: 16px;
    }

    .widget-header h2 {
        font-size: 1.15rem;
    }

    .widget-subtitle {
        font-size: 0.85rem;
    }

    .cost-demo h4 {
        font-size: 1rem;
        font-weight: 700;
    }

    .cost-breakdown-header,
    .system-comparison-header {
        font-size: 1rem;
        font-weight: 700;
    }

    /* Stack income buttons in 2 rows of 3 */
    .income-selector {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .income-btn {
        min-width: unset;
        padding: 8px 4px;
        font-size: 0.7rem;
    }

    .income-btn .income-pct,
    .income-btn .income-label {
        font-size: 0.55rem;
    }

    /* Stack employment buttons in 2 rows of 3 */
    #employment-selector {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    /* Cost breakdown adjustments */
    .cost-breakdown-grid {
        min-height: auto;
    }

    .cost-line {
        padding: 6px 26px 6px 8px;
        font-size: 0.8rem;
    }

    .cost-line-label {
        font-size: 0.75rem;
    }

    .cost-line-amount {
        font-size: 0.8rem;
    }

    .hidden-tag {
        font-size: 0.6rem;
        padding: 1px 4px;
    }

    /* Info icon tooltip adjustments for mobile */
    .info-icon-inline .tooltip {
        width: 180px;
        font-size: 0.7rem;
        right: -10px;
    }

    .info-icon .tooltip {
        width: 160px;
        font-size: 0.7rem;
    }

    /* Income bar section */
    .income-bar-label {
        font-size: 0.75rem;
        flex-direction: column;
        gap: 2px;
    }

    .bar-legend {
        font-size: 0.65rem;
        gap: 8px;
    }

    .legend-dot {
        width: 8px;
        height: 8px;
    }

    /* Comparison boxes */
    .income-compare-label {
        font-size: 0.85rem;
    }

    .income-compare-pct {
        font-size: 0.9rem;
    }

    .income-compare-detail {
        font-size: 0.75rem;
    }

    .system-comparison-header,
    .cost-breakdown-header {
        font-size: 0.7rem;
    }

    /* Insight box */
    .income-impact {
        padding: 12px;
        font-size: 0.85rem;
    }

    .insight-content strong {
        font-size: 0.9rem;
    }

    .insight-content p {
        font-size: 0.8rem;
        line-height: 1.4;
    }

    /* State selector */
    .state-selector select {
        font-size: 0.8rem;
        padding: 8px 10px;
    }

    /* Source link */
    .inline-source {
        font-size: 0.65rem;
    }
}

/* iPhone 16 Pro optimization (430px and below) */
@media (max-width: 430px) {
    body {
        padding: 4px;
    }

    .healthcare-widget {
        width: 100%;
    }

    .widget-header {
        padding: 14px;
        margin-bottom: 12px;
        border-radius: 8px;
    }

    .widget-header h2 {
        font-size: 1.1rem;
    }

    .widget-subtitle {
        font-size: 0.8rem;
    }

    .cost-demo {
        padding: 10px;
    }

    .input-section {
        padding: 12px;
        margin-bottom: 12px;
        border-radius: 8px;
    }

    .results-section {
        padding: 14px;
        border-radius: 8px;
    }

    .income-visual {
        padding: 12px;
    }

    .cost-demo h4 {
        font-size: 1rem;
        font-weight: 700;
    }

    /* Income buttons grid - equal size buttons */
    .income-selector {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }

    .income-btn {
        flex: none;
        min-width: unset;
        width: 100%;
        height: 65px;
        min-height: 65px;
        max-height: 65px;
        padding: 4px 2px;
        font-size: 0.95rem;
        font-weight: 700;
        border-radius: 4px;
        border-width: 1.5px;
        line-height: 1.1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

    .income-btn .income-pct,
    .income-btn .income-label {
        font-size: 0.65rem;
        margin-top: 1px;
        line-height: 1.2;
    }

    /* Employment buttons - equal size */
    #employment-selector {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }

    #employment-selector .income-btn {
        height: 65px;
        min-height: 65px;
        max-height: 65px;
    }

    /* Cost breakdown */
    .cost-breakdown-header,
    .system-comparison-header {
        font-size: 1rem;
        font-weight: 700;
        margin-bottom: 6px;
    }

    /* Show short title on mobile, hide full title */
    .cost-breakdown-header .short-title {
        display: inline;
    }

    .cost-breakdown-header .full-title {
        display: none;
    }

    /* Bring Coverage % closer to boxes */
    .system-comparison-header {
        margin-bottom: 2px;
    }

    .system-comparison-header {
        margin-top: 8px;
    }

    .cost-line {
        padding: 8px 28px 8px 10px;
        font-size: 0.9rem;
    }

    .cost-line-label {
        font-size: 0.85rem;
    }

    .cost-line-amount {
        font-size: 0.9rem;
    }

    .cost-line.total .cost-line-amount {
        font-size: 1rem;
    }

    .hidden-tag {
        font-size: 0.65rem;
        padding: 2px 5px;
    }

    /* Income bar */
    .income-bar-label {
        font-size: 0.85rem;
    }

    .income-bar {
        height: 32px;
    }

    .bar-legend {
        font-size: 0.75rem;
        gap: 8px;
        margin-top: 10px;
    }

    .legend-dot {
        width: 10px;
        height: 10px;
    }

    /* Comparison boxes */
    .income-compare-box {
        padding: 14px 10px;
    }

    .income-compare-label {
        font-size: 1rem;
    }

    .income-compare-pct {
        font-size: 1.1rem;
    }

    .income-compare-detail {
        font-size: 0.85rem;
    }

    /* Info icons */
    .info-icon {
        width: 14px;
        height: 14px;
        font-size: 0.55rem;
    }

    .info-icon-inline {
        width: 14px;
        height: 14px;
        font-size: 0.55rem;
    }

    .info-icon-inline .tooltip,
    .info-icon .tooltip {
        width: 160px;
        font-size: 0.7rem;
        padding: 8px 10px;
    }

    /* Insight box */
    .income-impact {
        padding: 14px;
        font-size: 0.95rem;
        gap: 12px;
    }

    .income-impact::before {
        font-size: 1.2rem;
    }

    .insight-content strong {
        font-size: 1rem;
    }

    .insight-content p {
        font-size: 0.9rem;
        line-height: 1.45;
    }

    /* State selector - match height of buttons */
    .state-selector select {
        font-size: 0.95rem;
        padding: 16px 12px;
        min-height: 65px;
    }

    /* Show line break on mobile for wrapped button text */
    .btn-text-wrap br {
        display: inline;
    }

    .btn-text-wrap {
        line-height: 1.1;
    }

    /* Source link */
    .inline-source {
        font-size: 0.75rem;
    }

    /* Reset button */
    .reset-demo-btn {
        padding: 16px 20px;
        font-size: 1.1rem;
        margin-top: 14px;
    }
}

/* Extra small screens */
@media (max-width: 380px) {
    body {
        padding: 2px;
    }

    .cost-demo {
        padding: 8px;
    }

    .widget-header h2 {
        font-size: 1rem;
    }

    /* Keep large button text and equal sizing on small screens */
    .income-btn {
        height: 60px !important;
        min-height: 60px !important;
        max-height: 60px !important;
        padding: 3px 1px !important;
        font-size: 0.9rem !important;
        line-height: 1.1 !important;
    }

    .income-btn .income-pct,
    .income-btn .income-label {
        font-size: 0.6rem !important;
    }

    .cost-line {
        padding: 5px 24px 5px 6px;
    }

    .cost-line-label {
        font-size: 0.7rem;
    }

    .income-compare-box {
        padding: 10px 8px;
    }

    .info-icon-inline .tooltip {
        width: 150px;
        right: -20px;
    }
}
