/**
 * ProfileDropdown Component Styles
 * 
 * A self-contained, accessible profile dropdown component following FAANG-level engineering standards.
 * Supports themes, responsive design, accessibility, and reduced motion preferences.
 */

/* Component Root */
.profile-dropdown {
    position: relative;
    display: inline-block;
    isolation: isolate;
}

/* Trigger Button */
.profile-dropdown__trigger {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    border: 2px solid var(--border-light, #e5e7eb);
    background: var(--surface-elevated, #ffffff);
    color: var(--text-primary, #1f2937);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    min-height: 44px; /* Touch target size */
    position: relative;
    overflow: hidden;
}

.profile-dropdown__trigger::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--primary, #3b82f6);
    opacity: 0;
    transition: opacity 0.2s ease;
    border-radius: inherit;
}

.profile-dropdown__trigger:hover {
    border-color: var(--primary, #3b82f6);
    transform: translateY(-1px);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.06);
}

.profile-dropdown__trigger:hover::before {
    opacity: 0.05;
}

.profile-dropdown__trigger:focus {
    outline: 2px solid var(--primary, #3b82f6);
    outline-offset: 2px;
    border-color: var(--primary, #3b82f6);
}

.profile-dropdown__trigger:active {
    transform: translateY(0);
    transition-duration: 0.1s;
}

/* Avatar */
.profile-dropdown__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-light, #e5e7eb);
    transition: border-color 0.2s ease;
    flex-shrink: 0;
}

.profile-dropdown__trigger:hover .profile-dropdown__avatar {
    border-color: var(--primary, #3b82f6);
}

/* Name */
.profile-dropdown__name {
    font-weight: 600;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

/* Chevron */
.profile-dropdown__chevron {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
    flex-shrink: 0;
    margin-left: auto;
}

.profile-dropdown.open .profile-dropdown__chevron {
    transform: rotate(180deg);
}

/* Dropdown Menu */
.profile-dropdown__menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 240px;
    background: var(--surface-elevated, #ffffff);
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 12px;
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 0.5rem;
    overflow: hidden;
}

.profile-dropdown.open .profile-dropdown__menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Menu Arrow */
.profile-dropdown__menu::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 20px;
    width: 12px;
    height: 12px;
    background: var(--surface-elevated, #ffffff);
    border: 1px solid var(--border-light, #e5e7eb);
    border-bottom: none;
    border-right: none;
    transform: rotate(45deg);
    z-index: -1;
}

/* Menu Items */
.profile-dropdown__item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary, #1f2937);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.15s ease;
    font-weight: 500;
    font-size: 0.875rem;
    border: none;
    background: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-family: inherit;
    min-height: 44px; /* Touch target size */
    position: relative;
    overflow: hidden;
}

.profile-dropdown__item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--primary, #3b82f6);
    opacity: 0;
    transition: opacity 0.15s ease;
    border-radius: inherit;
}

.profile-dropdown__item:hover {
    color: var(--primary, #3b82f6);
    transform: translateX(2px);
}

.profile-dropdown__item:hover::before {
    opacity: 0.08;
}

.profile-dropdown__item:focus {
    outline: 2px solid var(--primary, #3b82f6);
    outline-offset: -2px;
    color: var(--primary, #3b82f6);
}

.profile-dropdown__item:focus::before {
    opacity: 0.08;
}

.profile-dropdown__item:active {
    transform: translateX(0);
    transition-duration: 0.1s;
}

/* Item Icons */
.profile-dropdown__item i {
    font-size: 1rem;
    width: 18px;
    text-align: center;
    opacity: 0.8;
    flex-shrink: 0;
}

/* Separator */
.profile-dropdown__separator {
    height: 1px;
    background: var(--border-light, #e5e7eb);
    margin: 0.5rem 0;
}

/* Admin Section */
.profile-dropdown__admin-section {
    /* Styling handled by individual items */
}

/* Danger Item (Logout) */
.profile-dropdown__item--danger {
    color: var(--danger, #dc2626);
}

.profile-dropdown__item--danger::before {
    background: var(--danger, #dc2626);
}

.profile-dropdown__item--danger:hover {
    color: var(--danger, #dc2626);
}

.profile-dropdown__item--danger:focus {
    outline-color: var(--danger, #dc2626);
    color: var(--danger, #dc2626);
}

/* Auth Actions (for non-authenticated users) */
.profile-dropdown__auth-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.profile-dropdown__auth-actions .btn {
    min-height: 44px; /* Touch target size */
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: 2px solid transparent;
}

.btn--primary {
    background: var(--primary, #3b82f6);
    color: white;
    border-color: var(--primary, #3b82f6);
}

.btn--primary:hover {
    background: var(--primary-dark, #2563eb);
    border-color: var(--primary-dark, #2563eb);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn--secondary {
    background: transparent;
    color: var(--text-primary, #1f2937);
    border-color: var(--border-light, #e5e7eb);
}

.btn--secondary:hover {
    background: var(--surface-elevated, #f8fafc);
    border-color: var(--primary, #3b82f6);
    color: var(--primary, #3b82f6);
    transform: translateY(-1px);
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .profile-dropdown__trigger {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .profile-dropdown__name {
        display: none;
    }
    
    .profile-dropdown__chevron {
        display: none;
    }
    
    .profile-dropdown__menu {
        right: -10px;
        min-width: 200px;
    }
    
    .profile-dropdown__menu::before {
        right: 30px;
    }
    
    .profile-dropdown__auth-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .profile-dropdown__auth-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Dark Theme Support */
[data-theme="dark"] .profile-dropdown__trigger {
    background: var(--surface-elevated, #374151);
    border-color: var(--border-light, #4b5563);
    color: var(--text-primary, #f9fafb);
}

[data-theme="dark"] .profile-dropdown__menu {
    background: var(--surface-elevated, #374151);
    border-color: var(--border-light, #4b5563);
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.4),
        0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .profile-dropdown__menu::before {
    background: var(--surface-elevated, #374151);
    border-color: var(--border-light, #4b5563);
}

[data-theme="dark"] .profile-dropdown__separator {
    background: var(--border-light, #4b5563);
}

[data-theme="dark"] .btn--secondary {
    color: var(--text-primary, #f9fafb);
    border-color: var(--border-light, #4b5563);
}

[data-theme="dark"] .btn--secondary:hover {
    background: var(--surface-elevated, #4b5563);
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .profile-dropdown__trigger {
        border-width: 3px;
    }
    
    .profile-dropdown__menu {
        border-width: 2px;
    }
    
    .profile-dropdown__item:focus {
        outline-width: 3px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .profile-dropdown__trigger,
    .profile-dropdown__menu,
    .profile-dropdown__chevron,
    .profile-dropdown__item,
    .profile-dropdown__item::before,
    .profile-dropdown__trigger::before {
        transition: none;
    }
}

/* Focus Management */
.profile-dropdown__menu:focus-within .profile-dropdown__item:focus {
    outline: 3px solid var(--primary, #3b82f6);
    outline-offset: -3px;
}

/* Animation for closing */
.profile-dropdown__menu.closing {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.95);
    transition: all 0.15s ease;
}

/* Logout Confirmation Modal */
.logout-confirmation-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: modalFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg,
        rgba(0, 0, 0, 0.4) 0%,
        rgba(0, 0, 0, 0.6) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.modal-content {
    position: relative;
    background: var(--surface-elevated, #ffffff);
    border-radius: 24px;
    padding: 3rem 2.5rem 2.5rem;
    box-shadow:
        0 32px 64px rgba(0, 0, 0, 0.25),
        0 8px 24px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    max-width: 480px;
    width: 100%;
    text-align: center;
    animation: modalSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--border-light, #e5e7eb);
    overflow: hidden;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg,
        #ef4444 0%,
        #f97316 25%,
        #eab308 50%,
        #ef4444 100%);
    background-size: 200% 100%;
    animation: modalGradientShift 3s ease-in-out infinite;
}

.modal-icon {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: linear-gradient(135deg,
        rgba(239, 68, 68, 0.1) 0%,
        rgba(239, 68, 68, 0.2) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid rgba(239, 68, 68, 0.2);
    animation: modalIconPulse 2s ease-in-out infinite;
}

.modal-icon i {
    font-size: 2rem;
    color: #ef4444;
    animation: modalIconBounce 0.6s ease-out;
}

.modal-content h3 {
    color: var(--text-primary, #1f2937);
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.modal-content p {
    color: var(--text-secondary, #6b7280);
    margin-bottom: 2.5rem;
    line-height: 1.6;
    font-size: 1rem;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-actions .btn {
    padding: 0.875rem 2rem;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 120px;
    font-size: 0.95rem;
    position: relative;
    overflow: hidden;
    text-transform: none;
    font-family: inherit;
}

.btn-secondary {
    background: var(--surface-elevated, #f8fafc);
    color: var(--text-primary, #374151);
    border: 2px solid var(--border-light, #e5e7eb);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
    background: var(--border-light, #e5e7eb);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    border-color: var(--primary, #3b82f6);
}

.btn-danger {
    background: linear-gradient(135deg,
        #ef4444 0%,
        #dc2626 100%);
    color: white;
    border: 2px solid transparent;
    box-shadow:
        0 4px 16px rgba(239, 68, 68, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-danger:hover {
    background: linear-gradient(135deg,
        #dc2626 0%,
        #b91c1c 100%);
    transform: translateY(-3px);
    box-shadow:
        0 8px 24px rgba(239, 68, 68, 0.4),
        0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Modal Animations */
@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translate3d(0, -60px, 0) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
}

@keyframes modalGradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes modalIconPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 15px rgba(239, 68, 68, 0);
    }
}

@keyframes modalIconBounce {
    0% {
        transform: scale(0.3) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) rotate(-90deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Modal Responsive Design */
@media (max-width: 640px) {
    .modal-content {
        padding: 2rem 1.5rem;
        margin: 1rem;
        border-radius: 20px;
    }

    .modal-icon {
        width: 64px;
        height: 64px;
        margin-bottom: 1rem;
    }

    .modal-icon i {
        font-size: 1.5rem;
    }

    .modal-content h3 {
        font-size: 1.25rem;
    }

    .modal-content p {
        font-size: 0.9rem;
    }

    .modal-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .modal-actions .btn {
        width: 100%;
        padding: 1rem;
    }
}

/* Dark Theme Modal Support */
[data-theme="dark"] .modal-content {
    background: var(--surface-elevated, #374151);
    border: 1px solid var(--border-light, #4b5563);
    box-shadow:
        0 32px 64px rgba(0, 0, 0, 0.6),
        0 8px 24px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .modal-content h3 {
    color: var(--text-primary, #f9fafb);
}

[data-theme="dark"] .modal-content p {
    color: var(--text-secondary, #d1d5db);
}

[data-theme="dark"] .btn-secondary {
    background: var(--surface-elevated, #4b5563);
    color: var(--text-primary, #f9fafb);
    border-color: var(--border-light, #6b7280);
}

[data-theme="dark"] .btn-secondary:hover {
    background: var(--border-light, #6b7280);
    border-color: var(--primary, #60a5fa);
}
