/* ===== Input Field Container ===== */
.input-field {
    display: flex;
    flex-direction: column;
    gap: var(--780-spacing-4);
}

/* ===== Input Wrapper (border + label + icon) ===== */
.input-wrapper {
    position: relative;
    border-radius: 16px;
}

.input-wrapper input {
    width: 100%;
    border-radius: 16px;
    border: 1px solid var(--780-main-outline-var);
    background: transparent;
    padding: 17px 20px;
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--780-main-on-surface);
    outline: none;
    direction: rtl;
    transition: border-color 0.2s;
    font-family: inherit;
}

.input-wrapper input::placeholder {
    color: transparent;
}

/* Focus state */
.input-wrapper input:focus {
    border: 2px solid var(--780-main-primary);
    caret-color: var(--780-main-primary);
    padding: 16px 19px;
}

/* ===== Floating Label (notched outline / legend style) ===== */
.input-wrapper label {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.4rem;
    color: var(--780-main-on-surface-variant);
    pointer-events: none;
    transition: all 0.2s ease-in-out;
    line-height: 1;
}

/* Label floats to border on focus or when filled */
.input-wrapper input:focus ~ label,
.input-wrapper input:not(:placeholder-shown) ~ label {
    top: 0;
    transform: translateY(-50%);
    font-size: 1.2rem;
    background: var(--780-main-surface);
    padding: 0 var(--780-spacing-8);
}

.input-wrapper input:focus ~ label {
    color: var(--780-main-primary);
}

.input-wrapper input:not(:placeholder-shown) ~ label {
    color: var(--780-main-on-surface-variant);
}

/* ===== Error State ===== */
.input-field.has-error .input-wrapper input {
    border: 2px solid var(--780-error);
    padding: 16px 19px;
    padding-left: 48px;
}

.input-field.has-error .input-wrapper input:focus ~ label,
.input-field.has-error .input-wrapper input:not(:placeholder-shown) ~ label {
    color: var(--780-error);
}

.input-error-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.input-field.has-error .input-error-icon {
    display: flex;
}

.field-error {
    font-size: 1.2rem;
    color: var(--780-error);
    padding-right: var(--780-spacing-8);
    min-height: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.field-error:empty {
    display: none;
}

/* ===== No spinner ===== */
.input-wrapper input::-webkit-outer-spin-button,
.input-wrapper input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-wrapper input[type="number"] {
    -moz-appearance: textfield;
}

/* ===== OTP Digit Boxes ===== */
.otp-boxes {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.otp-box {
    width: 48px;
    height: 48px;
    border: 1px solid var(--780-main-outline-var);
    border-radius: var(--780-radius-12);
    background: transparent;
    text-align: center;
    font-size: 2rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--780-main-on-surface);
    outline: none;
    transition: border-color 0.2s;
    caret-color: var(--780-main-primary);
}

.otp-box:focus {
    border: 2px solid var(--780-main-primary);
}

.otp-box.has-error {
    border: 2px solid var(--780-error);
}

/* ===== OTP Error ===== */
.otp-input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--780-spacing-8);
}

.otp-error {
    font-size: 1.2rem;
    color: var(--780-error);
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}

.otp-error:empty {
    display: none;
}

/* ===== OTP Actions (resend + edit phone) ===== */
.otp-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--780-spacing-12);
}

.otp-resend {
    background: none;
    border: none;
    font-size: 1.3rem;
    font-family: inherit;
    color: var(--780-main-on-surface-variant);
    cursor: default;
    padding: 0;
}

.otp-resend:not(:disabled) {
    color: var(--780-main-primary);
    cursor: pointer;
}

.otp-resend:not(:disabled):hover {
    opacity: 0.8;
}

.otp-edit-phone {
    font-size: 1.3rem;
    font-family: inherit;
    color: var(--780-main-primary);
    text-decoration: none;
    cursor: pointer;
}

.otp-edit-phone:hover {
    opacity: 0.8;
}

/* ===== Primary Button ===== */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
    padding: var(--780-spacing-12) var(--780-spacing-24);
    border: none;
    border-radius: var(--780-radius-12);
    background: var(--780-main-primary);
    color: var(--780-main-on-primary);
    font-size: 1.5rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.2s;
    user-select: none;
}

.btn-primary:hover:not(:disabled) {
    opacity: 0.9;
}

.btn-primary:disabled {
    background: var(--780-main-divider);
    color: var(--780-main-on-surface-variant);
    cursor: not-allowed;
}

/* ===== Outline Button ===== */
.btn-outline {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
    padding: var(--780-spacing-12) var(--780-spacing-24);
    border: 1px solid var(--780-main-outline-var);
    border-radius: var(--780-radius-12);
    background: var(--780-main-surface-rog);
    color: var(--780-main-on-surface);
    font-size: 1.4rem;
    font-weight: 400;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--780-main-primary);
    color: var(--780-main-primary);
}

.btn-outline:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}

/* ===== Link Button ===== */
.btn-link {
    background: none;
    border: none;
    color: var(--780-main-primary);
    font-size: 1.3rem;
    font-family: inherit;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
}

.btn-link:hover {
    opacity: 0.8;
}

/* ===== Hidden Altcha Widget ===== */
.form-group:has(altcha-widget) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* ===== Button Loading State ===== */
.btn-primary.btn-loading {
    pointer-events: none;
    opacity: 0.8;
    gap: 8px;
}

.btn-primary.btn-loading::after {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}

@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* ===== Validation Summary ===== */
.validation-summary {
    font-size: 1.2rem;
    color: var(--780-error);
    font-weight: 500;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.6;
    max-width: 100%;
}
