/**
 * Qubic Login Modal Styles
 * Crypto-themed login modal for PeepSo
 */

/* CSS Variables */
:root {
    --qlm-primary: #00d4aa;
    --qlm-secondary: #7c3aed;
    --qlm-bg-dark: #1a1a2e;
    --qlm-bg-darker: #16213e;
    --qlm-text: #ffffff;
    --qlm-text-muted: #94a3b8;
    --qlm-border: rgba(255, 255, 255, 0.1);
    --qlm-error: #ef4444;
    --qlm-success: #10b981;
    --qlm-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --qlm-glow: 0 0 60px rgba(0, 212, 170, 0.3);
}

/* Modal Overlay */
.qlm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 20px;
}

.qlm-overlay.qlm-active {
    opacity: 1;
    visibility: visible;
}

/* Modal Content */
.qlm-modal-content {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #1a1a2e 100%);
    border-radius: 24px;
    padding: 40px;
    box-shadow: var(--qlm-shadow), var(--qlm-glow);
    border: 1px solid var(--qlm-border);
    transform: scale(0.95) translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.qlm-overlay.qlm-active .qlm-modal-content {
    transform: scale(1) translateY(0);
}

/* Decorative Glow Elements */
.qlm-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    pointer-events: none;
    z-index: 0;
}

.qlm-glow-1 {
    width: 200px;
    height: 200px;
    background: var(--qlm-primary);
    opacity: 0.15;
    top: -100px;
    right: -100px;
}

.qlm-glow-2 {
    width: 150px;
    height: 150px;
    background: var(--qlm-secondary);
    opacity: 0.1;
    bottom: -75px;
    left: -75px;
}

/* Close Button */
.qlm-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: var(--qlm-text-muted);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.qlm-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--qlm-text);
    transform: rotate(90deg);
}

/* Header */
.qlm-header {
    text-align: center;
    margin-bottom: 32px;
    position: relative;
    z-index: 1;
}

.qlm-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.1) 0%, rgba(124, 58, 237, 0.1) 100%);
    border-radius: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--qlm-border);
}

.qlm-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--qlm-text);
    margin: 0 0 8px;
    background: linear-gradient(135deg, var(--qlm-primary) 0%, var(--qlm-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.qlm-subtitle {
    font-size: 14px;
    color: var(--qlm-text-muted);
    margin: 0;
}

/* Form */
.qlm-form {
    position: relative;
    z-index: 1;
}

.qlm-field {
    margin-bottom: 16px;
}

.qlm-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.qlm-input-icon {
    position: absolute;
    left: 16px;
    color: var(--qlm-text-muted);
    display: flex;
    align-items: center;
    pointer-events: none;
    transition: color 0.2s ease;
}

.qlm-input {
    width: 100%;
    height: 56px;
    padding: 0 48px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--qlm-border);
    border-radius: 14px;
    color: var(--qlm-text);
    font-size: 15px;
    transition: all 0.2s ease;
    outline: none;
}

.qlm-input::placeholder {
    color: var(--qlm-text-muted);
}

/* Handle browser autofill styling */
.qlm-input:-webkit-autofill,
.qlm-input:-webkit-autofill:hover,
.qlm-input:-webkit-autofill:focus,
.qlm-input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #1e293b inset !important;
    -webkit-text-fill-color: var(--qlm-text) !important;
    background-color: #1e293b !important;
    transition: background-color 5000s ease-in-out 0s;
}

.qlm-input:focus {
    border-color: var(--qlm-primary);
    background: rgba(0, 212, 170, 0.03);
    box-shadow: 0 0 0 4px rgba(0, 212, 170, 0.1);
}

.qlm-input:focus + .qlm-input-icon,
.qlm-input-wrapper:focus-within .qlm-input-icon {
    color: var(--qlm-primary);
}

/* Toggle Password Button */
.qlm-toggle-password {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--qlm-text-muted);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.qlm-toggle-password:hover {
    color: var(--qlm-text);
}

/* Options Row */
.qlm-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

/* Checkbox */
.qlm-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.qlm-checkbox input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.qlm-checkmark {
    width: 20px;
    height: 20px;
    border: 1px solid var(--qlm-border);
    border-radius: 6px;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.03);
}

.qlm-checkbox input:checked + .qlm-checkmark {
    background: linear-gradient(135deg, var(--qlm-primary) 0%, var(--qlm-secondary) 100%);
    border-color: transparent;
}

