/**
 * Authentication Modal Styles
 * Login/Signup modal and user account UI
 */

:root {
    --auth-primary: #4a7c28;
    --auth-primary-dark: #2d5016;
    --auth-primary-light: #6fa548;
    --auth-secondary: #f0f9f4;
    --auth-border: #e2e8f0;
    --auth-error: #ef4444;
    --auth-success: #22c55e;
    --auth-text: #333;
    --auth-text-light: #666;
}

/* User Account Section in Header */
.user-account-section {
    display: flex;
    align-items: center;
    margin-left: auto;
    margin-right: 1rem;
}

.auth-button {
    /* Match nav-item styling from main CSS */
    color: rgba(255, 255, 255, 0.92);
    font-family: var(--font-heading);
    font-weight: 600;
    text-decoration: none;
    display: flex;
    align-items: center;
    padding: 0.8rem 1.2rem; /* Same padding as nav-item */
    font-size: 1.1rem; /* Same font size as nav-item */
    gap: 0.5rem;
    border-radius: 8px;
    position: relative;
    transition: all 0.3s ease;

    /* Match partner button gradient styling */
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--secondary-green) 50%, var(--tertiary-green) 100%) !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 4px 15px rgba(30, 74, 53, 0.3) !important;
    cursor: pointer;
    white-space: nowrap; /* Prevent text wrapping */
    flex-shrink: 0; /* Prevent button from shrinking */
}

.auth-button:hover {
    color: #ffffff;
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.5), 0 2px 4px rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, var(--secondary-green) 0%, var(--tertiary-green) 50%, var(--primary-green) 100%) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(30, 74, 53, 0.5) !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
}

/* User Dropdown */
.user-dropdown {
    position: relative;
}

.user-dropdown-toggle {
    /* Match header button styling */
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--secondary-green) 50%, var(--tertiary-green) 100%);
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92);
    font-family: var(--font-heading);
    transition: all 0.3s ease;
    font-size: 1.1rem;
    box-shadow: 0 4px 15px rgba(30, 74, 53, 0.3);
    position: relative;
}

.user-dropdown-toggle:hover {
    background: linear-gradient(135deg, var(--secondary-green) 0%, var(--tertiary-green) 50%, var(--primary-green) 100%);
    border-color: rgba(255, 255, 255, 0.5);
    color: #ffffff;
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.5), 0 2px 4px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(30, 74, 53, 0.5);
}

.user-dropdown-toggle i {
    font-size: 1.15em;
}

.user-dropdown-menu {
    position: fixed; /* Changed to fixed to position relative to viewport */
    top: 100px; /* Position at bottom of 100px header */
    right: 20px; /* Keep aligned to right side */
    background: linear-gradient(180deg,
        #1a3d2e 0%,
        #1e4a35 20%,
        #2d5f47 60%,
        #1e4a35 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    min-width: 220px;
    max-height: calc(100vh - 120px); /* Limit height to viewport minus header */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow-y: auto; /* Allow scrolling if content is too long */
    overflow-x: hidden;
}

.user-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* User info section in dropdown */
.dropdown-user-info {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.2);
}

.dropdown-username {
    color: var(--accent-gold);
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.dropdown-email {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.95);
    text-decoration: none;
    transition: all 0.3s ease;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    position: relative;
    /* Touch optimization for tablets */
    min-height: 44px;
    touch-action: manipulation;
}

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

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    transform: translateX(5px);
}

.dropdown-item:hover::before {
    left: 100%;
}

.dropdown-item i {
    color: var(--accent-gold);
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.dropdown-item.logout-btn {
    color: rgba(255, 255, 255, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    margin-top: 8px;
    padding: 14px 20px; /* Ensure consistent padding */
    font-size: 0.95rem; /* Match other items */
    font-weight: 500; /* Match other items */
    background: rgba(239, 68, 68, 0.1); /* Subtle red background */
    /* Ensure form button matches dropdown-item styling */
    width: 100%;
    font-family: var(--font-heading);
}

.dropdown-item.logout-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #ff6b6b;
    transform: translateX(5px); /* Match other items' hover effect */
}

.dropdown-item.logout-btn i {
    color: #ff6b6b;
    font-size: 1.1rem; /* Match other icons */
    width: 20px; /* Match other icons */
    text-align: center; /* Match other icons */
}

.dropdown-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0;
}

