/* Phone Authentication Styles */

/* Registration and Login Mode Selector */
.registration-mode-selector,
.login-mode-selector {
    margin-bottom: 20px;
}

.registration-mode-selector .btn-group,
.login-mode-selector .btn-group {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.registration-mode-selector .btn,
.login-mode-selector .btn {
    padding: 12px 20px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: none;
    flex: 1;
}

.registration-mode-selector .btn:first-child,
.login-mode-selector .btn:first-child {
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.registration-mode-selector .btn.active,
.login-mode-selector .btn.active {
    background-color: #007bff;
    color: white;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.registration-mode-selector .btn.btn-outline-primary,
.login-mode-selector .btn.btn-outline-primary {
    background-color: #f8f9fa;
    color: #007bff;
    border-color: #007bff;
}

.registration-mode-selector .btn.btn-outline-secondary,
.login-mode-selector .btn.btn-outline-secondary {
    background-color: #f8f9fa;
    color: #6c757d;
    border-color: #6c757d;
}

/* Phone Input Styling */
input[type="tel"] {
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    transition: all 0.3s ease;
}

input[type="tel"]:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
    outline: none;
}

input[type="tel"].valid {
    border-color: #28a745;
    background-color: rgba(40, 167, 69, 0.05);
}

input[type="tel"].invalid {
    border-color: #dc3545;
    background-color: rgba(220, 53, 69, 0.05);
}

/* Structured Phone Field Styling */
.phone-field-container {
    margin-bottom: 10px;
}

.phone-field-container input[name="phone[number]"] {
    flex: 1;
}

.login-page-form {
    max-width: 450px;
}

.phone-field {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    direction: ltr;
}

.phone-field input,
.phone-field select {
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.phone-field input.numeric {
    font-family: 'Courier New', monospace;
    text-align: center;
    letter-spacing: 1px;
}

.phone-field input.valid {
    border-color: #28a745;
    background-color: rgba(40, 167, 69, 0.05);
}

.phone-field input.invalid {
    border-color: #dc3545;
    background-color: rgba(220, 53, 69, 0.05);
}

.phone-field input:focus,
.phone-field select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
    outline: none;
}

.phone-field span {
    font-weight: bold;
    color: #666;
    font-size: 16px;
    user-select: none;
}

.phone-field .d-flex {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.phone-field .mr-1 {
    margin-right: 0.25rem;
}

.phone-field .mr-2 {
    margin-right: 0.5rem;
}

.phone-field .ml-1 {
    margin-left: 0.25rem;
}

.phone-field .mb-1 {
    margin-bottom: 0.25rem;
}

/* OTP Input Styling */
input[name="otp_code"] {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 6px;
    text-align: center;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.3s ease;
    max-width: 200px;
}

input[name="otp_code"]:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
    outline: none;
}

/* OTP Verification Section */
.otp-verification-section {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    border-left: 4px solid #007bff;
}

.otp-verification-section .name {
    color: #007bff;
    font-weight: 600;
    margin-bottom: 10px;
}

.otp-verification-section .notice {
    color: #6c757d;
    font-size: 14px;
    margin-top: 8px;
}

.verification-info {
    background-color: #e7f3ff;
    border: 1px solid #b8daff;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 20px;
}

.verification-info h4 {
    color: #004085;
    margin-bottom: 10px;
    font-size: 16px;
}

.verification-info p {
    color: #004085;
    margin-bottom: 5px;
}

/* Optional field styling */
.optional {
    font-size: 12px;
    color: #6c757d;
    font-weight: normal;
}

/* Loading states */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.loading input[type="submit"] {
    background-color: #6c757d;
    cursor: not-allowed;
}

/* Form transitions */
#phone-registration-form,
#email-registration-form,
#phone-login-form,
#email-login-form {
    transition: all 0.3s ease;
}

#phone-registration-form {
    div.phone span {
        display: flex;
        align-items: center;
        width: 250px;
        input {
            flex: 1;
        }
    }
}

