/* ==========================================================================
   TBB LD50 / Probit Analysis Calculator — Calculator-specific styles
   Common styles (variables, buttons, cards, info) in tbb-calculators-common.css
   ========================================================================== */

/* ── Small button modifier ───────────────────────────────────────────────── */
.tbb-ld50-calculator .tbb-btn--sm {
	padding:        .45rem 1rem;
	font-size:      1.15rem;
	text-transform: none;
	letter-spacing: 0;
}

/* ── Shared input / select styles ────────────────────────────────────────── */
.tbb-ld50-calculator .tbb-ld50-input,
.tbb-ld50-calculator .tbb-ld50-select {
	display:       block;
	width:         100% !important;
	max-width:     100% !important;
	min-width:     0;
	box-sizing:    border-box;
	padding:       .875rem 1.1rem;
	font-size:     1.3rem;
	line-height:   1.6;
	min-height:    52px;
	color:         var(--tbb-text);
	background:    var(--tbb-bg);
	border:        1.5px solid var(--tbb-border);
	border-radius: var(--tbb-radius-sm);
	transition:    border-color var(--tbb-transition), box-shadow var(--tbb-transition);
	font-family:   var(--tbb-font);
}

.tbb-ld50-calculator .tbb-ld50-input::-webkit-inner-spin-button,
.tbb-ld50-calculator .tbb-ld50-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.tbb-ld50-calculator .tbb-ld50-input { -moz-appearance: textfield; }

.tbb-ld50-calculator .tbb-ld50-select {
	background-image:    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
	background-repeat:   no-repeat;
	background-position: right .75rem center;
	padding-right:       2.25rem;
	-webkit-appearance:  none;
	-moz-appearance:     none;
	appearance:          none;
	cursor:              pointer;
}

.tbb-ld50-calculator .tbb-ld50-input:focus,
.tbb-ld50-calculator .tbb-ld50-select:focus {
	outline:      none;
	border-color: var(--tbb-primary);
	box-shadow:   0 0 0 3px rgba(37, 99, 235, .15);
}

/* ── Options row ─────────────────────────────────────────────────────────── */
.tbb-ld50-options-row {
	display:       flex;
	flex-wrap:     wrap;
	gap:           1rem;
	margin-bottom: 1.25rem;
}

.tbb-ld50-opt-field {
	flex:          1;
	min-width:     180px;
	margin-bottom: 0 !important;
}

/* ── Info icon + tooltip ─────────────────────────────────────────────────── */
.tbb-ld50-tooltip-wrap {
	position:       relative;
	display:        inline-block;
	margin-left:    .35rem;
	vertical-align: middle;
}

.tbb-ld50-info-icon {
	color:       var(--tbb-primary);
	font-size:   1.3rem;
	cursor:      pointer;
	line-height: 1;
	user-select: none;
}

.tbb-ld50-tooltip {
	visibility:     hidden;
	opacity:        0;
	position:       absolute;
	bottom:         calc(100% + 10px);
	left:           50%;
	transform:      translateX(-50%);
	width:          300px;
	background:     #1e293b;
	color:          #f1f5f9;
	font-size:      1.2rem;
	font-weight:    400;
	line-height:    1.55;
	padding:        .65rem .9rem;
	border-radius:  7px;
	z-index:        200;
	pointer-events: none;
	transition:     opacity .15s, visibility .15s;
	white-space:    normal;
}

.tbb-ld50-tooltip::after {
	content:          '';
	position:         absolute;
	top:              100%;
	left:             50%;
	transform:        translateX(-50%);
	border:           6px solid transparent;
	border-top-color: #1e293b;
}

.tbb-ld50-tooltip-wrap:hover .tbb-ld50-tooltip,
.tbb-ld50-tooltip-wrap:focus-within .tbb-ld50-tooltip,
.tbb-ld50-tooltip-wrap.tbb-tooltip-open .tbb-ld50-tooltip {
	visibility: visible;
	opacity:    1;
}

/* ── Model row (NLR only) ────────────────────────────────────────────────── */
.tbb-ld50-model-row {
	margin-bottom: 1rem;
}

/* ── Abbott's correction panel ───────────────────────────────────────────── */
.tbb-ld50-abbott-panel {
	background:    var(--tbb-bg-subtle);
	border:        1.5px solid var(--tbb-border);
	border-radius: var(--tbb-radius-sm);
	padding:       1rem 1.25rem .5rem;
	margin-bottom: 1.25rem;
}

.tbb-ld50-abbott-panel .tbb-ld50-options-row {
	margin-bottom: 0;
}