.qlm-checkbox input:checked + .qlm-checkmark::after {
    content: '';
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

.qlm-checkbox-label {
    font-size: 14px;
    color: var(--qlm-text-muted);
}

/* Forgot Password Link */
.qlm-forgot {
    font-size: 14px;
    color: var(--qlm-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.qlm-forgot:hover {
    color: var(--qlm-secondary);
    text-decoration: underline;
}

/* Error Message - handles both our class and PeepSo's */
.qlm-error,
.qlm-form .errlogin {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 20px;
    color: var(--qlm-error);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.qlm-error:empty,
.qlm-form .errlogin:empty {
    display: none !important;
}

.qlm-error::before,
.qlm-form .errlogin::before {
    content: '⚠️';
}

/* Submit Button */
.qlm-submit {
    width: 100%;
    height: 56px;
    background: linear-gradient(135deg, var(--qlm-primary) 0%, var(--qlm-secondary) 100%);
    border: none;
    border-radius: 14px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.qlm-submit span {
    display: inline;
}

.qlm-submit img {
    width: 20px;
    height: 20px;
    margin-left: 8px;
}

.qlm-submit::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.qlm-submit:hover::before {
    left: 100%;
}

.qlm-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px -10px rgba(0, 212, 170, 0.5);
}

.qlm-submit:active {
    transform: translateY(0);
}

.qlm-submit:disabled,
.qlm-submit[disabled] {
    opacity: 0.7;
    cursor: not-allowed;
}

.qlm-submit:disabled:hover,
.qlm-submit[disabled]:hover {
    transform: none;
    box-shadow: none;
}

/* PeepSo loading state override */
.qlm-submit.ps-btn--loading img {
    display: none;
}

.qlm-submit.ps-btn--loading.ps-processing img {
    display: inline-block !important;
}

.qlm-submit.ps-btn--loading.ps-processing span {
    opacity: 0.7;
}

.qlm-spinner {
    animation: qlm-spin 1s linear infinite;
}

@keyframes qlm-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Divider */
.qlm-divider {
    display: flex;
    align-items: center;
    margin: 28px 0;
    gap: 16px;
}

.qlm-divider::before,
.qlm-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--qlm-border);
}

.qlm-divider span {
    font-size: 13px;
    color: var(--qlm-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Social Buttons */
.qlm-social-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.qlm-social-btn {
    flex: 1;
    min-width: calc(33.333% - 8px);
    height: 48px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--qlm-border);
    border-radius: 12px;
    color: var(--qlm-text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.qlm-social-btn:hover {
    border-color: var(--qlm-primary);
    background: rgba(0, 212, 170, 0.05);
}

.qlm-social-facebook:hover {
    border-color: #1877F2;
    background: rgba(24, 119, 242, 0.1);
}

.qlm-social-google:hover {
    border-color: #EA4335;
    background: rgba(234, 67, 53, 0.1);
}

.qlm-social-twitter:hover {
    border-color: #1DA1F2;
    background: rgba(29, 161, 242, 0.1);
}

/* Footer */
.qlm-footer {
    text-align: center;
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--qlm-border);
    position: relative;
    z-index: 1;
}

.qlm-footer p {
    margin: 0;
    font-size: 14px;
    color: var(--qlm-text-muted);
}

.qlm-register-link {
    color: var(--qlm-primary);
    text-decoration: none;
    font-weight: 600;
    margin-left: 4px;
    transition: color 0.2s ease;
}

.qlm-register-link:hover {
    color: var(--qlm-secondary);
    text-decoration: underline;
}

/* Success State */
.qlm-success {
    text-align: center;
    padding: 20px 0;
}

.qlm-success-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--qlm-success);
}

.qlm-success-text {
    color: var(--qlm-success);
    font-size: 16px;
    font-weight: 500;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .qlm-overlay {
        padding: 16px;
        align-items: flex-end;
    }
    
    .qlm-modal-content {
        padding: 32px 24px;
        border-radius: 24px 24px 0 0;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .qlm-overlay.qlm-active .qlm-modal-content {
        transform: translateY(0);
    }
    
    .qlm-title {
        font-size: 24px;
    }
    
    .qlm-input {
        height: 52px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .qlm-submit {
        height: 52px;
    }
    
    .qlm-social-btn {
        min-width: 100%;
    }
    
    .qlm-social-btn span {
        display: none;
    }
    
    .qlm-social-btn {
        min-width: calc(33.333% - 8px);
    }
    
    .qlm-options {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .qlm-forgot {
        width: 100%;
        text-align: right;
    }
}

/* Animations */
@keyframes qlm-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.qlm-shake {
    animation: qlm-shake 0.4s ease-in-out;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .qlm-overlay,
    .qlm-modal-content,
    .qlm-input,
    .qlm-submit,
    .qlm-social-btn,
    .qlm-close {
        transition: none;
    }
    
    .qlm-spinner {
        animation: none;
    }
}

/* Dark mode adjustments - already dark by default */
@media (prefers-color-scheme: light) {
    /* Keep dark theme regardless of system preference */
}

/* Hide for logged-in users (backup) */
.logged-in .qlm-overlay {
    display: none !important;
}

/* Menu item trigger styles */
.qlm-trigger {
    cursor: pointer;
}

/* Focus styles for accessibility */
.qlm-input:focus,
.qlm-submit:focus,
.qlm-social-btn:focus,
.qlm-close:focus,
.qlm-checkbox input:focus + .qlm-checkmark {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.3);
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .qlm-modal-content {
        border: 2px solid var(--qlm-text);
    }
    
    .qlm-input {
        border: 2px solid var(--qlm-text);
    }
    
    .qlm-submit {
        border: 2px solid var(--qlm-text);
    }
}
