/**
 * RWL Entity Calculator - Complete Stylesheet
 * White background, black text, compact financial-tool density.
 *
 * @package RWL_Entity_Calculator
 * @since 1.2.0
 */

/* ================================================================== */
/*  ROOT CONTAINER                                                     */
/* ================================================================== */

#rwl-entity-calculator {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    color: #111827;
    background: #fff;
    line-height: 1.5;
    box-sizing: border-box;
}

#rwl-entity-calculator *,
#rwl-entity-calculator *::before,
#rwl-entity-calculator *::after {
    box-sizing: border-box;
}

/* ================================================================== */
/*  HEADER                                                             */
/* ================================================================== */

.rwl-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 4px;
}

.rwl-subtitle {
    font-size: 12px;
    color: #6b7280;
}

.rwl-tax-year-badge {
    display: inline;
    font-weight: 700;
    color: #111827;
}

/* ================================================================== */
/*  SECTIONS                                                           */
/* ================================================================== */

.rwl-section {
    margin-bottom: 16px;
}

.rwl-section-heading {
    font-size: 15px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #d1d5db;
}

/* ================================================================== */
/*  FIELD GRID & ROWS                                                  */
/* ================================================================== */

.rwl-field-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rwl-field-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    align-items: center;
    gap: 10px;
}

.rwl-field-row label {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.rwl-field-row.rwl-full-width {
    grid-column: 1 / -1;
}

.rwl-field-input {
    width: 100%;
}

/* ================================================================== */
/*  INPUTS                                                             */
/* ================================================================== */

.rwl-input,
.rwl-currency {
    width: 100%;
    padding: 5px 8px;
    font-size: 14px;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    background: #fff;
    color: #111827;
    outline: none;
    font-family: inherit;
}

.rwl-input:focus,
.rwl-currency:focus {
    border-color: #111827;
}

.rwl-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 28px;
    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='%23374151' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 12px;
}

.rwl-input-prominent {
    font-size: 16px;
    font-weight: 600;
    padding: 7px 10px;
}

/* ================================================================== */
/*  TOGGLE BUTTONS (Filing Status)                                     */
/* ================================================================== */

.rwl-toggle-group {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
}

.rwl-toggle-btn {
    padding: 5px 8px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
    cursor: pointer;
    border-radius: 3px;
    line-height: 1.4;
    font-family: inherit;
}

.rwl-toggle-btn:hover {
    background: #f3f4f6;
}

.rwl-toggle-btn.active {
    background: #111827;
    color: #fff;
    border-color: #111827;
}

/* ================================================================== */
/*  HELP                                                               */
/* ================================================================== */

.rwl-help-btn {
    display: inline-flex;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #e5e7eb;
    color: #6b7280;
    font-size: 10px;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    margin-left: 2px;
    flex-shrink: 0;
    line-height: 1;
    padding: 0;
}

.rwl-help-btn:hover {
    background: #d1d5db;
}

.rwl-help-text {
    display: none;
    padding: 8px 12px;
    margin-top: 4px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 3px;
    font-size: 12px;
    color: #374151;
    line-height: 1.5;
}

/* ================================================================== */
/*  SSTB INDICATOR                                                     */
/* ================================================================== */

.rwl-sstb-indicator {
    margin-top: 2px;
    margin-left: 190px;
    font-size: 12px;
}

.rwl-sstb-yes {
    color: #dc2626;
    font-weight: 600;
}

.rwl-sstb-no {
    color: #059669;
    font-weight: 600;
}

/* ================================================================== */
/*  SALARY                                                             */
/* ================================================================== */

.rwl-salary-info {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: 190px;
    font-size: 12px;
    color: #374151;
}

.rwl-salary-guidance {
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 2px;
}

.rwl-salary-low {
    color: #d97706;
    background: #fffbeb;
}

.rwl-salary-ok {
    color: #059669;
    background: #f0fdf4;
}

.rwl-salary-high {
    color: #d97706;
    background: #fffbeb;
}

/* ================================================================== */
/*  SLIDER                                                             */
/* ================================================================== */

.rwl-slider {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #d1d5db;
    border-radius: 2px;
    outline: none;
}

.rwl-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #111827;
    border: 2px solid #fff;
    cursor: pointer;
    box-shadow: 0 0 0 1px #d1d5db;
}

.rwl-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #111827;
    border: 2px solid #fff;
    cursor: pointer;
    box-shadow: 0 0 0 1px #d1d5db;
}

/* ================================================================== */
/*  FIELD NOTES, CHECKBOX, CONDITIONAL                                 */
/* ================================================================== */

.rwl-field-note {
    font-size: 11px;
    color: #6b7280;
    margin-left: 190px;
}

.rwl-checkbox {
    accent-color: #111827;
}

.rwl-conditional {
    margin-left: 190px;
}

.rwl-range-display {
    margin-left: 190px;
    font-size: 12px;
    color: #374151;
}

/* ================================================================== */
/*  CALCULATE BUTTON                                                   */
/* ================================================================== */

#rwl-calculate-btn {
    display: block;
    margin: 16px auto 0;
    padding: 8px 32px;
    font-size: 14px;
    font-weight: 600;
    background: #111827;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
}

#rwl-calculate-btn:hover {
    background: #374151;
}

/* ================================================================== */
/*  RESULTS CARDS                                                      */
/* ================================================================== */

.rwl-results-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin: 16px 0;
}

.rwl-result-card {
    padding: 10px 8px;
    text-align: center;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #fff;
    position: relative;
}

.rwl-card-optimal {
    border-color: #059669;
    background: #f0fdf4;
}

.rwl-card-label {
    font-size: 11px;
    color: #6b7280;
    font-weight: 500;
}

.rwl-card-total {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
    font-family: monospace;
    margin: 4px 0;
}

