/* Input States and Helper Classes for Kabir Lesson */

/* ====== Input Status Classes ====== */

/* 1. Input with value */
.has-value {
    border-color: rgba(92, 64, 51, 0.4);
    background-color: rgba(255, 255, 255, 0.9);
}

/* 2. Valid input */
.is-valid {
    border-color: #4caf50;
    background-color: rgba(76, 175, 80, 0.05);
}

.is-valid:focus {
    border-color: #4caf50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

/* 3. Invalid input */
.is-invalid {
    border-color: #f44336;
    background-color: rgba(244, 67, 54, 0.05);
}

.is-invalid:focus {
    border-color: #f44336;
    box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.2);
}

/* 4. Warning input */
.has-warning {
    border-color: #ff9800;
    background-color: rgba(255, 152, 0, 0.05);
}

.has-warning:focus {
    border-color: #ff9800;
    box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.2);
}

/* 5. Required indicator */
.is-required label::after {
    content: " *";
    color: #f44336;
    font-weight: bold;
}

/* 6. Read-only input */
input[readonly],
textarea[readonly],
select[disabled] {
    background-color: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.8;
    border-color: rgba(0, 0, 0, 0.1);
}

/* 7. Active focus state */
.focus-active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(92, 64, 51, 0.2);
    transform: translateY(-2px);
}

/* 8. Value changed animation */
.value-changed {
    animation: highlight-change 1.5s ease;
}

@keyframes highlight-change {
    0%, 100% { background-color: transparent; }
    30% { background-color: rgba(92, 64, 51, 0.1); }
}

/* 9. Dropdown changed animation */
select.changed {
    animation: dropdown-change 1s ease;
}

@keyframes dropdown-change {
    0%, 100% { background-color: transparent; }
    30% { background-color: rgba(92, 64, 51, 0.1); }
}

/* ====== Input Group Layouts ====== */

/* 1. Horizontal form group */
.form-group-horizontal {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
}

.form-group-horizontal label {
    flex: 0 0 30%;
    margin-bottom: 0;
    text-align: right;
}

.form-group-horizontal .input-wrapper {
    flex: 1;
}

/* 2. Input with icon */
.input-with-icon {
    position: relative;
}

.input-with-icon input,
.input-with-icon select {
    padding-left: 40px;
}

.input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(92, 64, 51, 0.6);
    font-size: 1.1em;
}

/* 3. Input with character count */
.with-char-count {
    position: relative;
    margin-bottom: 25px;
}

.char-count {
    position: absolute;
    right: 10px;
    bottom: -25px;
    font-size: 0.85rem;
    color: rgba(0, 0, 0, 0.5);
    transition: color 0.3s ease;
}

.char-count-warning {
    color: #ff9800;
    font-weight: 500;
}

/* 4. Input group with prefix/suffix */
.input-group {
    display: flex;
    align-items: stretch;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0 15px;
    background-color: rgba(92, 64, 51, 0.05);
    border: 2px solid rgba(92, 64, 51, 0.15);
    font-size: 1rem;
}

.input-group-prepend .input-group-text {
    border-radius: var(--input-radius) 0 0 var(--input-radius);
    border-right: none;
}

.input-group-append .input-group-text {
    border-radius: 0 var(--input-radius) var(--input-radius) 0;
    border-left: none;
}

.input-group-prepend + input {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group input + .input-group-append {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

/* 5. Floating labels */
.float-label {
    position: relative;
    margin-top: 20px;
}

.float-label input,
.float-label textarea,
.float-label select {
    height: 56px;
    padding: 20px 16px 10px;
}

.float-label textarea {
    height: auto;
    min-height: 140px;
}

.float-label label {
    position: absolute;
    top: 20px;
    left: 16px;
    color: rgba(0, 0, 0, 0.5);
    transition: all 0.2s ease;
    pointer-events: none;
    margin: 0;
}

.float-label input:focus + label,
.float-label textarea:focus + label,
.float-label select:focus + label,
.float-label input.has-value + label,
.float-label textarea.has-value + label,
.float-label select.has-value + label {
    top: 7px;
    font-size: 0.8rem;
    color: var(--primary-color);
    font-weight: 500;
}

/* 6. Error messages */
.error-message {
    color: #f44336;
    font-size: 0.85rem;
    margin-top: 5px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 7. Success messages */
.success-message {
    color: #4caf50;
    font-size: 0.85rem;
    margin-top: 5px;
    animation: fadeIn 0.3s ease;
}

/* 8. Loading state */
.is-loading {
    position: relative;
    color: transparent !important;
}

.is-loading::after {
    content: '';
    position: absolute;
    left: calc(50% - 10px);
    top: calc(50% - 10px);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(92, 64, 51, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s infinite linear;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ====== Conditional Field Animations ====== */

/* Fields that become visible based on previous selections */
.conditional-field {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
    margin: 0;
}

.conditional-field.is-visible {
    max-height: 500px; /* Large enough to fit content */
    opacity: 1;
    margin: 15px 0;
    overflow: visible;
}

/* ====== Enhanced Radio and Checkbox Designs ====== */

/* Style for checkboxes */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid rgba(92, 64, 51, 0.3);
    border-radius: 4px;
    margin-right: 10px;
    display: grid;
    place-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

input[type="checkbox"]::before {
    content: "";
    width: 14px;
    height: 14px;
    transform: scale(0);
    transition: transform 0.2s ease-in-out;
    box-shadow: inset 1em 1em var(--primary-color);
    transform-origin: center;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

input[type="checkbox"]:checked {
    border-color: var(--primary-color);
    background-color: rgba(92, 64, 51, 0.05);
}

input[type="checkbox"]:checked::before {
    transform: scale(1);
}

/* Modern checkbox containers */
.checkbox-container {
    display: flex;
    align-items: center;
    margin: 10px 0;
    cursor: pointer;
    padding: 12px 16px;
    border-radius: var(--input-radius);
    transition: all 0.3s ease;
}

.checkbox-container:hover {
    background-color: rgba(92, 64, 51, 0.05);
}

.checkbox-container input[type="checkbox"]:checked ~ label {
    font-weight: 600;
    color: var(--primary-color);
}

/* Visual feedback for invalid fields */
.is-invalid ~ .error-message {
    margin-top: 5px;
    display: block;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

/* Additional styling for form field focus state for keyboard users */
.user-is-tabbing input:focus,
.user-is-tabbing textarea:focus,
.user-is-tabbing select:focus,
.user-is-tabbing button:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(92, 64, 51, 0.15);
}
