/* Login Modal Styles */
.pg-auth-modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100000 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Ensure modal is always on top */
.pg-auth-modal-container * {
    z-index: inherit;
}

.pg-auth-modal-container .pg-auth-modal-backdrop {
    z-index: 99999 !important;
}

.pg-auth-modal-container .pg-auth-modal-dialog {
    z-index: 100000 !important;
}

.pg-auth-modal-container.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.pg-auth-modal-container:not(.hidden) {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.pg-auth-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1;
}

.pg-auth-modal-dialog {
    position: relative;
    background: var(--background-color, #fff);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    z-index: 10;
}

.pg-auth-modal-container:not(.hidden) .pg-auth-modal-dialog {
    transform: scale(1);
}

.pg-auth-modal-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border-color, #eee);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pg-auth-modal-heading {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color, #333);
}

.pg-auth-modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted, #666);
    transition: color 0.2s ease;
    padding: 4px;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pg-auth-modal-close-btn:hover {
    color: var(--text-color, #333);
}

.pg-auth-modal-body {
    padding: 24px;
}

/* Auth Forms */
.pg-auth-form-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.pg-auth-form-container.hidden {
    display: none;
}

.pg-auth-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pg-auth-form-group label {
    font-weight: 500;
    color: var(--text-color, #333);
    font-size: 0.9rem;
}

.pg-auth-form-group input {
    padding: 12px 16px;
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: var(--input-background, #fff);
    color: var(--text-color, #333);
}

.pg-auth-form-group input:focus {
    outline: none;
    border-color: var(--primary-color, #007bff);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.pg-auth-form-group input:invalid {
    border-color: var(--error-color, #dc3545);
}

.pg-auth-form-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.pg-auth-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    text-decoration: none;
    display: inline-block;
}

.pg-auth-btn-primary {
    background: var(--primary-color, #007bff);
    color: white;
}

.pg-auth-btn-primary:hover {
    background: var(--primary-color-dark, #0056b3);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.pg-auth-btn-primary:active {
    transform: translateY(0);
}

.pg-auth-btn-secondary {
    background: transparent;
    color: var(--text-muted, #666);
    border: 2px solid var(--border-color, #e0e0e0);
}

.pg-auth-btn-secondary:hover {
    background: var(--background-hover, #f8f9fa);
    border-color: var(--text-muted, #666);
    color: var(--text-color, #333);
}

/* Form Messages */
.pg-auth-form-message {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-weight: 500;
    border: 1px solid transparent;
}

.pg-auth-form-message.hidden {
    display: none;
}

.pg-auth-form-message.error {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.pg-auth-form-message.success {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.pg-auth-form-message.info {
    background: #cce7ff;
    border-color: #b3d7ff;
    color: #004085;
}

/* Better form help text */
.pg-auth-form-help {
    font-size: 13px;
    color: #6c757d;
    margin-top: 6px;
    display: block;
    line-height: 1.4;
}

/* Forgot password link */
.pg-auth-forgot-password-section {
    text-align: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

.pg-auth-btn-link {
    background: none;
    border: none;
    color: #667eea;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.pg-auth-btn-link:hover {
    background: rgba(102, 126, 234, 0.1);
    text-decoration: underline;
}

/* Verification required styles */
.pg-auth-verification-notice {
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border-radius: 8px;
    margin-bottom: 24px;
}

.pg-auth-verification-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.pg-auth-verification-notice h3 {
    color: #2c3e50;
    margin-bottom: 12px;
    font-size: 20px;
    font-weight: 600;
}

.pg-auth-verification-notice p {
    color: #5a6c7d;
    margin-bottom: 8px;
    line-height: 1.5;
}

.pg-auth-verification-email {
    font-weight: 500;
    color: #667eea;
}

/* Dark Mode Support */
[data-theme="dark"] .pg-auth-modal-dialog {
    background: var(--background-dark, #1e1e1e);
    color: var(--text-dark, #e0e0e0);
    border: 1px solid var(--border-dark, #333);
}

[data-theme="dark"] .pg-auth-modal-header {
    border-bottom-color: var(--border-dark, #333);
}

[data-theme="dark"] .pg-auth-modal-heading {
    color: var(--text-dark, #e0e0e0);
}

[data-theme="dark"] .pg-auth-modal-close-btn {
    color: var(--text-muted-dark, #999);
}

[data-theme="dark"] .pg-auth-modal-close-btn:hover {
    color: var(--text-dark, #e0e0e0);
}

[data-theme="dark"] .pg-auth-form-group label {
    color: var(--text-dark, #e0e0e0);
}

[data-theme="dark"] .pg-auth-form-group input {
    background: var(--input-background-dark, #2a2a2a);
    border-color: var(--border-dark, #444);
    color: var(--text-dark, #e0e0e0);
}

[data-theme="dark"] .pg-auth-form-group input:focus {
    border-color: var(--primary-color, #007bff);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

[data-theme="dark"] .pg-auth-btn-secondary {
    color: var(--text-muted-dark, #999);
    border-color: var(--border-dark, #444);
}

[data-theme="dark"] .pg-auth-btn-secondary:hover {
    background: var(--background-hover-dark, #2a2a2a);
    border-color: var(--text-muted-dark, #999);
    color: var(--text-dark, #e0e0e0);
}

/* Responsive Design */
@media (max-width: 768px) {
    .pg-auth-modal-dialog {
        width: 95%;
        margin: 20px;
    }
    
    .pg-auth-modal-header {
        padding: 20px 20px 12px;
    }
    
    .pg-auth-modal-body {
        padding: 20px;
    }
    
    .pg-auth-modal-heading {
        font-size: 1.3rem;
    }
    
    .pg-auth-form-group input {
        padding: 14px 16px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .pg-auth-btn {
        padding: 14px 24px;
        font-size: 1rem;
    }
    
    .verification-container,
    .reset-container {
        margin: 20px;
        padding: 24px;
    }
    
    .verification-title,
    .reset-title {
        font-size: 24px;
    }
    
    .verification-actions {
        flex-direction: column;
    }
    
    .verification-actions .pg-auth-btn {
        width: 100%;
        margin: 8px 0;
    }
}

/* Loading State */
.pg-auth-form-group input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.pg-auth-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.pg-auth-btn-loading {
    position: relative;
    color: transparent !important;
}

.pg-auth-btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Animation */
@keyframes modalSlideIn {
    from {
        transform: scale(0.9) translateY(-20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.pg-auth-modal-container:not(.hidden) .pg-auth-modal-dialog {
    animation: modalSlideIn 0.3s ease-out;
}

/* Focus States */
.pg-auth-btn:focus-visible {
    outline: 2px solid var(--primary-color, #007bff);
    outline-offset: 2px;
}

.pg-auth-form-group input:focus-visible {
    outline: none; /* Custom focus handled by border and box-shadow */
}

/* User Profile Dropdown Styles */
.pg-auth-profile-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--background-color, #fff);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    z-index: 1000;
    padding: 8px 0;
    margin-top: 8px;
}

.pg-auth-profile-dropdown.hidden {
    display: none;
}

.pg-auth-dropdown-item {
    display: block;
    padding: 12px 16px;
    color: var(--text-color, #333);
    text-decoration: none;
    transition: background-color 0.2s ease;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 0.9rem;
}

.pg-auth-dropdown-item:hover {
    background: var(--background-hover, #f8f9fa);
}

.pg-auth-logout-btn {
    color: var(--error-color, #dc3545) !important;
}

.pg-auth-logout-btn:hover {
    background: #fee !important;
}

/* Dark mode for dropdown */
[data-theme="dark"] .pg-auth-profile-dropdown {
    background: var(--background-dark, #1e1e1e);
    border-color: var(--border-dark, #333);
}

[data-theme="dark"] .pg-auth-dropdown-item {
    color: var(--text-dark, #e0e0e0);
}

[data-theme="dark"] .pg-auth-dropdown-item:hover {
    background: var(--background-hover-dark, #2a2a2a);
}

[data-theme="dark"] .pg-auth-logout-btn:hover {
    background: rgba(220, 53, 69, 0.1) !important;
}
