/**
 * Webapp Form Components
 * Styled form inputs, selects, textareas, and form utilities
 */

/* ═══════════════════════════════════════════════════════════════
   BASE FORM CONTROLS
   ═══════════════════════════════════════════════════════════════ */

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
select,
textarea {
    border: 2px solid var(--input-border, #ced4da);
    border-radius: var(--radius-md, 10px);
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
    background: var(--input-bg, #ffffff);
    color: var(--c-text);
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--input-focus-border, #dc3545);
    box-shadow: 0 0 0 0.2rem var(--input-focus-shadow, rgba(220, 53, 69, 0.25));
}

/* ═══════════════════════════════════════════════════════════════
   INFO ROWS (Label-Value Pairs)
   ═══════════════════════════════════════════════════════════════ */

.ir {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-md, 10px);
    background: var(--c-row);
    margin-bottom: 0.4rem;
    transition: background 0.2s;
    border-left: 3px solid transparent;
}

.ir:hover {
    background: var(--c-row-h);
    border-color: var(--brand-primary, #dc3545);
}

.ir .lbl {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--c-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    min-width: 76px;
    flex-shrink: 0;
    margin-top: 0.18rem;
}

.ir .val {
    font-size: 0.9rem;
    color: var(--c-text);
    flex: 1;
    word-break: break-word;
}

/* ═══════════════════════════════════════════════════════════════
   TOGGLE SWITCHES
   ═══════════════════════════════════════════════════════════════ */

.tog {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    background: var(--c-row);
    border-radius: var(--radius-sm, 8px);
    margin-top: 0.4rem;
}

.tog .tlbl {
    font-size: 0.82rem;
    flex: 1;
    color: var(--c-text);
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--brand-primary, #dc3545);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* ═══════════════════════════════════════════════════════════════
   FORM GROUPS
   ═══════════════════════════════════════════════════════════════ */

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--c-text);
    font-size: 0.9rem;
}

.form-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--c-muted);
}

.form-error {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: #dc3545;
}

/* ═══════════════════════════════════════════════════════════════
   CUSTOM SELECT
   ═══════════════════════════════════════════════════════════════ */

.custom-select {
    position: relative;
}

.custom-select select {
    appearance: none;
    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='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

[data-bs-theme="dark"] .custom-select select,
body.dark-mode .custom-select select {
    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='%23fff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

/* ═══════════════════════════════════════════════════════════════
   CHECKBOXES & RADIOS
   ═══════════════════════════════════════════════════════════════ */

.custom-checkbox,
.custom-radio {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    cursor: pointer;
}

.custom-checkbox input[type="checkbox"],
.custom-radio input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--brand-primary, #dc3545);
}

.custom-checkbox label,
.custom-radio label {
    cursor: pointer;
    margin: 0;
    font-weight: 400;
}

/* ═══════════════════════════════════════════════════════════════
   INPUT GROUPS
   ═══════════════════════════════════════════════════════════════ */

.input-group {
    display: flex;
    gap: 0.5rem;
}

.input-group .form-control {
    flex: 1;
}

.input-group-prepend,
.input-group-append {
    display: flex;
    align-items: center;
}

.input-group-text {
    padding: 0.75rem 1rem;
    background: var(--c-surface);
    border: 2px solid var(--input-border, #ced4da);
    border-radius: var(--radius-md, 10px);
    color: var(--c-muted);
    font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════════
   SEARCH INPUT
   ═══════════════════════════════════════════════════════════════ */

.search-input {
    position: relative;
}

.search-input input {
    padding-left: 3rem;
}

.search-input::before {
    content: '\f002';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--c-muted);
    pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════
   FORM STATES
   ═══════════════════════════════════════════════════════════════ */

.form-control.is-valid,
input.is-valid,
select.is-valid,
textarea.is-valid {
    border-color: #28a745;
}

.form-control.is-invalid,
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
    border-color: #dc3545;
}

.valid-feedback {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: #28a745;
}

.invalid-feedback {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: #dc3545;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 576px) {
    .form-control,
    input,
    select,
    textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}
