/*
 * Croplod Profile Modal
 * Google Account style, bottom sheet on mobile
 */

/* Overlay */
.profile-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 400;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

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

/* Modal */
.profile-modal {
    position: fixed;
    top: calc(var(--header-height) + 8px);
    left: 16px;
    width: 320px;
    max-height: calc(100vh - var(--header-height) - 24px);
    overflow-y: auto;
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 28px;
    box-shadow: var(--card-shadow-elevated);
    z-index: 500;
    overflow: hidden;
    transform: scale(0.92) translateY(-12px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.28s cubic-bezier(0.2, 0, 0, 1);
    direction: rtl;
    font-family: var(--font-family);
}

.profile-modal.active {
    transform: scale(1) translateY(0);
    opacity: 1;
    visibility: visible;
}

/* Top bar */
.pm-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 0;
}

.pm-topbar-email {
    font-size: 13px;
    color: var(--text-secondary);
    direction: ltr;
    text-align: center;
    flex: 1;
}

.pm-topbar-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease;
    flex-shrink: 0;
}

.pm-topbar-close:hover {
    background-color: var(--bg-hover);
}

.pm-topbar-close svg {
    width: 20px;
    height: 20px;
}

/* Avatar section */
.pm-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 20px 0;
}

.pm-avatar-wrap {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 14px;
}

.pm-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, var(--color-primary-400), var(--color-secondary-400));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 600;
    color: white;
}

[data-theme="dark"] .pm-avatar {
    background: linear-gradient(135deg, var(--color-primary-400), var(--color-secondary-400));
}

.pm-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pm-avatar-camera {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--bg-card);
    border: 2px solid var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background-color 0.15s ease;
}

.pm-avatar-camera:hover {
    background-color: var(--bg-hover);
}

.pm-avatar-camera svg {
    width: 14px;
    height: 14px;
}

/* Greeting */
.pm-greeting {
    font-size: 22px;
    font-weight: 400;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 20px;
}

/* Manage button */
.pm-manage-btn {
    display: block;
    margin: 0 24px 20px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-primary-600);
    background-color: transparent;
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    text-decoration: none;
    font-family: var(--font-family);
    width: calc(100% - 48px);
}

.pm-manage-btn:hover {
    background-color: rgba(99, 102, 241, 0.06);
    border-color: rgba(99, 102, 241, 0.5);
}

[data-theme="dark"] .pm-manage-btn {
    color: var(--color-primary-300);
    border-color: rgba(129, 140, 248, 0.3);
}

[data-theme="dark"] .pm-manage-btn:hover {
    background-color: rgba(129, 140, 248, 0.08);
}

/* Accounts section */
.pm-accounts-section {
    margin: 0 16px 16px;
    background-color: var(--bg-tertiary);
    border-radius: 16px;
    overflow: hidden;
}

.pm-accounts-list {
    display: flex;
    flex-direction: column;
}

.pm-account-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.pm-account-item:hover {
    background-color: var(--bg-hover);
}

.pm-account-item.active {
    background-color: rgba(99, 102, 241, 0.08);
}

.pm-account-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, var(--color-primary-400), var(--color-secondary-400));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.pm-account-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pm-account-info {
    flex: 1;
    min-width: 0;
}

.pm-account-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pm-account-email {
    font-size: 11px;
    color: var(--text-tertiary);
    direction: ltr;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pm-account-check {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--color-primary-500);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pm-account-check svg {
    width: 18px;
    height: 18px;
}

/* Bottom actions */
.pm-bottom-actions {
    display: flex;
    gap: 0;
    margin: 0 16px 16px;
    background-color: var(--bg-tertiary);
    border-radius: 24px;
    overflow: hidden;
}

.pm-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease;
    text-decoration: none;
    font-family: var(--font-family);
}

.pm-action-btn:hover {
    background-color: var(--bg-hover);
}

.pm-action-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.pm-action-btn--signout {
    border-right: 1px solid var(--border-subtle);
}

/* Footer */
.pm-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 20px 16px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.pm-footer a {
    color: var(--text-tertiary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.pm-footer a:hover {
    color: var(--text-secondary);
}

.pm-footer-dot {
    opacity: 0.5;
}

/* === Mobile: Bottom Sheet === */
@media (max-width: 639px) {
    .profile-modal {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .profile-modal.active {
        transform: translateY(0);
    }

    .pm-greeting {
        font-size: 20px;
    }

    .pm-bottom-actions {
        margin: 0 16px 20px;
    }

    /* Handle bar for bottom sheet */
    .profile-modal::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background-color: var(--text-tertiary);
        border-radius: 2px;
        margin: 12px auto 4px;
        opacity: 0.4;
    }
}
