/* === Main Wrapper === */
.cf7-authyo-wrap {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 6px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding: 0 15px;
    margin: 0;
    transform: translateY(-15px) scale(0.95);
    transition: 
        max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        padding 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        margin 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.3s ease;
    border-color: transparent;
}

/* Show wrapper when active */
.cf7-authyo-wrap.cf7-authyo-active {
    max-height: 1000px; /* Large enough to accommodate content */
    opacity: 1;
    padding: 15px;
    margin: 12px 0;
    transform: translateY(0) scale(1);
    border-color: #ddd;
}

/* Stagger animations for multiple sections */
.cf7-authyo-wrap.cf7-authyo-email {
    transition-delay: 0s;
}

.cf7-authyo-wrap.cf7-authyo-phone {
    transition-delay: 0.1s; /* Slight delay for phone section to appear after email */
}

/* Animation stages for smoother appearance */
@keyframes authyo-slide-in {
    0% {
        max-height: 0;
        opacity: 0;
        padding: 0 15px;
        margin: 0;
        transform: translateY(-15px) scale(0.95);
    }
    50% {
        opacity: 0.5;
    }
    100% {
        max-height: 1000px;
        opacity: 1;
        padding: 15px;
        margin: 12px 0;
        transform: translateY(0) scale(1);
    }
}

@keyframes authyo-slide-out {
    0% {
        max-height: 1000px;
        opacity: 1;
        padding: 15px;
        margin: 12px 0;
        transform: translateY(0) scale(1);
    }
    50% {
        opacity: 0.5;
    }
    100% {
        max-height: 0;
        opacity: 0;
        padding: 0 15px;
        margin: 0;
        transform: translateY(-15px) scale(0.95);
    }
}

.cf7-authyo-wrap .button {
    margin-right: 8px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
}

/* === OTP Input Row === */
.cf7-authyo-otp-row {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.cf7-authyo-otp-row input.cf7-authyo-otp {
    width: 140px;
    padding: 8px;
    font-size: 16px;
    text-align: center;
    border: 2px solid #ddd;
    border-radius: 4px;
    transition: border-color 0.3s;
}

.cf7-authyo-otp-row input.cf7-authyo-otp:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

/* === Status Messages === */
.cf7-authyo-status {
    margin-top: 0px;
    font-size: 14px;
    font-weight: 500;
    min-height: 20px;
}

/* === Resend Link === */
.cf7-authyo-resend {
    color: #0073aa;
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
}

.cf7-authyo-resend:hover {
    text-decoration: underline;
}

.cf7-authyo-resend.disabled {
    pointer-events: none;
    opacity: 0.5;
    color: #999;
}

/* === Countdown Timer === */
.cf7-authyo-countdown {
    font-size: 13px;
    color: #666;
    margin-left: 8px;
}

/* === Fallback UI (Phone Only) === */
.cf7-authyo-fallback {
    margin-top: 16px;
    padding: 12px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.cf7-authyo-fallback-message {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.cf7-authyo-fallback-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

@media (max-width: 600px) {
    .cf7-authyo-fallback-buttons {
        grid-template-columns: 1fr;
    }
}

.cf7-authyo-fallback-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    font-size: 13px;
    background: #fff;
    border: 2px solid #0073aa;
    border-radius: 4px;
    color: #0073aa;
    cursor: pointer;
    transition: all 0.3s;
}

.cf7-authyo-fallback-btn:hover:not(:disabled) {
    background: #0073aa;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 2px 6px rgba(0, 115, 170, 0.3);
}

.cf7-authyo-fallback-btn:active:not(:disabled) {
    transform: translateY(0);
}

.cf7-authyo-fallback-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cf7-authyo-fallback-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.cf7-authyo-fallback-timer {
    display: block;
    text-align: center;
    font-size: 12px;
    color: #666;
    margin-top: 8px;
}

/* === Accessibility === */
.cf7-authyo-wrap *:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.cf7-authyo-wrap [aria-live] {
    position: relative;
}

/* === Loading States === */
.cf7-authyo-wrap .button.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.cf7-authyo-wrap .button.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #fff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: cf7-authyo-spin 0.6s linear infinite;
}

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

/* === Phone-specific styling === */
.cf7-authyo-wrap.cf7-authyo-phone {
    border-left: 4px solid #25D366;
}

.cf7-authyo-wrap.cf7-authyo-email {
    border-left: 4px solid #0073aa;
}

/* === Legacy support === */
p.cf7-authyo-phone-hint {
    font-size: 12px !important;
}

/* === Country Selector Styles === */

/* Inline phone container - wraps country dropdown + phone field */
.cf7-authyo-inline-phone-container {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin: 0;
    position: relative;
}

.cf7-authyo-country-selector-container {
    position: relative;
    flex: 0 0 200px;
    max-width: 200px;
    margin-bottom: 0;
}

/* Remove margin when inside inline container to prevent double spacing */
.cf7-authyo-inline-phone-container .cf7-authyo-country-selector-container {
    margin-bottom: 0 !important;
}

/* Show country selector for phone forms */
.cf7-authyo-wrap.cf7-authyo-phone .cf7-authyo-country-selector-container {
    display: block !important;
}

/* Phone field styling when integrated with country selector */
.cf7-authyo-inline-phone-container input[type="tel"],
.cf7-authyo-inline-phone-container input[type="text"].wpcf7-tel {
    flex: 1;
    min-width: 0;
    padding-left: 60px !important;
}

/* Visual prefix showing country code on phone field */
.cf7-authyo-phone-prefix {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 600;
    color: #0073aa;
    font-size: 0px;
    pointer-events: none;
    z-index: 1;
    background: white;
    padding: 2px 4px;
    border-radius: 2px;
}

.cf7-authyo-country-dropdown-wrapper {
    position: relative;
    display: block;
    cursor: pointer;
}

.cf7-authyo-country-search {
    width: 100%;
    padding: 10px 75px 10px 12px;
    font-size: 13px;
    border: 2px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer !important;
    transition: border-color 0.3s, box-shadow 0.3s;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
    position: relative;
}

.cf7-authyo-country-search:hover {
    border-color: #0073aa;
    box-shadow: 0 0 0 1px rgba(0, 115, 170, 0.1);
}

.cf7-authyo-country-search:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
    cursor: text;
}

