/* Improved Form Elements for Hindi Interactive Lesson */

/* Custom Select */
.custom-select {
    display: block;
    width: 100%;
    height: var(--form-input-height-md);
    padding: 0 var(--form-spacing-md);
    font-family: var(--form-font-family);
    font-size: var(--form-font-size-md);
    line-height: var(--form-line-height);
    color: var(--form-text-color);
    background-color: var(--form-bg-color);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='8' height='12' viewBox='0 0 8 12'%3e%3cpath fill='%23343a40' d='M2 0L0 2h4L2 0zm0 12l2-2H0l2 2z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right var(--form-spacing-md) center;
    background-size: 8px 12px;
    border: 1px solid var(--form-border-color);
    border-radius: var(--form-border-radius-md);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: border-color var(--form-transition-duration), box-shadow var(--form-transition-duration);
}

.custom-select:focus {
    border-color: var(--form-border-focus-color);
    outline: 0;
    box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.25);
}

.custom-select:disabled {
    background-color: var(--form-disabled-bg-color);
    color: var(--form-disabled-text-color);
    cursor: not-allowed;
}

/* Custom Checkbox and Radio */
.custom-control {
    position: relative;
    z-index: 1;
    display: block;
    min-height: calc(var(--form-line-height) * 1em);
    padding-left: 1.5rem;
}

.custom-control-input {
    position: absolute;
    left: 0;
    z-index: -1;
    width: 1rem;
    height: 1.5rem;
    opacity: 0;
}

.custom-control-label {
    position: relative;
    margin-bottom: 0;
    vertical-align: top;
    cursor: pointer;
}

.custom-control-label::before {
    position: absolute;
    top: calc((var(--form-line-height) * 1em - 1rem) / 2);
    left: -1.5rem;
    display: block;
    width: 1rem;
    height: 1rem;
    content: "";
    background-color: var(--form-bg-color);
    border: 1px solid var(--form-border-color);
    transition: background-color var(--form-transition-duration), border-color var(--form-transition-duration), box-shadow var(--form-transition-duration);
}

.custom-control-label::after {
    position: absolute;
    top: calc((var(--form-line-height) * 1em - 1rem) / 2);
    left: -1.5rem;
    display: block;
    width: 1rem;
    height: 1rem;
    content: "";
    background: no-repeat 50% / 50% 50%;
}

/* Custom Checkbox */
.custom-checkbox .custom-control-label::before {
    border-radius: var(--form-border-radius-sm);
}

.custom-checkbox .custom-control-input:checked ~ .custom-control-label::before {
    background-color: var(--form-border-focus-color);
    border-color: var(--form-border-focus-color);
}

.custom-checkbox .custom-control-input:checked ~ .custom-control-label::after {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3e%3cpath fill='%23fff' d='M6.564.75l-3.59 3.612-1.538-1.55L0 4.26l2.974 2.99L8 2.193z'/%3e%3c/svg%3e");
}

/* Custom Radio */
.custom-radio .custom-control-label::before {
    border-radius: 50%;
}

.custom-radio .custom-control-input:checked ~ .custom-control-label::before {
    background-color: var(--form-border-focus-color);
    border-color: var(--form-border-focus-color);
}

.custom-radio .custom-control-input:checked ~ .custom-control-label::after {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
}

/* Focus states */
.custom-control-input:focus ~ .custom-control-label::before {
    box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.25);
}

/* Disabled state */
.custom-control-input:disabled ~ .custom-control-label {
    color: var(--form-disabled-text-color);
    cursor: not-allowed;
}

.custom-control-input:disabled ~ .custom-control-label::before {
    background-color: var(--form-disabled-bg-color);
}

/* Custom Range Input */
.custom-range {
    width: 100%;
    height: 1.5rem;
    padding: 0;
    background-color: transparent;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.custom-range:focus {
    outline: none;
}

.custom-range::-webkit-slider-thumb {
    width: 1rem;
    height: 1rem;
    margin-top: -0.25rem;
    background-color: var(--form-border-focus-color);
    border: 0;
    border-radius: 50%;
    -webkit-appearance: none;
    appearance: none;
    transition: background-color var(--form-transition-duration), border-color var(--form-transition-duration), box-shadow var(--form-transition-duration);
}

.custom-range::-webkit-slider-runnable-track {
    width: 100%;
    height: 0.5rem;
    color: transparent;
    cursor: pointer;
    background-color: var(--form-border-color);
    border-radius: var(--form-border-radius-lg);
}

.custom-range::-moz-range-thumb {
    width: 1rem;
    height: 1rem;
    background-color: var(--form-border-focus-color);
    border: 0;
    border-radius: 50%;
    -moz-appearance: none;
    appearance: none;
    transition: background-color var(--form-transition-duration), border-color var(--form-transition-duration), box-shadow var(--form-transition-duration);
}

.custom-range::-moz-range-track {
    width: 100%;
    height: 0.5rem;
    color: transparent;
    cursor: pointer;
    background-color: var(--form-border-color);
    border-radius: var(--form-border-radius-lg);
}

/* Text Area */
textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* Input Groups */
.input-group {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    width: 100%;
}

.input-group > .form-control,
.input-group > .custom-select {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
    margin-bottom: 0;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: var(--form-spacing-sm) var(--form-spacing-md);
    font-size: var(--form-font-size-md);
    font-weight: 400;
    line-height: var(--form-line-height);
    color: var(--form-text-color);
    text-align: center;
    white-space: nowrap;
    background-color: var(--form-disabled-bg-color);
    border: 1px solid var(--form-border-color);
    border-radius: var(--form-border-radius-md);
}

.input-group-prepend,
.input-group-append {
    display: flex;
}

.input-group-prepend .input-group-text {
    border-right: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group-append .input-group-text {
    border-left: 0;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group > .form-control:not(:last-child),
.input-group > .custom-select:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group > .form-control:not(:first-child),
.input-group > .custom-select:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}