.tbb-ld50-abbott-title {
	font-size:     1.3rem;
	font-weight:   600;
	color:         var(--tbb-text);
	margin:        0 0 .75rem;
}

.tbb-ld50-abbott-desc {
	font-size:   1.2rem;
	color:       var(--tbb-text-muted);
	margin:      0 0 .75rem;
	line-height: 1.5;
}

/* ── Abbott toggle checkbox ──────────────────────────────────────────────── */
.tbb-ld50-abbott-toggle-wrap {
	display:     flex;
	align-items: center;
	gap:         .6rem;
	margin-bottom: .75rem;
	font-size:   1.3rem;
	color:       var(--tbb-text);
	cursor:      pointer;
	user-select: none;
}

.tbb-ld50-abbott-toggle-wrap input[type="checkbox"] {
	width:  18px;
	height: 18px;
	cursor: pointer;
	accent-color: var(--tbb-primary);
}

/* ── Table toolbar ───────────────────────────────────────────────────────── */
.tbb-ld50-table-toolbar {
	display:         flex;
	align-items:     center;
	justify-content: space-between;
	flex-wrap:       wrap;
	gap:             .5rem;
	margin-bottom:   .75rem;
}

.tbb-ld50-table-label {
	font-size:   1.3rem;
	font-weight: 600;
	color:       var(--tbb-text);
	margin:      0 0 .6rem;
}

.tbb-ld50-table-hint {
	font-size:   1.2rem;
	font-weight: 400;
	color:       var(--tbb-text-muted);
}

.tbb-ld50-table-actions {
	display:     flex;
	gap:         .5rem;
	flex-wrap:   wrap;
	align-items: center;
}

/* ── Paste modal ─────────────────────────────────────────────────────────── */
.tbb-ld50-paste-modal {
	background:    var(--tbb-bg-subtle);
	border:        1.5px solid var(--tbb-border);
	border-radius: var(--tbb-radius-sm);
	padding:       1.25rem;
	margin-bottom: 1rem;
}

.tbb-ld50-paste-instructions {
	font-size:     1.3rem;
	color:         var(--tbb-text);
	margin:        0 0 .75rem;
}

.tbb-ld50-paste-area {
	display:       block;
	width:         100%;
	box-sizing:    border-box;
	padding:       .75rem 1rem;
	font-family:   var(--tbb-font-mono);
	font-size:     1.2rem;
	line-height:   1.6;
	color:         var(--tbb-text);
	background:    var(--tbb-bg);
	border:        1.5px solid var(--tbb-border);
	border-radius: var(--tbb-radius-sm);
	resize:        vertical;
	margin-bottom: .75rem;
	transition:    border-color var(--tbb-transition);
}

.tbb-ld50-paste-area:focus {
	outline:      none;
	border-color: var(--tbb-primary);
	box-shadow:   0 0 0 3px rgba(37, 99, 235, .15);
}

.tbb-ld50-paste-actions { display: flex; gap: .5rem; }

/* ── Data table ──────────────────────────────────────────────────────────── */
.tbb-ld50-table-wrap {
	overflow-x:    auto;
	margin-bottom: 1.25rem;
}

.tbb-ld50-table {
	width:           100%;
	border-collapse: collapse;
	font-size:       1.3rem;
}

.tbb-ld50-table th {
	text-align:    left;
	padding:       .6rem .75rem;
	font-weight:   600;
	color:         var(--tbb-text-muted);
	border-bottom: 2px solid var(--tbb-border);
	white-space:   nowrap;
}

.tbb-ld50-table th.tbb-ld50-th-pct {
	color: var(--tbb-text-muted);
}

.tbb-ld50-table td {
	padding:       .35rem .5rem;
	border-bottom: 1px solid var(--tbb-border);
}

.tbb-ld50-table td:last-child {
	width:      40px;
	text-align: center;
}

/* Editable table cell inputs */
.tbb-ld50-cell {
	display:       block;
	width:         100% !important;
	max-width:     100% !important;
	min-width:     0;
	box-sizing:    border-box;
	padding:       .55rem .75rem;
	font-size:     1.3rem;
	color:         var(--tbb-text);
	background:    var(--tbb-bg);
	border:        1.5px solid var(--tbb-border);
	border-radius: 6px;
	font-family:   var(--tbb-font);
	transition:    border-color var(--tbb-transition), box-shadow var(--tbb-transition);
	-moz-appearance: textfield;
}

.tbb-ld50-cell::-webkit-inner-spin-button,
.tbb-ld50-cell::-webkit-outer-spin-button { -webkit-appearance: none; }