.cf7-authyo-country-search[readonly] {
    cursor: pointer;
}

/* Locked state for single country */
.cf7-authyo-country-locked .cf7-authyo-country-search {
    cursor: not-allowed !important;
    background-color: #f0f0f0 !important;
    opacity: 0.7;
}

.cf7-authyo-country-locked .cf7-authyo-country-search:hover {
    border-color: #ddd !important;
    box-shadow: none !important;
}

.cf7-authyo-country-locked .cf7-authyo-dropdown-arrow {
    display: none !important;
}

.cf7-authyo-country-locked .cf7-authyo-country-dropdown-wrapper {
    pointer-events: none;
    cursor: not-allowed;
    opacity: 0.7;
}

.cf7-authyo-country-code-display {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 600;
    color: #0073aa;
    pointer-events: none;
    font-size: 12px;
    background: #e7f3f8;
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
    z-index: 2;
    min-width: 35px;
    text-align: center;
}

.cf7-authyo-dropdown-arrow {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #666;
    font-size: 10px;
    transition: transform 0.3s;
    cursor: pointer;
    z-index: 3;
}

.cf7-authyo-country-dropdown-wrapper:hover .cf7-authyo-dropdown-arrow {
    color: #0073aa;
}

.cf7-authyo-country-search:focus ~ .cf7-authyo-dropdown-arrow {
    transform: translateY(-50%) rotate(180deg);
}

.cf7-authyo-country-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 250px;
    overflow-y: auto;
    background: white;
    border: 2px solid #0073aa;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999 !important;
    margin-top: 4px;
}

/* Ensure country dropdown wrapper has proper stacking context */
.cf7-authyo-country-dropdown-wrapper {
    z-index: 100;
}

.cf7-authyo-country-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

.cf7-authyo-country-item:last-child {
    border-bottom: none;
}

.cf7-authyo-country-item:hover {
    background-color: #f5f9fc;
}

.cf7-authyo-country-item.cf7-authyo-selected {
    background-color: #e7f3f8;
    font-weight: 500;
}

/* Keyboard navigation highlight */
.cf7-authyo-country-item.cf7-authyo-highlighted {
    background-color: #d4ebf7;
    outline: 2px solid #0073aa;
    outline-offset: -2px;
}

.cf7-authyo-country-item.cf7-authyo-no-results,
.cf7-authyo-country-item.cf7-authyo-no-countries {
    cursor: default;
    color: #999;
    text-align: center;
    padding: 20px;
}

.cf7-authyo-country-item.cf7-authyo-no-results:hover,
.cf7-authyo-country-item.cf7-authyo-no-countries:hover {
    background-color: white;
}

.cf7-authyo-country-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 20px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 2px;
    font-size: 11px;
    font-weight: 600;
    color: #666;
    flex-shrink: 0;
}

.cf7-authyo-country-name {
    flex: 1;
    font-size: 14px;
    color: #333;
}

.cf7-authyo-country-dial-code {
	/* Hidden - only showing country names in dropdown */
	display: none !important;
	font-size: 13px;
	font-weight: 600;
	color: #0073aa;
	flex-shrink: 0;
}

/* Scrollbar styling for country list */
.cf7-authyo-country-list::-webkit-scrollbar {
    width: 8px;
}

.cf7-authyo-country-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.cf7-authyo-country-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.cf7-authyo-country-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .cf7-authyo-inline-phone-container {
        flex-direction: column;
        gap: 12px;
    }
    
    .cf7-authyo-country-selector-container {
        flex: 1 1 100%;
        max-width: 100%;
    }
    
    .cf7-authyo-inline-phone-container input[type="tel"],
    .cf7-authyo-inline-phone-container input[type="text"].wpcf7-tel {
        width: 100%;
    }
    
    .cf7-authyo-country-list {
        max-height: 200px;
    }
    
    .cf7-authyo-country-item {
        padding: 12px 10px;
    }
}

/* Additional styling for better CF7 integration */
.wpcf7-form-control-wrap.cf7-authyo-phone-wrapper {
    display: block;
    position: relative;
    margin-bottom: 0;
}

/* Remove any extra margins from phone wrapper when it contains inline container */
.wpcf7-form-control-wrap.cf7-authyo-phone-wrapper .cf7-authyo-inline-phone-container {
    margin: 0;
}

.cf7-authyo-inline-phone-container > span.wpcf7-form-control-wrap,
.cf7-authyo-inline-phone-container > input[type="tel"],
.cf7-authyo-inline-phone-container > input[type="text"].wpcf7-tel {
    position: relative;
}