/**
 * Firebase Authentication Styles
 * 
 * Styles for Google Sign-In button, user menu, and notifications.
 * 
 * @package AIPromptGallery
 */

/* ==========================================================================
   Sign In Button
   ========================================================================== */

.aipg-signin-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #ffffff;
    border: 1px solid #dadce0;
    border-radius: 24px;
    color: #3c4043;
    font-family: 'Google Sans', Roboto, Arial, sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.aipg-signin-btn:hover {
    background: #f8f9fa;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.aipg-signin-btn:active {
    background: #f1f3f4;
}

.aipg-signin-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.3);
}

.aipg-signin-btn.aipg-loading {
    opacity: 0.7;
    pointer-events: none;
}

.aipg-signin-btn.aipg-loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid #dadce0;
    border-top-color: #4285f4;
    border-radius: 50%;
    animation: aipg-spin 0.8s linear infinite;
}

.aipg-signin-btn svg,
.aipg-signin-btn img {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Google "G" Logo */
.aipg-google-logo {
    width: 18px;
    height: 18px;
}

/* ==========================================================================
   User Menu
   ========================================================================== */

.aipg-user-menu {
    display: none;
    align-items: center;
    position: relative;
}

.aipg-user-menu-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 24px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.aipg-user-menu-toggle:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: #dadce0;
}

.aipg-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: #e8eaed;
}

.aipg-user-name {
    font-size: 14px;
    font-weight: 500;
    color: #3c4043;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aipg-user-menu-arrow {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid #5f6368;
    transition: transform 0.2s;
}

.aipg-dropdown-open .aipg-user-menu-arrow {
    transform: rotate(180deg);
}

/* ==========================================================================
   User Dropdown
   ========================================================================== */

.aipg-user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
    z-index: 1000;
    overflow: hidden;
}

.aipg-user-dropdown.aipg-dropdown-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.aipg-dropdown-header {
    padding: 16px;
    border-bottom: 1px solid #e8eaed;
    display: flex;
    align-items: center;
    gap: 12px;
}

.aipg-dropdown-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: #e8eaed;
}

.aipg-dropdown-user-info {
    flex: 1;
    min-width: 0;
}

.aipg-dropdown-name {
    font-size: 14px;
    font-weight: 600;
    color: #202124;
    margin: 0 0 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aipg-dropdown-email {
    font-size: 12px;
    color: #5f6368;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aipg-dropdown-menu {
    padding: 8px 0;
    list-style: none;
    margin: 0;
}

.aipg-dropdown-item {
    margin: 0;
}

.aipg-dropdown-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: #3c4043;
    font-size: 14px;
    text-decoration: none;
    transition: background-color 0.15s;
}

.aipg-dropdown-link:hover {
    background: #f1f3f4;
    color: #202124;
}

.aipg-dropdown-link svg {
    width: 20px;
    height: 20px;
    color: #5f6368;
    flex-shrink: 0;
}

.aipg-dropdown-divider {
    height: 1px;
    background: #e8eaed;
    margin: 8px 0;
}

.aipg-dropdown-link.aipg-signout-btn {
    color: #d93025;
}

.aipg-dropdown-link.aipg-signout-btn:hover {
    background: #fce8e6;
}

.aipg-dropdown-link.aipg-signout-btn svg {
    color: #d93025;
}

/* ==========================================================================
   Favorite Button
   ========================================================================== */

.aipg-favorite-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    background: #fff;
    border: 1px solid #dadce0;
    border-radius: 20px;
    color: #5f6368;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.aipg-favorite-btn:hover {
    border-color: #d93025;
    color: #d93025;
}

.aipg-favorite-btn.aipg-favorited {
    background: #fce8e6;
    border-color: #d93025;
    color: #d93025;
}

.aipg-favorite-btn.aipg-favorited .aipg-heart-icon {
    fill: #d93025;
}

.aipg-favorite-btn.aipg-disabled {
    opacity: 0.6;
}

.aipg-favorite-btn .aipg-heart-icon {
    width: 18px;
    height: 18px;
    transition: fill 0.2s, transform 0.2s;
}

.aipg-favorite-btn:hover .aipg-heart-icon {
    transform: scale(1.1);
}

.aipg-favorite-btn.aipg-loading .aipg-heart-icon {
    animation: aipg-pulse 0.6s ease-in-out infinite;
}

/* ==========================================================================
   Notifications
   ========================================================================== */

.aipg-notification {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 20px;
    background: #323232;
    color: #fff;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 400px;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
}

.aipg-notification-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.aipg-notification-success {
    background: #0f9d58;
}

.aipg-notification-error {
    background: #d93025;
}

.aipg-notification-info {
    background: #4285f4;
}

.aipg-notification-message {
    flex: 1;
}

