/* ============================================================
   itmr-fields.css — ITMR Header Fields V1
   Global styles for ItmrHeaderFieldsPanel and DropdownWithFallback.
   Global scope intentional — must reach inside child components.
   Linked from App.razor.
   ============================================================ */

/* ── Panel container ─────────────────────────────────────────── */

.itmr-panel {
    display: block;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: visible;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin: 16px 0;
    padding: 16px 20px;
    width: 100%;
}

.itmr-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #1a3c6e;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
}

.itmr-panel-badge {
    margin-left: auto;
    background: #dbeafe;
    color: #1e40af;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.itmr-panel-body {
    display: block;
    width: 100%;
}

.itmr-fields-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    width: 100%;
}

/* ── Field wrapper ───────────────────────────────────────────── */

.itmr-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.itmr-field-label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.itmr-input {
    padding: 7px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    width: 100%;
    background: white;
    color: #2c3e5a;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.itmr-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}

.itmr-input:disabled {
    background: #f8fafc;
    color: #94a3b8;
    cursor: default;
}

.itmr-input-sm {
    padding: 5px 8px;
    font-size: 13px;
}

/* ── Source color-coding ─────────────────────────────────────── */
/*   Applied to .itmr-field wrapper; selectors reach into the    */
/*   child input, select, and DropdownWithFallback root div.     */

.itmr-field.itmr-source-extracted input,
.itmr-field.itmr-source-extracted select,
.itmr-field.itmr-source-extracted .dfb-wrapper,
.itmr-field.itmr-source-extracted .dfb-search,
.itmr-field.itmr-source-extracted .dfb-input {
    border: 2px solid #2563eb !important;   /* blue — extracted */
}

.itmr-field.itmr-source-derived input,
.itmr-field.itmr-source-derived select,
.itmr-field.itmr-source-derived .dfb-wrapper,
.itmr-field.itmr-source-derived .dfb-search,
.itmr-field.itmr-source-derived .dfb-input {
    border: 2px solid #16a34a !important;   /* green — derived  */
}

.itmr-field.itmr-source-manual input,
.itmr-field.itmr-source-manual select {
    /* no override — default border */
}

/* ── Source badges (next to labels) ─────────────────────────── */

.itmr-source-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 4px;
    vertical-align: middle;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.itmr-source-badge.extracted { background: #dbeafe; color: #1e40af; }
.itmr-source-badge.derived   { background: #dcfce7; color: #166534; }
.itmr-source-badge.manual    { background: #f3f4f6; color: #4b5563; }

/* ── Hint / error messages ───────────────────────────────────── */

.itmr-derived-hint {
    font-size: 11px;
    color: #64748b;
    font-style: italic;
    margin-top: 2px;
}

.itmr-field-error input {
    border-color: #dc2626 !important;
}

.itmr-input-error {
    border-color: #dc2626 !important;
}

.itmr-error-msg {
    font-size: 0.72rem;
    color: #dc2626;
    margin-top: 2px;
}

.itmr-ok-msg {
    font-size: 0.72rem;
    color: #16a34a;
    margin-top: 2px;
}

/* ── Weight row ──────────────────────────────────────────────── */

.itmr-weight-row .itmr-weight-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.itmr-weight-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.itmr-kgm-display {
    font-size: 0.72rem;
    color: #64748b;
    margin-top: 3px;
}

/* ── DropdownWithFallback wrapper ────────────────────────────── */

.dfb-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.dfb-select-wrap {
    position: relative;
    flex: 1;
}

.dfb-search {
    width: 100%;
    padding: 0.3rem 0.5rem;
    font-size: 0.85rem;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    background: #fff;
    color: #2c3e5a;
}

.dfb-input {
    width: 100%;
    padding: 0.3rem 0.5rem;
    font-size: 0.85rem;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    background: #fff;
    color: #2c3e5a;
}

.dfb-dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 200;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0 0 6px 6px;
    max-height: 180px;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 2px 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.dfb-dropdown-item {
    padding: 5px 10px;
    font-size: 0.83rem;
    cursor: pointer;
    color: #2c3e5a;
    transition: background 0.1s;
}

.dfb-dropdown-item:hover,
.dfb-dropdown-item.dfb-selected {
    background: #eff6ff;
    color: #1d4ed8;
}

/* ── Freetext override button (pencil) ───────────────────────── */
/*   Sits inline to the right of the search input.               */
/*   24×24, icon-only, visible only in dropdown mode.            */

.dfb-freetext-btn {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 13px;
    line-height: 1;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #f8fafc;
    color: #64748b;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.dfb-freetext-btn:hover {
    background: #e0f2fe;
    color: #0284c7;
    border-color: #7dd3fc;
}

.dfb-tooltip-anchor {
    font-size: 11px;
    color: #94a3b8;
    cursor: default;
    flex-shrink: 0;
}
