/**
 * Etsy-Style Login Popup - Refined Styles
 * Optimized for Kadence Theme and WooCommerce
 */

/* ===== POPUP OVERLAY ===== */
.etsy-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(34, 34, 34, 0.65);
    backdrop-filter: blur(2px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.etsy-popup-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* ===== POPUP CONTAINER ===== */
.etsy-popup-container {
    background: #ffffff;
    border-radius: 16px;
    width: 100%;
    max-width: 380px;
    max-height: 90vh;
    position: relative;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 8px 25px rgba(0, 0, 0, 0.08);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.etsy-popup-overlay.show .etsy-popup-container {
    transform: scale(1) translateY(0);
}

/* ===== HEADER SECTION ===== */
.etsy-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 0;
    border-bottom: 1px solid #f5f5f5;
    margin-bottom: 0;
}

.etsy-auth-switch {
    display: flex;
    align-items: center;
    gap: 12px;
}

.etsy-popup-title {
    font-size: 20px;
    font-weight: 600;
    color: #222222;
    margin: 0;
    letter-spacing: -0.02em;
}

.etsy-register-btn {
    background: transparent;
    border: 1.5px solid #222222;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #222222;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
}

.etsy-register-btn:hover {
    background: #222222;
    color: #ffffff;
    transform: translateY(-1px);
}

.etsy-register-btn.active {
    background: #222222;
    color: #ffffff;
}

.etsy-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #999999;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.etsy-close-btn:hover {
    background-color: #f5f5f5;
    color: #666666;
    transform: scale(1.1);
}

/* ===== CONTENT SECTION ===== */
.etsy-popup-content {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
}

/* Custom scrollbar */
.etsy-popup-content::-webkit-scrollbar {
    width: 4px;
}

.etsy-popup-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.etsy-popup-content::-webkit-scrollbar-thumb {
    background: #cccccc;
    border-radius: 2px;
}

/* ===== FORM CONTAINERS ===== */
.etsy-form-container {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.etsy-form-container.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== FORM ELEMENTS ===== */
.etsy-form-group {
    margin-bottom: 20px;
    position: relative;
}

.etsy-form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #333333;
    letter-spacing: -0.01em;
}

.etsy-form-input {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid #e1e3e1;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 400;
    color: #222222;
    background: #ffffff;
    transition: all 0.2s ease;
    box-sizing: border-box;
    -webkit-appearance: none;
}

.etsy-form-input:focus {
    outline: none;
    border-color: #222222;
    box-shadow: 0 0 0 3px rgba(34, 34, 34, 0.1);
    transform: translateY(-1px);
}

.etsy-form-input:invalid {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

.etsy-form-input::placeholder {
    color: #999999;
    font-weight: 400;
}

/* Password hint */
.etsy-password-hint {
    font-size: 12px;
    color: #666666;
    margin-top: 4px;
    opacity: 0.8;
}

/* ===== FORM OPTIONS ===== */
.etsy-form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.etsy-checkbox-container {
    display: flex;
    align-items: center;
}

.etsy-checkbox {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    accent-color: #222222;
    cursor: pointer;
}

.etsy-checkbox-label {
    font-size: 14px;
    color: #333333;
    cursor: pointer;
    user-select: none;
}

.etsy-forgot-password {
    font-size: 14px;
}

.etsy-forgot-password a {
    color: #222222;
    text-decoration: underline;
    transition: all 0.2s ease;
}

.etsy-forgot-password a:hover {
    color: #000000;
    text-decoration: none;
}

/* ===== SUBMIT BUTTON ===== */
.etsy-submit-btn {
    width: 100%;
    padding: 16px 24px;
    background: #222222;
    color: #ffffff;
    border: none;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.02em;
}

.etsy-submit-btn:hover {
    background: #000000;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(34, 34, 34, 0.3);
}

.etsy-submit-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(34, 34, 34, 0.2);
}

.etsy-submit-btn:disabled {
    background: #cccccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Button loading state */
.etsy-submit-btn .btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== TROUBLE SIGNING ===== */
.etsy-trouble-signing {
    text-align: center;
    margin-bottom: 24px;
}

.etsy-trouble-signing a {
    color: #222222;
    text-decoration: underline;
    font-size: 14px;
    transition: all 0.2s ease;
}

.etsy-trouble-signing a:hover {
    color: #000000;
    text-decoration: none;
}

/* ===== MESSAGES ===== */
#etsy-popup-messages {
    margin-bottom: 16px;
}