.aipg-notification-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.aipg-notification-close:hover {
    color: #fff;
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes aipg-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes aipg-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .aipg-signin-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .aipg-signin-btn span {
        display: none;
    }
    
    .aipg-user-name {
        display: none;
    }
    
    .aipg-user-menu-toggle {
        padding: 4px;
    }
    
    .aipg-user-dropdown {
        right: -10px;
        min-width: 260px;
    }
    
    .aipg-notification {
        left: 16px;
        right: 16px;
        transform: translateX(0) translateY(100px);
        max-width: none;
    }
    
    .aipg-notification-visible {
        transform: translateX(0) translateY(0);
    }
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

[data-aipg-theme="dark"] {
    .aipg-signin-btn {
        background: #3c4043;
        border-color: #5f6368;
        color: #e8eaed;
    }
    
    .aipg-signin-btn:hover {
        background: #4a4d51;
    }
    
    .aipg-user-menu-toggle:hover {
        background: rgba(255, 255, 255, 0.08);
        border-color: #5f6368;
    }
    
    .aipg-user-name {
        color: #e8eaed;
    }
    
    .aipg-user-menu-arrow {
        border-top-color: #9aa0a6;
    }
    
    .aipg-user-dropdown {
        background: #2d2d2d;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    }
    
    .aipg-dropdown-header {
        border-bottom-color: #5f6368;
    }
    
    .aipg-dropdown-name {
        color: #e8eaed;
    }
    
    .aipg-dropdown-email {
        color: #9aa0a6;
    }
    
    .aipg-dropdown-link {
        color: #e8eaed;
    }
    
    .aipg-dropdown-link:hover {
        background: #3c4043;
        color: #fff;
    }
    
    .aipg-dropdown-link svg {
        color: #9aa0a6;
    }
    
    .aipg-dropdown-divider {
        background: #5f6368;
    }
    
    .aipg-favorite-btn {
        background: #2d2d2d;
        border-color: #5f6368;
        color: #9aa0a6;
    }
}

/* Theme support for sites with custom dark mode class */
body.dark-mode .aipg-signin-btn,
body.theme-dark .aipg-signin-btn,
[data-theme="dark"] .aipg-signin-btn {
    background: #3c4043;
    border-color: #5f6368;
    color: #e8eaed;
}

/* ==========================================================================
   Profile Editor Modal
   ========================================================================== */

.aipg-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.aipg-modal-overlay.aipg-modal-open {
    opacity: 1;
    visibility: visible;
}

.aipg-modal {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(20px) scale(0.95);
    transition: transform 0.2s;
}

.aipg-modal-open .aipg-modal {
    transform: translateY(0) scale(1);
}

.aipg-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.aipg-modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #111827;
}

.aipg-modal-close {
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #6b7280;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}

.aipg-modal-close:hover {
    background: #f3f4f6;
    color: #111827;
}

.aipg-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.aipg-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

/* Form Groups */
.aipg-form-group {
    margin-bottom: 20px;
}

.aipg-form-group:last-child {
    margin-bottom: 0;
}

.aipg-form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.aipg-form-group input[type="text"],
.aipg-form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}

.aipg-form-group input[type="text"]:focus,
.aipg-form-group textarea:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.aipg-form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.aipg-form-hint {
    margin: 6px 0 0;
    font-size: 12px;
    color: #6b7280;
}

.aipg-form-status {
    margin: 6px 0 0;
    font-size: 12px;
    min-height: 18px;
}

.aipg-status-success {
    color: #059669;
}

.aipg-status-error {
    color: #dc2626;
}

.aipg-form-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    margin-top: 16px;
}

/* Input with prefix (username) */
.aipg-input-with-prefix {
    display: flex;
    align-items: stretch;
}

.aipg-input-prefix {
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-right: none;
    border-radius: 8px 0 0 8px;
    color: #6b7280;
    font-size: 14px;
}

.aipg-input-with-prefix input {
    border-radius: 0 8px 8px 0;
    flex: 1;
}

/* Avatar Upload */
.aipg-avatar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding-bottom: 10px;
}

.aipg-avatar-preview {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: 8px;
}

.aipg-avatar-preview img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #e5e7eb;
}

.aipg-avatar-upload-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #6366f1;
    border: 2px solid #fff;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.15s;
}

.aipg-avatar-upload-btn:hover {
    background: #4f46e5;
    transform: scale(1.1);
}

/* Buttons */
.aipg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
}

.aipg-btn-primary {
    background: #6366f1;
    color: #fff;
}

.aipg-btn-primary:hover {
    background: #4f46e5;
}

.aipg-btn-primary:disabled {
    background: #a5b4fc;
    cursor: not-allowed;
}

.aipg-btn-secondary {
    background: #fff;
    color: #374151;
    border: 1px solid #d1d5db;
}

.aipg-btn-secondary:hover {
    background: #f9fafb;
}

/* Mobile Responsive */
@media (max-width: 500px) {
    .aipg-modal {
        max-height: 100vh;
        border-radius: 16px 16px 0 0;
        margin-top: auto;
    }
    
    .aipg-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
    
    .aipg-modal-body {
        padding: 20px;
    }
    
    .aipg-modal-footer {
        flex-direction: column-reverse;
    }
    
    .aipg-btn {
        width: 100%;
    }
}

/* Dark Mode Support */
[data-aipg-theme="dark"] {
    .aipg-modal {
        background: #1f2937;
    }
    
    .aipg-modal-header {
        border-bottom-color: #374151;
    }
    
    .aipg-modal-header h2 {
        color: #f9fafb;
    }
    
    .aipg-modal-close {
        color: #9ca3af;
    }
    
    .aipg-modal-close:hover {
        background: #374151;
        color: #f9fafb;
    }
    
    .aipg-modal-footer {
        border-top-color: #374151;
        background: #111827;
    }
    
    .aipg-form-group label {
        color: #e5e7eb;
    }
    
    .aipg-form-group input[type="text"],
    .aipg-form-group textarea {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .aipg-form-group input[type="text"]:focus,
    .aipg-form-group textarea:focus {
        border-color: #6366f1;
    }
    
    .aipg-input-prefix {
        background: #374151;
        border-color: #4b5563;
        color: #9ca3af;
    }
    
    .aipg-form-hint {
        color: #9ca3af;
    }
    
    .aipg-btn-secondary {
        background: #374151;
        color: #e5e7eb;
        border-color: #4b5563;
    }
    
    .aipg-btn-secondary:hover {
        background: #4b5563;
    }
}