.tbb-ld50-cell:focus {
	outline:      none;
	border-color: var(--tbb-primary);
	box-shadow:   0 0 0 2px rgba(37, 99, 235, .15);
}

/* Read-only % mortality cell */
.tbb-ld50-pct-cell {
	font-size:   1.25rem;
	font-weight: 500;
	color:       var(--tbb-text-muted);
	background:  var(--tbb-bg-subtle);
	border:      1.5px solid var(--tbb-border);
	border-radius: 6px;
	padding:     .55rem .75rem;
	min-width:   70px;
	white-space: nowrap;
	text-align:  right;
}

/* Delete button */
.tbb-ld50-del-row {
	background:    transparent;
	border:        none;
	color:         var(--tbb-text-muted);
	font-size:     1.4rem;
	cursor:        pointer;
	line-height:   1;
	padding:       .2rem .4rem;
	border-radius: 4px;
	transition:    background var(--tbb-transition), color var(--tbb-transition);
}

.tbb-ld50-del-row:hover {
	background: var(--tbb-danger-light);
	color:      var(--tbb-danger);
}

.tbb-ld50-add-row-btn { margin-top: .5rem; }

/* ── Results grid ────────────────────────────────────────────────────────── */
.tbb-ld50-results-grid {
	display:               grid;
	grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
	gap:                   .875rem;
	margin-bottom:         1.25rem;
}

.tbb-ld50-stat-card {
	display:        flex;
	flex-direction: column;
	align-items:    center;
	text-align:     center;
	padding:        1rem .75rem .85rem;
	background:     var(--tbb-bg-subtle);
	border:         1.5px solid var(--tbb-border);
	border-radius:  var(--tbb-radius-sm);
}

.tbb-ld50-stat-card--primary {
	background:   var(--tbb-primary-light);
	border-color: #bfdbfe;
}

.tbb-ld50-stat-card--ci {
	background:   #f0fdf4;
	border-color: #bbf7d0;
}

.tbb-ld50-stat-label {
	font-size:      1.15rem;
	font-weight:    600;
	color:          var(--tbb-text-muted);
	text-transform: uppercase;
	letter-spacing: .04em;
	margin-bottom:  .4rem;
}

.tbb-ld50-stat-value {
	font-size:   1.75rem;
	font-weight: 700;
	color:       var(--tbb-text);
	line-height: 1.15;
	word-break:  break-all;
}

.tbb-ld50-stat-card--primary .tbb-ld50-stat-value {
	font-size: 2rem;
	color:     var(--tbb-primary);
}

.tbb-ld50-stat-card--ci .tbb-ld50-stat-value {
	font-size: 1.6rem;
	color:     var(--tbb-success);
}

.tbb-ld50-stat-unit {
	font-size:  1.2rem;
	color:      var(--tbb-text-muted);
	margin-top: .2rem;
}

/* ── Fitted equation + fit quality ──────────────────────────────────────── */
.tbb-ld50-equation {
	background:    var(--tbb-bg-subtle);
	border:        1px solid var(--tbb-border);
	border-radius: var(--tbb-radius-sm);
	padding:       1rem 1.25rem;
	font-size:     1.3rem;
	line-height:   1.6;
	margin-bottom: 1.25rem;
}

.tbb-ld50-equation p { margin: 0 0 .35rem; }
.tbb-ld50-equation p:last-child { margin-bottom: 0; }

.tbb-ld50-fit-ok   { color: var(--tbb-success); font-weight: 600; }
.tbb-ld50-fit-warn { color: var(--tbb-warning);  font-weight: 600; }
.tbb-ld50-fit-note { color: var(--tbb-text-muted); font-size: 1.2rem; }

/* ── Chart ───────────────────────────────────────────────────────────────── */
.tbb-ld50-chart-wrap {
	position:      relative;
	background:    var(--tbb-bg);
	border:        1.5px solid var(--tbb-border);
	border-radius: var(--tbb-radius-sm);
	padding:       1rem;
	margin-bottom: 1.5rem;
	max-height:    420px;
}

.tbb-ld50-chart-wrap canvas { max-height: 380px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media ( max-width: 600px ) {
	.tbb-ld50-options-row    { flex-direction: column; gap: .5rem; }
	.tbb-ld50-opt-field      { min-width: 0; }
	.tbb-ld50-table-toolbar  { flex-direction: column; align-items: flex-start; }
	.tbb-ld50-results-grid   { grid-template-columns: repeat(2, 1fr); }
	.tbb-ld50-stat-card--primary .tbb-ld50-stat-value { font-size: 1.5rem; }
}

@media ( max-width: 360px ) {
	.tbb-ld50-results-grid { grid-template-columns: 1fr; }
}
