/* ============================================
   Financial Input (Bloomberg dark + portal light manage UI)
   Portal light / right-only steppers: financial model, deal model edit, apply forms.
   Row layout (label | value): portal_calculator_fields.css
   ============================================ */

:root {
    /* Portal amount column — value box fits £999,222,222 (13 chars + padding @ portal value size, mono) */
    --financial-input-portal-value-max: 7.35rem;
    --financial-input-portal-control-height: 2rem;
    --financial-input-portal-stepper-col: 2.65rem;
    --financial-input-portal-amount-control-max: calc(
        var(--financial-input-portal-value-max) + var(--financial-input-portal-stepper-col) + 2px
    );
    --financial-input-portal-border: var(--color-border, #d2dee8);
    --financial-input-portal-value-size: 0.8125rem;
    --financial-input-portal-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    /* Light manage UI: white chrome on cream panels (not --color-surface beige) */
    --financial-input-portal-value-bg: #fff;
    --financial-input-portal-btn-bg: #fff;
    --financial-input-portal-btn-bg-hover: #f3f4f6;
}

/* Main container for the financial input control */
.financial-input {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-family: var(--font-mono);
    background: #1a1a1a;
    padding: 1px 2px;
    border-radius: var(--radius-sm);
    border: 1px solid #333;
    transition: border-color 0.2s;
}

.financial-input:focus-within {
    border-color: #ff6b00;
    box-shadow: 0 0 0 2px rgba(255, 107, 0, 0.1);
}

/* Decrease controls on the left */
.financial-input__decrease {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Increase controls on the right */
.financial-input__increase {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Individual control buttons */
.financial-input__btn {
    background: #2a2a2a;
    border: 1px solid #444;
    color: #aaa;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    padding: 4px 4px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: var(--font-mono);
    min-width: 44px;
    text-align: center;
    user-select: none;
    white-space: nowrap;
}

.financial-input__btn:hover:not(:disabled) {
    background: #3a3a3a;
    border-color: #555;
    color: #fff;
}

.financial-input__btn:active:not(:disabled) {
    background: #1a1a1a;
    transform: scale(0.95);
}

.financial-input__btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Decrease buttons - red accent */
.financial-input__btn--decrease {
    color: #ff6b6b;
}

.financial-input__btn--decrease:hover:not(:disabled) {
    background: #3a2a2a;
    border-color: #ff6b6b;
    color: #ff8888;
}

/* Increase buttons - green accent */
.financial-input__btn--increase {
    color: #51cf66;
}

.financial-input__btn--increase:hover:not(:disabled) {
    background: #2a3a2a;
    border-color: #51cf66;
    color: #6fe081;
}

/* Value display/input area */
.financial-input__value {
    width: 120px;
    min-width: 120px;
    max-width: 120px;
    background: #000;
    border: 1px solid #333;
    color: #fff;
    font-family: var(--font-mono);
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    padding: 8px 10px;
    border-radius: 3px;
    text-align: right;
    outline: none;
    transition: all 0.2s;
}

.financial-input__value:focus {
    border-color: #ff6b00;
    background: #0a0a0a;
}

.financial-input__value::placeholder {
    color: #444;
}

/* Percentage variant - sized for "100.0%" */
.financial-input--percentage .financial-input__value {
    width: 87px;
    min-width: 87px;
    max-width: 87px;
}

/* Light theme — portal manage UI (loan calc, deal model edit, apply) */
.financial-input--light {
    align-items: stretch;
    gap: 2px;
    background: transparent;
    border-color: transparent;
    padding: 0;
}

.financial-input--light .financial-input__btn {
    padding: 0 0.25rem;
    font-size: var(--text-xs);
    flex: 1 1 auto;
    min-height: 0;
    min-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    background: var(--financial-input-portal-btn-bg, #fff);
    border: 1px solid var(--financial-input-portal-border, #d1d5db);
    border-radius: var(--radius-sm);
    color: #6b7280;
    box-shadow: var(--shadow-1);
}

.financial-input--light .financial-input__btn:hover:not(:disabled) {
    background: var(--financial-input-portal-btn-bg-hover, #f3f4f6);
    border-color: #9ca3af;
    color: #111827;
}

.financial-input--light .financial-input__btn--decrease {
    color: var(--color-danger, #b91c1c);
}

.financial-input--light .financial-input__btn--decrease:hover:not(:disabled) {
    border-color: var(--color-danger, #dc2626);
    color: #b91c1c;
}

.financial-input--light .financial-input__btn--increase {
    color: var(--color-success, #0f6b3f);
}

.financial-input--light .financial-input__btn--increase:hover:not(:disabled) {
    border-color: var(--color-success, #059669);
    color: #047857;
}

.financial-input--light .financial-input__value {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    max-width: none;
    height: var(--financial-input-portal-control-height, 2rem);
    min-height: var(--financial-input-portal-control-height, 2rem);
    padding: 0.2rem 0.45rem;
    font-family: var(--financial-input-portal-font-mono);
    font-size: var(--financial-input-portal-value-size, 0.8125rem);
    font-weight: var(--weight-semibold);
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
    text-align: right;
    background: var(--financial-input-portal-value-bg, #fff);
    border: 1px solid var(--financial-input-portal-border, #d1d5db);
    border-radius: var(--radius-md);
    color: var(--color-text, #14283c);
    box-sizing: border-box;
}

.financial-input--light .financial-input__value:focus {
    border-color: #0ea5e9;
    background: var(--financial-input-portal-btn-bg-hover, #f9fafb);
}

.financial-input--light.financial-input--percentage .financial-input__value {
    min-width: 4.25rem;
}

/* Readonly state */
.financial-input--readonly .financial-input__value {
    background: #1a1a1a;
    color: #888;
    cursor: not-allowed;
}

.financial-input--light.financial-input--readonly .financial-input__value {
    background: #e5e7eb;
    color: #6b7280;
}

/* Compact size variant */
.financial-input--compact {
    padding: 2px 4px;
}

.financial-input--compact .financial-input__btn {
    font-size: var(--text-xs);
    padding: 3px 6px;
    min-width: 40px;
}

.financial-input--compact .financial-input__value {
    font-size: var(--text-xs);
    padding: 6px 8px;
    width: 100px;
    min-width: 100px;
    max-width: 100px;
}

/* Large size variant */
.financial-input--large {
    padding: 2px 4px;
}

.financial-input--large .financial-input__btn {
    font-size: var(--text-xs);
    padding: 6px 10px;
    min-width: 52px;
}

.financial-input--large .financial-input__value {
    font-size: var(--text-base);
    padding: 9px 12px;
    width: 130px;
    min-width: 130px;
    max-width: 130px;
}

/* Error state */
.financial-input--error {
    border-color: #dc2626;
}

.financial-input--error .financial-input__value {
    border-color: #dc2626;
    background: #1a0a0a;
}

.financial-input--light.financial-input--error .financial-input__value {
    border-color: #dc2626;
    background: #fef2f2;
}

/* Disabled state */
.financial-input--disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.financial-input--disabled .financial-input__btn {
    pointer-events: none;
}

.financial-input--disabled .financial-input__value {
    cursor: not-allowed;
}

/* Right-only: value | stacked +/- steppers (portal light standard) */
.financial-input--light.financial-input--right-only-mode {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--financial-input-portal-stepper-col, 2.9rem);
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.financial-input--light.financial-input--right-only-mode .financial-input__value {
    grid-column: 1;
    width: 100%;
}

.financial-input--light.financial-input--right-only-mode .financial-input__decrease {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    border: none !important;
}

.financial-input--light.financial-input--right-only-mode .financial-input__increase {
    grid-column: 2;
    width: var(--financial-input-portal-stepper-col, 2.9rem);
    height: var(--financial-input-portal-control-height, 2rem);
    min-height: var(--financial-input-portal-control-height, 2rem);
    flex-direction: column;
    justify-content: space-between;
    gap: 1px;
    box-sizing: border-box;
}

/* Dark / legacy right-only (both-sides layout collapsed) */
.financial-input--right-only-mode:not(.financial-input--light) .financial-input__decrease {
    display: none !important;
}

.financial-input--right-only-mode:not(.financial-input--light) .financial-input__increase {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}

/* Portal manage UI — dark theme (translucent chrome; never white steppers) */
body.theme-dark {
    --financial-input-portal-value-bg: rgba(0, 0, 0, 0.2);
    --financial-input-portal-btn-bg: rgba(255, 255, 255, 0.08);
    --financial-input-portal-btn-bg-hover: rgba(255, 255, 255, 0.12);
}

body.theme-dark .financial-input--light .financial-input__value {
    background: var(--financial-input-portal-value-bg);
    border-color: var(--color-border);
    color: var(--color-text);
}

body.theme-dark .financial-input--light .financial-input__value:focus {
    background: rgba(0, 0, 0, 0.28);
    border-color: var(--color-border);
}

body.theme-dark .financial-input--light .financial-input__btn {
    background: var(--financial-input-portal-btn-bg);
    border-color: var(--color-border);
    color: var(--color-text-muted);
    box-shadow: none;
}

body.theme-dark .financial-input--light .financial-input__btn:hover:not(:disabled) {
    background: var(--financial-input-portal-btn-bg-hover);
    border-color: var(--color-border);
    color: var(--color-text);
}

body.theme-dark .financial-input--light .financial-input__btn--decrease {
    color: #f87171;
}

body.theme-dark .financial-input--light .financial-input__btn--decrease:hover:not(:disabled) {
    border-color: #f87171;
    color: #fca5a5;
}

body.theme-dark .financial-input--light .financial-input__btn--increase {
    color: #4ade80;
}

body.theme-dark .financial-input--light .financial-input__btn--increase:hover:not(:disabled) {
    border-color: #4ade80;
    color: #86efac;
}