/* Mobile User Account - Always visible when menu is open */
.mobile-user-account {
    /* Ensure always visible - no collapsing */
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.mobile-user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 15px 20px;
    color: rgba(255, 255, 255, 0.95);
    background: rgba(0, 0, 0, 0.2); /* Subtle dark background (matches desktop dropdown-user-info) */
    border-bottom: 1px solid rgba(255, 255, 255, 0.15); /* Bottom border for separation */
    font-weight: 500;
    font-size: 0.95rem;
    margin-bottom: 0; /* No extra margin needed */
}

.mobile-user-info i {
    color: var(--accent-gold);
    font-size: 1.15rem;
}

.mobile-nav-item.auth-button {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--secondary-green) 50%, var(--tertiary-green) 100%);
    justify-content: center;
    font-weight: 600;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(30, 74, 53, 0.3);
    /* Touch optimization */
    min-height: 48px; /* Comfortable touch target */
    touch-action: manipulation; /* Prevent double-tap zoom */
    -webkit-tap-highlight-color: rgba(46, 204, 113, 0.2);
}

.mobile-nav-item.logout-btn {
    color: rgba(255, 255, 255, 0.95);
    background: rgba(239, 68, 68, 0.1); /* Subtle red background (matches desktop) */
    border: none; /* Removed border to match desktop */
    /* Touch optimization */
    min-height: 48px; /* Comfortable touch target */
    touch-action: manipulation; /* Prevent double-tap zoom */
    -webkit-tap-highlight-color: rgba(239, 68, 68, 0.2);
    /* Ensure form button matches mobile-nav-item styling */
    width: 100%;
    font-family: var(--font-heading);
    font-weight: 500; /* Match desktop logout styling */
    font-size: 0.95rem; /* Match desktop */
    padding: 14px 20px; /* Match desktop logout padding */
}

.mobile-nav-item.logout-btn i {
    color: #ff6b6b; /* Red icon */
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.mobile-nav-item.logout-btn:hover {
    background: rgba(239, 68, 68, 0.25); /* Match desktop hover */
    color: #ff6b6b; /* Match desktop hover */
}

/* Auth Modal Overlay */
.auth-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-modal-overlay.show {
    display: flex;
    opacity: 1;
}

/* Auth Modal Content */
.auth-modal-content {
    background: linear-gradient(to bottom, #ffffff, #fafafa);
    border-radius: 16px;
    padding: 2rem 2rem 1.5rem;
    max-width: 450px;
    width: 90%;
    margin: 1rem;
    position: relative;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(74, 124, 40, 0.1);
}

.auth-modal-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #999;
    cursor: pointer;
    /* Touch target optimization - WCAG 2.5.5 compliant */
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 10;
}

.auth-modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

/* Logo Styles */
.auth-logo {
    width: 160px;
    height: auto;
    display: block;
    margin: 0 auto 1rem auto;
}

/* Auth Form Styles */
.auth-form {
    position: relative;
}

.auth-form h2 {
    color: var(--auth-primary-dark);
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    text-align: center;
    font-weight: 700;
}

.auth-subtitle {
    color: #666;
    text-align: center;
    margin-bottom: 1rem;
    font-size: 1rem;
    font-weight: 500;
}

.form-group {
    margin-bottom: 0.875rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    color: #333;
    font-weight: 600;
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 0.625rem;
    border: 2px solid #e8e8e8;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    background: #fafafa;
}

.form-group input:focus {
    outline: none;
    border-color: var(--auth-primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(74, 124, 40, 0.08);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: #666;
    font-size: 0.85rem;
}

/* Form Messages */
.form-error {
    background: #fef2f2;
    color: var(--auth-error);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
    border: 1px solid #fecaca;
}

.form-success {
    background: #f0fdf4;
    color: var(--auth-success);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
    border: 1px solid #bbf7d0;
}

/* Submit Button */
.auth-submit-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--auth-primary) 0%, var(--auth-primary-light) 100%);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(74, 124, 40, 0.2);
    letter-spacing: 0.5px;
    /* Touch optimization */
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(74, 124, 40, 0.2);
}

