/**
 * Shared primary-themed inputs & selects — used across Harvest Mills forms
 */
:root {
    --primary: #2f5d3a;
    --primary-dark: #1e3f28;
    --primary-light: #3f7a4d;
    --accent: #c9922a;
    --text: #1a241c;
    --white: #ffffff;
    --input-border: rgba(47, 93, 58, 0.3);
    --input-border-hover: rgba(47, 93, 58, 0.5);
    --input-bg: rgba(47, 93, 58, 0.05);
    --input-ring: rgba(47, 93, 58, 0.18);
}

/* Stop page-level horizontal scroll from open Select2 menus */
html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

.form-group label,
.form-label {
    color: var(--primary-dark);
    font-weight: 600;
}

.input-wrap input,
.form-control,
.form-select,
textarea.form-control,
select.form-select {
    border: 1.5px solid var(--input-border);
    background-color: var(--input-bg);
    color: var(--primary-dark);
    border-radius: 8px;
    min-height: 42px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
    max-width: 100%;
}

textarea.form-control {
    min-height: 96px;
}

.input-wrap input:hover:not(:disabled):not([readonly]),
.form-control:hover:not(:disabled):not([readonly]),
.form-select:hover:not(:disabled),
textarea.form-control:hover:not(:disabled),
select.form-select:hover:not(:disabled) {
    border-color: var(--input-border-hover);
    background-color: rgba(47, 93, 58, 0.07);
}

.input-wrap input:focus,
.form-control:focus,
.form-select:focus,
textarea.form-control:focus,
select.form-select:focus {
    border-color: var(--primary);
    background-color: var(--white);
    box-shadow: 0 0 0 3px var(--input-ring);
    outline: none;
    color: var(--text);
}

.input-wrap input::placeholder,
.form-control::placeholder,
textarea.form-control::placeholder {
    color: rgba(47, 93, 58, 0.4);
}

.input-wrap input.input-readonly,
.form-control[readonly] {
    background-color: rgba(47, 93, 58, 0.1);
    border-color: rgba(47, 93, 58, 0.2);
    color: var(--primary);
    font-weight: 600;
    cursor: default;
}

.input-wrap:focus-within .input-icon {
    color: var(--primary);
}

.input-wrap:hover .input-icon {
    color: var(--primary-light);
}

/* Native select (before/alongside Select2) must not force wide layout */
select.select2,
select.form-select.select2 {
    width: 100% !important;
    max-width: 100% !important;
}

.select2-container {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    display: block;
}

/* Bootstrap columns default min-width:auto causes select2 to expand the row */
.row > [class*="col-"],
.section-card,
.form-card,
.form-group,
.form-wrapper {
    min-width: 0;
    max-width: 100%;
}

.select2-container .select2-selection--single {
    height: 42px;
    border-radius: 8px;
    overflow: hidden;
    max-width: 100%;
    box-sizing: border-box;
}

.select2-container--default .select2-selection--single {
    border: 1.5px solid var(--input-border);
    background-color: var(--input-bg);
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--primary-dark);
    line-height: 39px;
    padding-left: 12px;
    padding-right: 28px;
    font-size: 0.9375rem;
    overflow: hidden !important;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    box-sizing: border-box;
    display: block;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 40px;
    right: 6px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: var(--primary) transparent transparent transparent;
    margin-top: -2px;
}

.select2-container--default:hover .select2-selection--single {
    border-color: var(--input-border-hover);
    background-color: rgba(47, 93, 58, 0.07);
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--primary);
    background-color: var(--white);
    box-shadow: 0 0 0 3px var(--input-ring);
}

.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent var(--primary) transparent;
}

.select2-container--default.select2-container--disabled .select2-selection--single {
    background-color: rgba(47, 93, 58, 0.06);
    cursor: not-allowed;
}

/* Open menu shell (often appended to body with large inline width) */
body > .select2-container--open {
    z-index: 3000;
    max-width: calc(100vw - 16px) !important;
    box-sizing: border-box !important;
}

.select2-dropdown {
    border: 1.5px solid var(--input-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(30, 63, 40, 0.12);
    overflow-x: hidden;
    overflow-y: auto;
    box-sizing: border-box !important;
    max-width: 100% !important;
    /* width: 100% !important; */
}

.select2-results {
    max-width: 100%;
    overflow-x: hidden;
}

.select2-results__options {
    max-width: 100%;
}

.select2-results__option {
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
    max-width: 100%;
    box-sizing: border-box;
}

.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
    background-color: var(--primary);
}

.select2-container--default .select2-results__option--selected {
    background-color: rgba(47, 93, 58, 0.12);
    color: var(--primary-dark);
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1.5px solid var(--input-border);
    border-radius: 6px;
    background-color: var(--input-bg);
    color: var(--primary-dark);
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--input-ring);
    outline: none;
}

.select2-search--dropdown {
    padding: 8px;
    max-width: 100%;
    box-sizing: border-box;
}

.form-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.form-today-count {
    font-size: 0.9rem;
    color: var(--text-muted, #5f6f63);
    font-weight: 600;
}

.form-today-count strong {
    color: var(--primary, #2f5d3a);
}

.btn-form-close {
    margin-left: auto;
    border: 1px solid var(--border, #d8e2da);
    background: #fff;
    color: var(--primary, #2f5d3a);
    font-weight: 700;
    border-radius: 10px;
    padding: 8px 14px;
    min-height: 40px;
    cursor: pointer;
}

.btn-form-close:hover {
    background: rgba(47, 93, 58, 0.06);
}
