/* ========================================================
   Shares - avatar menu, popup, connection cards, badges
   ======================================================== */

/* --- User Avatar + Context Menu (header) --- */
.header-user {
    margin-left: auto;
    position: relative;
}

.user-avatar-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg-surface);
    color: var(--accent);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color var(--transition);
    overflow: hidden;
    padding: 0;
}

.user-avatar-btn:hover {
    border-color: var(--accent);
}

.user-avatar-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Dropdown menu */
.user-menu {
    position: absolute;
    top: 44px;
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 160px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 100;
    overflow: hidden;
}

.user-menu-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.user-menu-item:hover {
    background: var(--bg-surface-hover);
}

.user-menu-item--danger {
    color: var(--danger);
}

.user-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* --- Shares Popup Overlay --- */
.shares-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.shares-popup {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 480px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.shares-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.shares-popup-header h3 {
    font-size: var(--font-size-lg);
    color: var(--text-primary);
}

.shares-close {
    font-size: 1.4rem;
    color: var(--text-secondary);
}

.shares-popup-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

/* --- Sections --- */
.shares-section {
    margin-bottom: 20px;
}

.shares-section:last-child {
    margin-bottom: 0;
}

.shares-section-title {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    margin-bottom: 10px;
}

.shares-empty {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    font-style: italic;
}

/* --- Invite Form --- */
.shares-invite-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shares-invite-email {
    width: 100%;
}

.shares-invite-options {
    display: grid;
    grid-template-columns: 2fr 3fr 1fr;
    gap: 8px;
    align-items: center;
}

.shares-invite-options .form-select {
    width: 100%;
}

.shares-invite-status {
    font-size: var(--font-size-sm);
    margin-top: 6px;
    min-height: 1.2em;
}

.shares-invite-success { color: var(--success); }
.shares-invite-error { color: var(--danger); }

/* --- Connection Cards --- */
.shares-connection {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.shares-connection-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
}

.shares-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.shares-avatar-initials {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--accent);
}

.shares-connection-info {
    flex: 1;
    min-width: 0;
}

.shares-connection-name {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shares-connection-meta {
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

/* --- Status Badges --- */
.shares-badge {
    font-size: var(--font-size-xs);
    padding: 1px 6px;
    border-radius: 3px;
    text-transform: capitalize;
}

.shares-status--pending { background: rgba(255, 165, 2, 0.15); color: var(--warning); }
.shares-status--accepted { background: rgba(46, 213, 115, 0.15); color: var(--success); }
.shares-status--declined { background: rgba(255, 71, 87, 0.15); color: var(--danger); }
.shares-status--revoked { background: rgba(255, 71, 87, 0.15); color: var(--danger); }

.shares-permission {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.shares-connection-date {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: 2px;
    opacity: 0.8;
}

/* --- Scope controls (in My Shares popup) --- */
.shares-scope-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.shares-scope-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    flex-shrink: 0;
}

.shares-scope-change {
    font-size: var(--font-size-xs);
    padding: 2px 4px;
}

.shares-scope-info {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

.shares-invite-form .shares-scope-select {
    width: auto;
    min-width: 160px;
}

/* --- Connection action buttons (accept/revoke side by side) --- */
.shares-connection-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* --- Share With native multi-select (in modal) --- */
.share-with-group {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.share-with-empty {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    margin: 0;
}

.share-with-setup-link {
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
}

.share-with-setup-link:hover {
    text-decoration: underline;
}

/* --- Share Picker (custom dropdown multi-select) --- */
.share-picker {
    position: relative;
}

.share-picker-display {
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.share-picker-placeholder {
    color: var(--text-muted);
}

.share-picker-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 50;
    max-height: 180px;
    overflow-y: auto;
}

.share-picker-dropdown.open {
    display: block;
}

.share-picker-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    transition: background 150ms ease;
    user-select: none;
}

.share-picker-option:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.share-picker-option.selected {
    color: var(--accent);
}

.share-picker-tick {
    display: none;
    color: var(--accent);
    font-weight: 600;
}

.share-picker-option.selected .share-picker-tick {
    display: inline;
}

/* --- Shared Item Badge (in schedule/reminder views) --- */
.shared-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--font-size-sm);
    color: var(--accent);
    opacity: 0.85;
}

.shared-badge .icon {
    width: 1em;
    height: 1em;
}

/* --- Profile Popup --- */
.profile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.profile-popup {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.profile-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.profile-popup-header h3 {
    font-size: var(--font-size-lg);
    color: var(--text-primary);
}

.profile-popup-body {
    padding: 20px;
}

.profile-avatar-section {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.profile-avatar-preview {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 2px solid var(--border);
}

.profile-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-avatar-preview .shares-avatar-initials {
    font-size: var(--font-size-lg);
}

.profile-avatar-actions {
    display: flex;
    gap: 8px;
}

.profile-form .form-group {
    margin-bottom: 16px;
}

.profile-form .form-group:last-child {
    margin-bottom: 0;
}

.profile-email {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.profile-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