/* Button styling */
.btn-link {
    color: #007bff;
    text-decoration: none;
    padding: 8px 0;
    font-size: 14px;
    transition: color 0.3s ease;
}

.btn-link:hover {
    color: #0056b3;
    text-decoration: underline;
}

.btn-link:disabled {
    color: #6c757d;
    cursor: not-allowed;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .registration-mode-selector .btn,
    .login-mode-selector .btn {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    input[type="tel"],
    input[name="otp_code"] {
        width: 100%;
        max-width: none;
    }
    
    .otp-verification-section {
        padding: 15px;
        margin: 15px 0;
    }
    
    /* Responsive phone field */
    .phone-field {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .phone-field > div {
        width: 100%;
    }
    
    .phone-field input,
    .phone-field select {
        width: 100% !important;
        text-align: left;
        max-width: none;
    }
    
    .phone-field span {
        display: inline-block;
        min-width: 20px;
    }
}

/* Error and success states */
.field .error {
    color: #dc3545;
    font-size: 14px;
    margin-top: 5px;
}

.field .success {
    color: #28a745;
    font-size: 14px;
    margin-top: 5px;
}

/* Phone format hint */
.notice {
    font-size: 13px;
    color: #6c757d;
    margin-top: 5px;
    font-style: italic;
}

/* Hide/show animation */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

.fade-out {
    animation: fadeOut 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-10px); }
}

/* Progress indicator for OTP */
.otp-progress {
    width: 100%;
    height: 4px;
    background-color: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 15px;
}

.otp-progress-bar {
    height: 100%;
    background-color: #007bff;
    transition: width 0.3s ease;
}

/* Resend button styling */
.resend-otp-btn {
    display: inline;
    margin-top: 10px;
    color: #007bff;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    font-size: inherit;
}

.resend-otp-btn:hover:not(.disabled) {
    color: #0056b3;
    text-decoration: underline;
}

.resend-otp-btn:disabled,
.resend-otp-btn.disabled {
    color: #6c757d;
    cursor: not-allowed;
    pointer-events: none;
    text-decoration: none;
}

/* Verify OTP button styling */
.verify-otp:disabled {
    cursor: not-allowed;
}

/* Phone authentication specific form styling */
.phone-auth-form {
    max-width: 400px;
    margin: 0 auto;
}

.phone-auth-form .submit-cell {
    margin-bottom: 20px;
}

.phone-auth-form .submit-cell .name {
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.phone-auth-form .field {
    position: relative;
}

#phone-otp-form .submit-cell {
    margin-bottom: 20px;
    align-items: center;

    .single-field {
        flex: unset;
        margin-inline-end: 20px;
    }
}

/* Success checkmark animation */
.success-checkmark {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #28a745;
    color: white;
    text-align: center;
    line-height: 20px;
    font-size: 12px;
    margin-left: 10px;
    animation: pulse 0.6s ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.auth-method-toggle {
    display: flex;
    justify-content: center;
    align-items: center;
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 15px;
    max-width: 450px;
}

.toggle-side-label {
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.3s ease;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
}

.toggle-side-label.active {
    background-color: #007bff;
    color: white;
    font-weight: bold;
}

.toggle-side-label.left.active {
    background-color: #007bff;
}

.toggle-side-label.right.active {
    background-color: #28a745;
}

.toggle-side-label i {
    margin-right: 5px;
}

.toggle-switch {
    position: relative;
    width: 60px;
    height: 30px;
}

.toggle-switch input[type="checkbox"] {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #007bff;
    transition: 0.3s;
    border-radius: 30px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: #28a745;
}

input:checked + .toggle-slider:before {
    transform: translateX(30px);
}

.toggle-slider:hover {
    box-shadow: 0 0 5px rgba(0,123,255,0.5);
} 

.ha-icons-container.in-registration {
    flex-direction: column !important;
}

.login-form {
    div.verification-info {
        direction: ltr;
    }
}