.auth-submit-btn:hover {
    background: linear-gradient(135deg, var(--auth-primary-dark) 0%, var(--auth-primary) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(74, 124, 40, 0.3);
}

.auth-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Auth Links */
.auth-links {
    text-align: center;
    margin-top: 0.75rem;
}

.auth-links a {
    color: var(--auth-primary);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.3s ease;
}

.auth-links a:hover {
    color: var(--auth-primary-dark);
    text-decoration: underline;
}

/* Auth Divider */
.auth-divider {
    display: flex;
    align-items: center;
    margin: 1rem 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e0e0e0;
}

.auth-divider span {
    padding: 0 1rem;
    color: #999;
    font-size: 0.9rem;
}

/* Auth Switch */
.auth-switch {
    text-align: center;
}

.auth-switch p {
    color: #666;
    margin-bottom: 0.5rem;
}

.auth-switch-btn {
    background: none;
    border: 1px solid var(--auth-primary);
    color: var(--auth-primary);
    padding: 0.5rem 1.5rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    /* Touch optimization */
    min-height: 40px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(74, 124, 40, 0.1);
}

.auth-switch-btn:hover {
    background: var(--auth-secondary);
    color: var(--auth-primary-dark);
    border-color: var(--auth-primary);
}

/* SSO Buttons */
.sso-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.sso-button {
    width: 100%;
    padding: 0.625rem;
    border-radius: 6px;
    border: 1px solid var(--auth-border);
    background: white;
    color: var(--auth-text);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    /* Touch optimization */
    min-height: 40px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.05);
}

.sso-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sso-button.google {
    border-color: #4285f4;
}

.sso-button.google:hover {
    background: #f0f7ff;
    border-color: #1a73e8;
}

.sso-button.discord {
    border-color: #5865f2;
}

.sso-button.discord:hover {
    background: #f6f6fe;
    border-color: #4752c4;
}

.sso-button i {
    font-size: 1.2rem;
}

.sso-button.google i {
    color: #4285f4;
}

.sso-button.discord i {
    color: #5865f2;
}

/* Mobile Navigation Auth Button - Unified Styling */
.mobile-nav-item.auth-button:hover {
    background: linear-gradient(135deg, var(--secondary-green) 0%, var(--tertiary-green) 50%, var(--primary-green) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(30, 74, 53, 0.5);
}

/* Responsive Design */
@media (max-width: 768px) {
    .auth-modal-content {
        padding: 2rem 1.5rem;
        max-height: 90vh; /* Prevent modal from exceeding viewport */
        overflow-y: auto; /* Enable scrolling if content is tall */
    }

    .auth-form h2 {
        font-size: 1.75rem;
    }

    .user-account-section {
        margin-right: 0.5rem;
    }

    .auth-button {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        /* Ensure minimum touch target on mobile */
        min-height: 44px;
    }

    /* Touch target optimization for all buttons in modal */
    .auth-submit-btn {
        padding: 0.875rem; /* Increased from 0.75rem */
        min-height: 48px; /* Comfortable touch target */
        font-size: 1rem;
    }

    .sso-button {
        padding: 0.75rem; /* Increased from 0.625rem */
        min-height: 44px; /* Ensure minimum touch target */
    }

    .auth-switch-btn {
        padding: 0.625rem 1.5rem; /* Increased vertical padding */
        min-height: 44px;
    }

    /* Ensure form inputs are touch-friendly */
    .form-group input {
        min-height: 44px;
        padding: 0.75rem; /* Increased from 0.625rem */
    }

    /* Make modal close button more prominent on mobile */
    .auth-modal-close {
        top: 1rem;
        right: 1rem;
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
        background: rgba(0, 0, 0, 0.05);
        font-size: 1.5rem;
    }

    .auth-modal-close:hover {
        background: rgba(0, 0, 0, 0.1);
    }
}

/* Very small screens (480px and below) */
@media (max-width: 480px) {
    .auth-modal-content {
        width: 95%;
        padding: 1.5rem 1rem;
        margin: 0.5rem;
    }

    .auth-logo {
        width: 140px;
    }

    .auth-form h2 {
        font-size: 1.5rem;
    }

    .auth-subtitle {
        font-size: 0.9rem;
    }

    /* Stack SSO buttons for very small screens if needed */
    .sso-buttons {
        gap: 0.625rem;
    }

    .sso-button {
        font-size: 0.85rem;
        min-height: 44px; /* Maintain touch target */
    }

    /* Adjust modal close button */
    .auth-modal-close {
        top: 0.75rem;
        right: 0.75rem;
    }
}