.rwl-card-rate {
    font-size: 11px;
    color: #6b7280;
}

.rwl-card-savings {
    font-size: 11px;
    font-weight: 600;
}

.rwl-card-savings.rwl-negative {
    color: #dc2626;
}

.rwl-optimal-badge {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: #111827;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 8px;
    text-transform: uppercase;
    white-space: nowrap;
}

/* ================================================================== */
/*  COMPARISON TABLE                                                   */
/* ================================================================== */

.rwl-comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.rwl-comparison-table thead th {
    padding: 4px 8px;
    text-align: right;
    font-size: 11px;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #111827;
    background: #fff;
}

.rwl-comparison-table thead th:first-child {
    text-align: left;
}

.rwl-comparison-table td {
    padding: 4px 8px;
    text-align: right;
    border-bottom: 1px solid #f3f4f6;
    font-family: monospace;
    font-size: 12px;
}

.rwl-comparison-table td:first-child {
    text-align: left;
    font-family: inherit;
}

.rwl-section-header td {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    padding-top: 10px;
    border-bottom: 1px solid #d1d5db;
    font-family: inherit;
}

.rwl-total-row td {
    font-weight: 700;
    font-size: 13px;
    border-top: 2px solid #111827;
    border-bottom: 3px double #111827;
    color: #111827;
}

.rwl-col-optimal,
.rwl-optimal-cell {
    background: #f0fdf4;
}

.rwl-negative {
    color: #dc2626;
}

/* ================================================================== */
/*  DETAIL TOGGLE                                                      */
/* ================================================================== */

.rwl-detail-toggle {
    width: 100%;
    padding: 6px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    font-size: 12px;
    color: #374151;
    cursor: pointer;
    text-align: center;
    margin: 8px 0;
    font-family: inherit;
}

.rwl-detail-toggle:hover {
    background: #f9fafb;
}

/* ================================================================== */
/*  CHARTS                                                             */
/* ================================================================== */

.rwl-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 12px 0;
}

.rwl-chart-wrap {
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 10px;
}

.rwl-chart-wrap h3 {
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 8px;
    color: #111827;
}

/* ================================================================== */
/*  FLAGS                                                              */
/* ================================================================== */

.rwl-flag {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 3px;
    margin-bottom: 4px;
}

.rwl-flag-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.rwl-flag-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ================================================================== */
/*  SENSITIVITY / PROJECTIONS TABLES                                   */
/* ================================================================== */

.rwl-sensitivity-table,
.rwl-projections-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.rwl-sensitivity-table thead th,
.rwl-projections-table thead th {
    padding: 4px 8px;
    text-align: right;
    font-size: 11px;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #111827;
    background: #fff;
}

.rwl-sensitivity-table thead th:first-child,
.rwl-projections-table thead th:first-child {
    text-align: left;
}

.rwl-sensitivity-table td,
.rwl-projections-table td {
    padding: 4px 8px;
    text-align: right;
    border-bottom: 1px solid #f3f4f6;
    font-family: monospace;
    font-size: 12px;
}

.rwl-sensitivity-table td:first-child,
.rwl-projections-table td:first-child {
    text-align: left;
    font-family: inherit;
}

/* ================================================================== */
/*  PDF SECTION                                                        */
/* ================================================================== */

.rwl-pdf-section {
    text-align: center;
    margin: 16px 0;
}

.rwl-btn {
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
}

.rwl-btn-accent {
    background: #111827;
    color: #fff;
}

.rwl-btn-accent:hover {
    background: #374151;
}

.rwl-btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.rwl-btn-secondary:hover {
    background: #d1d5db;
}

.rwl-btn-primary {
    background: #111827;
    color: #fff;
}

.rwl-btn-primary:hover {
    background: #374151;
}

/* ================================================================== */
/*  SHARE SECTION (HIDDEN)                                             */
/* ================================================================== */

.rwl-share-section {
    display: none !important;
}

/* ================================================================== */
/*  DISCLAIMER & FOOTER                                                */
/* ================================================================== */

.rwl-disclaimer {
    font-size: 10px;
    color: #6b7280;
    margin-top: 16px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
}

.rwl-disclaimer p {
    margin: 0;
}

.rwl-footer {
    font-size: 10px;
    color: #9ca3af;
    text-align: center;
    margin-top: 8px;
}

.rwl-footer p {
    margin: 0;
}

/* ================================================================== */
/*  LOADING & ERROR                                                    */
/* ================================================================== */

.rwl-loading {
    text-align: center;
    padding: 20px;
    color: #6b7280;
}

.rwl-error {
    text-align: center;
    padding: 20px;
    color: #dc2626;
}

/* ================================================================== */
/*  RESPONSIVE (max-width 768px)                                       */
/* ================================================================== */

@media (max-width: 768px) {
    .rwl-field-row {
        grid-template-columns: 1fr;
    }

    .rwl-field-row label {
        text-align: left;
        justify-content: flex-start;
    }

    .rwl-toggle-group {
        grid-template-columns: repeat(2, 1fr);
    }

    .rwl-sstb-indicator,
    .rwl-salary-info,
    .rwl-field-note,
    .rwl-conditional,
    .rwl-range-display {
        margin-left: 0;
    }

    .rwl-charts {
        grid-template-columns: 1fr;
    }

    .rwl-results-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ================================================================== */
/*  PRINT                                                              */
/* ================================================================== */

@media print {
    #rwl-calculate-btn,
    .rwl-btn,
    .rwl-share-section,
    .rwl-pdf-section,
    .rwl-help-btn {
        display: none !important;
    }

    .rwl-help-text {
        display: none !important;
    }

    #rwl-entity-calculator {
        max-width: 100%;
        padding: 0;
    }
}
