/**
 * Magic Code Authentication Styles
 * Version: 13.4.0
 * Enhanced UX with modern design
 */

/* Hide default WooCommerce forms */
.woocommerce-form-login,
.woocommerce-form-register,
#customer_login {
    display: none !important;
}

/* Initial load state */
.mca-popup-overlay.mca-initial-load {
    display: none;
}

/* Simple body lock when popup is open */
body.mca-popup-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
}

/* Popup Overlay - Full coverage */
.mca-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999999;
    padding: 20px;
    box-sizing: border-box;
    animation: mca-fade-in 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Popup Content */
.mca-popup-content {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
    position: relative;
    animation: mca-slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Animations */
@keyframes mca-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes mca-slide-up {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Progress Steps */
.mca-progress-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 32px;
    padding: 0 20px;
}

.mca-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    opacity: 0.4;
    transition: all 0.3s ease;
}

.mca-step.mca-step-active {
    opacity: 1;
}

.mca-step.mca-step-complete {
    opacity: 0.7;
}

.mca-step-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #999;
    transition: all 0.3s ease;
}

.mca-step-active .mca-step-circle {
    background: linear-gradient(135deg, var(--mca-primary-color, #667eea) 0%, var(--mca-secondary-color, #764ba2) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transform: scale(1.1);
}

.mca-step-complete .mca-step-circle {
    background: #46b450;
    color: white;
}

.mca-step-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
}

.mca-step-active .mca-step-label {
    color: #333;
}

.mca-step-line {
    width: 40px;
    height: 2px;
    background: #e0e0e0;
    margin: 0 4px;
    position: relative;
    top: -12px;
}

/* Header */
.mca-header {
    margin-bottom: 24px;
    text-align: center;
}

.mca-header h2 {
    margin: 0 0 8px 0;
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
    transition: all 0.3s ease;
}

.mca-header p {
    margin: 0;
    font-size: 15px;
    color: #666;
    line-height: 1.5;
    transition: all 0.3s ease;
}

/* Trust Badges */
.mca-trust-badges {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 28px;
    padding: 14px;
    background: linear-gradient(135deg, #f8f9fa 0%, #f0f2f5 100%);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.mca-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    padding: 6px 12px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.mca-badge svg {
    color: var(--mca-primary-color, #667eea);
}

/* Forms */
.mca-form {
    display: none;
    animation: mca-form-slide-in 0.3s ease;
}

.mca-form-active {
    display: block;
}

@keyframes mca-form-slide-in {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Input Wrapper */
.mca-input-wrapper {
    margin-bottom: 20px;
}

.mca-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Input Groups */
.mca-input-group {
    position: relative;
    margin-bottom: 20px;
}

.mca-input-group input {
    width: 100%;
    padding: 14px 16px;
    padding-right: 44px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    transition: all 0.3s ease;
    box-sizing: border-box;
    font-family: inherit;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    touch-action: manipulation;
    background: #fafafa;
}

.mca-input-group input:hover {
    border-color: #d0d0d0;
    background: #fff;
}

.mca-input-group input:focus {
    outline: none;
    border-color: var(--mca-primary-color, #667eea);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    background: #fff;
}

.mca-input-icon {
    position: absolute;
    right: 14px;
    top: 44%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
    transition: color 0.3s ease;
}

.mca-input-group input:focus + .mca-input-icon {
    color: var(--mca-primary-color, #667eea);
}

/* Code Input Specific */
.mca-input-group-code input {
    text-align: center;
    font-size: 28px;
    letter-spacing: 8px;
    font-weight: 700;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    padding: 18px 16px;
}

/* Buttons */
.mca-btn {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    position: relative;
    overflow: hidden;
}

.mca-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.mca-btn:active::before {
    width: 300px;
    height: 300px;
}

.mca-btn-primary {
    background: linear-gradient(135deg, var(--mca-primary-color, #667eea) 0%, var(--mca-secondary-color, #764ba2) 100%);
    color: var(--mca-button-text-color, white);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.mca-btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.mca-btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.mca-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.mca-btn-text,
.mca-btn-loader {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.mca-btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: mca-spin 0.6s linear infinite;
}

@keyframes mca-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Link Buttons */
.mca-btn-link {
    background: transparent;
    color: var(--mca-primary-color, #667eea);
    padding: 10px 15px;
    font-size: 14px;
    width: fit-content !important;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mca-btn-link:hover {
    background: #f9fafb;
    color: var(--mca-secondary-color, #764ba2);
}

.mca-btn-link:active {
    background: #f3f4f6;
}

.mca-btn-link svg {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.mca-btn-link:hover svg {
    transform: scale(1.1);
}

.mca-btn-link.disabled {
    color: #9ca3af;
    cursor: not-allowed;
    opacity: 0.6;
    background: transparent;
}

.mca-btn-link.disabled:hover {
    background: transparent;
}

#mca-change-email-new {
    margin-top: 12px;
    width: 100%;
    justify-content: center;
}

/* Biometric Login Button */
.mca-btn-biometric {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    border: 2px solid var(--mca-primary-color, #667eea);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: inherit;
    background: white;
    color: var(--mca-primary-color, #667eea);
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.mca-btn-biometric:hover:not(:disabled) {
    background: var(--mca-primary-color, #667eea);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.mca-btn-biometric:active:not(:disabled) {
    transform: translateY(0);
}

.mca-btn-biometric:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mca-biometric-icon {
    display: inline-flex;
    align-items: center;
}

/* OR Divider */
.mca-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0;
    color: #999;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
}

.mca-divider::before,
.mca-divider::after {
    content: '';
    flex: 1;
    border-bottom: 2px solid #e8e8e8;
}

.mca-divider span {
    padding: 0 16px;
}

/* Checkbox Wrapper */
.mca-checkbox-wrapper {
    margin: 20px 0;
}

.mca-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.6;
    color: #444;
}

.mca-checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.mca-checkbox-custom {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 2px solid #d0d0d0;
    border-radius: 4px;
    margin-top: 2px;
    transition: all 0.3s ease;
    position: relative;
}

.mca-checkbox-label:hover .mca-checkbox-custom {
    border-color: var(--mca-primary-color, #667eea);
}

.mca-checkbox-label input[type="checkbox"]:checked + .mca-checkbox-custom {
    background: var(--mca-primary-color, #667eea);
    border-color: var(--mca-primary-color, #667eea);
}

.mca-checkbox-label input[type="checkbox"]:checked + .mca-checkbox-custom::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.mca-checkbox-text a {
    color: var(--mca-primary-color, #667eea);
    text-decoration: none;
    font-weight: 600;
}

.mca-checkbox-text a:hover {
    text-decoration: underline;
}

/* Info Box */
.mca-info-box {
    background: linear-gradient(135deg, #f8f9fa 0%, #f0f2f5 100%);
    border-left: 4px solid var(--mca-primary-color, #667eea);
    padding: 16px;
    margin-bottom: 20px;
    border-radius: 8px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.mca-info-box svg {
    flex-shrink: 0;
    color: var(--mca-primary-color, #667eea);
    margin-top: 2px;
}

.mca-info-box h3 {
    margin: 0 0 8px 0;
    font-size: 16px !important;
    font-weight: 700;
    color: #333;
}

.mca-info-box p {
    margin: 0 0 6px 0;
    color: #555;
    font-size: 14px;
    line-height: 1.5;
}

.mca-info-box p:last-child {
    margin-bottom: 0;
}

.mca-info-main {
    font-weight: 600;
    font-size: 15px !important;
    color: #333 !important;
    margin-bottom: 8px !important;
}

.mca-info-detail {
    font-size: 14px !important;
    color: #555 !important;
}

.mca-info-hint {
    font-size: 12px !important;
    color: #999 !important;
    margin-top: 4px !important;
}

.mca-info-box-welcome {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-left-color: #46b450;
}

.mca-info-box-welcome svg {
    color: #46b450;
}

.mca-info-box-feature {
    background: linear-gradient(135deg, #fff9e6 0%, #ffe8cc 100%);
    border-left-color: #f59e0b;
    display: block;
}

.mca-info-box-feature h3 {
    margin-bottom: 12px !important;
}

/* Feature List */
.mca-feature-list {
    list-style: none;
    padding: 0;
    margin: 16px 0 0 0;
}

.mca-feature-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    color: #555;
    font-size: 14px;
}

.mca-feature-list svg {
    flex-shrink: 0;
    color: #46b450;
}

/* Form Footer */
.mca-form-footer {
    display: flex;
    margin-top: 10px;
    justify-content: space-around;
}

/* Privacy Note */
.mca-privacy-note {
    margin: 16px -15px 0 -15px;
    font-size: 12px;
    color: #999;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

.mca-privacy-note svg {
    flex-shrink: 0;
    opacity: 0.7;
}

/* Loading Spinner */
.mca-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.98);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 16px;
    z-index: 10;
    backdrop-filter: blur(2px);
}

.mca-spinner-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.mca-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--mca-primary-color, #667eea);
    border-radius: 50%;
    animation: mca-spin 0.8s linear infinite;
}

#mca-loading-text {
    font-size: 14px;
    font-weight: 600;
    color: #666;
    margin: 0;
}

/* Messages */
.mca-message {
    padding: 14px 18px;
    border-radius: 8px;
    margin: 16px 0;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    animation: mca-fade-in 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.mca-message.mca-success {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

.mca-message.mca-error {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

.mca-message.mca-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 2px solid #bee5eb;
}

/* Honeypot Fields */
.mca-honey {
    position: absolute !important;
    left: -9999px !important;
    opacity: 0 !important;
    pointer-events: none !important;
    height: 0 !important;
    width: 0 !important;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .mca-popup-overlay {
        padding: 15px;
    }

    .mca-popup-content {
        padding: 32px 28px;
        max-width: 100%;
    }

    .mca-header h2 {
        font-size: 24px;
    }

    .mca-progress-steps {
        margin-bottom: 24px;
        padding: 0 10px;
    }

    .mca-step-circle {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }

    .mca-step-line {
        width: 32px;
    }

    .mca-trust-badges {
        gap: 10px;
        padding: 12px;
    }

    .mca-badge {
        font-size: 11px;
        padding: 5px 10px;
    }
}

@media (max-width: 480px) {
    .mca-popup-overlay {
        padding: 0;
        align-items: center;
    }

    .mca-popup-content {
        padding: 20px 24px 10px;
        border-radius: 16px;
        max-height: 90vh;
        overflow-y: auto;
        margin: 15px;
        width: calc(100% - 30px);
        max-width: 420px;
    }

    .mca-header h2 {
        font-size: 22px;
        margin-bottom: 6px;
    }

    .mca-header p {
        font-size: 14px;
    }

    .mca-progress-steps {
        margin-bottom: 20px;
    }

    .mca-step-circle {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .mca-step-label {
        font-size: 10px;
    }

    .mca-step-line {
        width: 24px;
    }

    .mca-trust-badges {
        gap: 8px;
        padding: 10px;
        margin-bottom: 20px;
        flex-wrap: wrap;
    }

    .mca-badge {
        font-size: 10px;
        padding: 4px 8px;
        flex: 1;
        min-width: 70px;
        justify-content: center;
    }

    /* Form footer and btn-link already optimized for mobile */

    .mca-input-group input {
        font-size: 16px;
        padding: 14px 16px;
        padding-right: 44px;
        height: 50px;
    }

    .mca-input-group-code input {
        font-size: 24px;
        letter-spacing: 6px;
    }

    .mca-btn {
        padding: 14px 20px;
        font-size: 15px;
        min-height: 50px;
    }

    .mca-info-box {
        padding: 14px;
        gap: 12px;
    }

    .mca-info-box h3 {
        font-size: 15px !important;
    }

    .mca-info-box p {
        font-size: 13px;
    }

    .mca-feature-list li {
        font-size: 13px;
        padding: 6px 0;
    }

    .mca-checkbox-label {
        font-size: 13px;
    }

    .mca-privacy-note {
        font-size: 11px;
        margin-top: 12px;
    }

    .mca-message {
        font-size: 13px;
        padding: 12px 14px;
    }

    .mca-checkmark {
        width: 64px;
        height: 64px;
    }
}

@media (max-width: 360px) {
    .mca-popup-content {
        padding: 24px 20px;
        margin: 10px;
        width: calc(100% - 20px);
    }

    .mca-header h2 {
        font-size: 20px;
    }

    .mca-badge {
        font-size: 9px;
        padding: 3px 6px;
        min-width: 60px;
    }

    .mca-step-circle {
        width: 24px;
        height: 24px;
        font-size: 11px;
    }

    .mca-step-label {
        font-size: 9px;
    }
}

/* Landscape mode adjustments */
@media (max-height: 600px) and (orientation: landscape) {
    .mca-popup-overlay {
        padding: 10px;
        align-items: flex-start;
        padding-top: 20px;
    }

    .mca-popup-content {
        padding: 20px 28px;
        max-height: 90vh;
        overflow-y: auto;
        margin: 0 auto;
    }

    .mca-header h2 {
        font-size: 20px;
        margin-bottom: 4px;
    }

    .mca-header p {
        font-size: 13px;
        margin-bottom: 0;
    }

    .mca-progress-steps {
        margin-bottom: 16px;
    }

    .mca-trust-badges {
        display: none;
    }

    .mca-input-wrapper,
    .mca-input-group {
        margin-bottom: 12px;
    }

    .mca-btn {
        padding: 10px 16px;
        min-height: 42px;
    }

    .mca-info-box {
        padding: 12px;
        margin-bottom: 12px;
    }
}
/* Shake animation for overlay click feedback */
.mca-shake {
    animation: mca-shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes mca-shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-8px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(8px);
    }
}