.etsy-message {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 12px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.etsy-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.etsy-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.etsy-message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* ===== DIVIDER ===== */
.etsy-divider {
    text-align: center;
    margin: 28px 0;
    position: relative;
    color: #999999;
    font-size: 13px;
    font-weight: 500;
}

.etsy-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, #e1e3e1 20%, #e1e3e1 80%, transparent);
}

.etsy-divider span {
    background: #ffffff;
    padding: 0 20px;
    position: relative;
    z-index: 1;
}

/* ===== SOCIAL LOGIN ===== */
.etsy-social-login-wrapper {
    margin-bottom: 20px;
}

/* Nextend Social Login styling */
.etsy-social-login-wrapper .nsl-container-buttons {
    margin: 0 !important;
}

.etsy-social-login-wrapper .nsl-button {
    width: 100% !important;
    padding: 14px 16px !important;
    border: 1.5px solid #e1e3e1 !important;
    border-radius: 25px !important;
    background: #ffffff !important;
    color: #333333 !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    margin-bottom: 12px !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-decoration: none !important;
}

.etsy-social-login-wrapper .nsl-button:hover {
    border-color: #222222 !important;
    background: #f8f9fa !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

.etsy-social-login-wrapper .nsl-button-icon {
    margin-right: 10px !important;
    width: 20px !important;
    height: 20px !important;
}

/* Manual social buttons */
.etsy-social-btn {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid #e1e3e1;
    border-radius: 25px;
    background: #ffffff;
    color: #333333;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.etsy-social-btn:hover {
    border-color: #222222;
    background: #f8f9fa;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.etsy-social-btn .social-icon,
.etsy-social-btn .facebook-icon {
    margin-right: 10px;
}

.facebook-icon {
    width: 20px;
    height: 20px;
    background: #1877f2;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 12px;
}

/* ===== TERMS TEXT ===== */
.etsy-terms-text {
    font-size: 12px;
    color: #666666;
    line-height: 1.5;
    text-align: left;
    margin-top: 20px;
}

.etsy-terms-text p {
    margin-bottom: 8px;
}

.etsy-terms-text a {
    color: #222222;
    text-decoration: underline;
    transition: all 0.2s ease;
}

.etsy-terms-text a:hover {
    color: #000000;
    text-decoration: none;
}

/* ===== KADENCE THEME INTEGRATION ===== */
.kadence-theme .etsy-popup-container {
    font-family: var(--global-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
}

.kadence-theme .etsy-submit-btn {
    background: var(--global-palette-btn, #222222);
}

.kadence-theme .etsy-submit-btn:hover {
    background: var(--global-palette-btn-hover, #000000);
}

/* ===== WOOCOMMERCE INTEGRATION ===== */
.woocommerce .etsy-login-btn {
    background: #222222;
    color: #ffffff;
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
    margin: 8px 0;
}

.woocommerce .etsy-login-btn:hover {
    background: #000000;
    color: #ffffff;
    transform: translateY(-1px);
    text-decoration: none;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 480px) {
    .etsy-popup-container {
        margin: 16px;
        max-width: calc(100% - 32px);
        border-radius: 12px;
    }
    
    .etsy-popup-header {
        padding: 20px 20px 0;
    }
    
    .etsy-popup-content {
        padding: 20px;
    }
    
    .etsy-popup-title {
        font-size: 18px;
    }
    
    .etsy-form-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .etsy-forgot-password {
        align-self: flex-end;
    }
}

@media (max-width: 360px) {
    .etsy-popup-container {
        margin: 12px;
        max-width: calc(100% - 24px);
    }
    
    .etsy-form-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* ===== ACCESSIBILITY ===== */
.etsy-popup-overlay:focus-within .etsy-popup-container {
    outline: 2px solid #4A90E2;
    outline-offset: 4px;
}

.etsy-form-input:focus {
    outline: 2px solid #4A90E2;
    outline-offset: 2px;
}

.etsy-checkbox:focus {
    outline: 2px solid #4A90E2;
    outline-offset: 2px;
}

/* ===== BODY STATES ===== */
body.etsy-popup-active {
    overflow: hidden;
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
    .etsy-popup-container {
        border: 2px solid #000000;
    }
    
    .etsy-form-input {
        border-width: 2px;
    }
    
    .etsy-submit-btn {
        border: 2px solid #000000;
    }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    .etsy-popup-overlay,
    .etsy-popup-container,
    .etsy-submit-btn,
    .etsy-form-input {
        transition: none;
    }
    
    .spinner {
        animation: none;
        border: 2px solid #ffffff;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .etsy-popup-overlay {
        display: none !important;
    }
}