/* Profile > Basic Info > Other emails, and its "Your emails" dialog (js/profile-emails.js).
   The dialog lives outside the profile page's containers, so every --pc-* token has a fallback. */

#profileEmails {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
    margin-top: 6px;
}

#profileEmails[hidden] {
    display: none;
}

/* Labelled divider, like Location above it */
.emails-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #94a3b8;
}

.emails-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--pc-line, #e6ebef);
}

.emails-head {
    display: flex;
    align-items: center;
    gap: 16px;
    border-radius: 12px;
}

.emails-head.is-flash {
    animation: emails-ring 2.4s ease;
}

.emails-summary {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

/* Loading placeholder, the same shape as the summary row */
.emails-skeleton {
    display: block;
    border-radius: 8px;
    background: linear-gradient(90deg, #eef2f5 0%, #f7f9fb 50%, #eef2f5 100%) 0 0 / 200% 100%;
    animation: emails-shimmer 1.3s ease-in-out infinite;
}

.emails-skeleton--line {
    width: min(420px, 90%);
    height: 14px;
    margin: 4px 0 2px;
}

.emails-skeleton--short {
    width: 120px;
    height: 12px;
}

.emails-skeleton--button {
    flex: none;
    width: 150px;
    height: 42px;
    border-radius: 12px;
}

@keyframes emails-shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .emails-skeleton {
        animation: none;
    }
}

.emails-summary-count {
    font-size: 0.8rem;
    color: var(--pc-muted, #64748b);
}

.emails-intro {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--pc-muted, #64748b);
}

.emails-intro strong {
    font-weight: 600;
    color: var(--pc-text, #334155);
    overflow-wrap: anywhere;
}

.emails-open {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 16px;
    border: 1.5px solid rgba(17, 161, 145, 0.35);
    border-radius: 12px;
    background: rgba(17, 161, 145, 0.05);
    color: var(--pc-teal-deep, #0b7a6e);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.emails-open svg {
    width: 16px;
    height: 16px;
    margin-left: -3px;
}

.emails-open:hover {
    border-color: var(--pc-teal, #11a191);
    background: rgba(17, 161, 145, 0.1);
}

.emails-open--row {
    width: 100%;
    height: 48px;
    border-style: dashed;
}

/* ---------- Emails ---------- */

.emails-list {
    margin: 0;
    padding: 0;
    list-style: none;
    border: 1px solid var(--pc-line, #e6ebef);
    border-radius: 14px;
    background: #fff;
}

.emails-item {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 12px 12px 12px 14px;
}

.emails-item + .emails-item {
    border-top: 1px solid var(--pc-line, #e6ebef);
}

.emails-item:first-child {
    border-radius: 13px 13px 0 0;
}

.emails-item:last-child {
    border-radius: 0 0 13px 13px;
}

.emails-item:only-child {
    border-radius: 13px;
}

.emails-item.is-flash {
    animation: emails-flash 2.4s ease;
}

@keyframes emails-flash {
    0%, 45% { background-color: rgba(17, 161, 145, 0.13); }
    100% { background-color: transparent; }
}

@keyframes emails-ring {
    0%, 45% { background-color: rgba(17, 161, 145, 0.1); box-shadow: 0 0 0 8px rgba(17, 161, 145, 0.1); }
    100% { background-color: transparent; box-shadow: 0 0 0 8px transparent; }
}

.emails-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(17, 161, 145, 0.09);
    color: var(--pc-teal-deep, #0b7a6e);
}

.emails-item--account .emails-item-icon {
    background: #f1f5f9;
    color: #64748b;
}

.emails-item-icon svg {
    width: 18px;
    height: 18px;
}

.emails-item-main {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.emails-item-address {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--pc-ink, #0f172a);
    overflow-wrap: anywhere;
}

.emails-item-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.emails-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.55;
    white-space: nowrap;
}

.emails-badge svg {
    width: 11px;
    height: 11px;
    flex: none;
}

.emails-badge--ok {
    background: rgba(17, 161, 145, 0.11);
    color: #0b7a6e;
}

.emails-badge--wait {
    background: #fff4e0;
    color: #8a5a00;
}

.emails-badge--warn {
    background: #fdecee;
    color: #b42335;
}

.emails-badge--shared {
    background: #eef2ff;
    color: #3f4bb0;
}

.emails-badge--plain {
    background: #f1f5f9;
    color: #475569;
}

.emails-item-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cselect--emlabel {
    width: 118px;
    flex: none;
    margin-right: 4px;
    --cselect-height: 36px;
    --cselect-padding: 0 0.3rem 0 0.7rem;
    --cselect-radius: 10px;
    --cselect-border: var(--pc-line, #e6ebef);
    --cselect-font-size: 0.84rem;
    --cselect-font-weight: 600;
    --cselect-ink: var(--pc-text, #334155);
    --cselect-shadow: none;
    --cselect-ring: 0 0 0 3px rgba(17, 161, 145, 0.16);
    --cselect-chevron-size: 22px;
    --cselect-chevron-bg: transparent;
    --cselect-chevron-color: #94a3b8;
}

.cselect--emlabel:has(option[value=""]:checked) .cselect-value {
    color: #94a3b8;
    font-weight: 500;
}

.emails-link {
    height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: 9px;
    background: none;
    color: var(--pc-teal-deep, #0b7a6e);
    font: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.emails-link:hover:not(:disabled) {
    background: rgba(17, 161, 145, 0.09);
}

.emails-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: none;
    color: #94a3b8;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.emails-icon-btn svg {
    width: 18px;
    height: 18px;
}

.emails-icon-btn:hover:not(:disabled) {
    background: #fdecee;
    color: #dc3545;
}

.emails-link:disabled,
.emails-icon-btn:disabled {
    opacity: 0.55;
    cursor: default;
}

.emails-link:focus-visible,
.emails-icon-btn:focus-visible,
.emails-open:focus-visible,
.emails-btn:focus-visible,
.emails-kind-option:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(17, 161, 145, 0.3);
}

/* ---------- Add an email ---------- */

.emails-add {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 14px 12px;
    padding: 16px;
    border: 1px solid var(--pc-line, #e6ebef);
    border-radius: 14px;
    background: #fbfcfd;
}

.emails-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

.emails-field label {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--pc-text, #334155);
}

#addEmailInput {
    width: 100%;
    height: 50px;
    box-sizing: border-box;
    margin: 0;
    padding: 0 14px 0 44px;
    border: 1.5px solid var(--pc-field-line, #dfe5ea);
    border-radius: 12px;
    background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='5' width='18' height='14' rx='2.5'/><path d='m4 7 8 6 8-6'/></svg>") no-repeat 14px center / 18px 18px;
    font: inherit;
    font-size: 0.98rem;
    color: var(--pc-ink, #0f172a);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#addEmailInput::placeholder {
    color: #a0aab6;
}

#addEmailInput:hover:not(:focus):not(:disabled) {
    border-color: #c9d3db;
}

#addEmailInput:focus {
    border-color: var(--pc-teal, #11a191);
    box-shadow: 0 0 0 4px rgba(17, 161, 145, 0.12);
}

.emails-kind {
    display: inline-flex;
    gap: 2px;
    box-sizing: border-box;
    height: 50px;
    padding: 4px;
    border-radius: 13px;
    background: #eef2f4;
}

.emails-kind-option {
    padding: 0 16px;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--pc-muted, #64748b);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.emails-kind-option[aria-checked="true"] {
    background: #fff;
    color: var(--pc-ink, #0f172a);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 2px 8px rgba(15, 23, 42, 0.06);
}

.emails-add-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.emails-btn {
    height: 44px;
    padding: 0 18px;
    border: 1px solid #e2e6ea;
    border-radius: 12px;
    background: #fff;
    color: #3d4852;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.emails-btn:hover:not(:disabled) {
    background: #f6f8fa;
    border-color: #d5dbe1;
}

.emails-btn--primary {
    border-color: #0f978a;
    background: linear-gradient(180deg, #16b0a0 0%, #11a191 100%);
    color: #fff;
    box-shadow: 0 6px 16px -8px rgba(17, 161, 145, 0.7);
}

.emails-btn--primary:hover:not(:disabled) {
    border-color: #0b7a6e;
    background: linear-gradient(180deg, #13a596 0%, #0f9083 100%);
}

.emails-btn:disabled,
.emails-kind-option:disabled {
    opacity: 0.6;
    cursor: default;
}

/* ---------- Picking the shared email (circle beside each pickable email) ---------- */

/* The label only groups the circle and address for clicks; the row grid lays them out */
.emails-pick {
    display: contents;
    cursor: pointer;
}

.emails-item.is-pickable {
    transition: background-color 0.2s ease;
}

/* Not confirmed yet, so it can't be picked */
.emails-list--pick .emails-item:not(.is-pickable) .emails-item-icon {
    background: #f1f5f9;
    color: #94a3b8;
}

.emails-item.is-pickable .emails-item-main {
    cursor: pointer;
}

.emails-item.is-pickable:hover {
    background: #f8fafc;
}

.emails-item.is-picked,
.emails-item.is-picked:hover {
    background: rgba(17, 161, 145, 0.055);
}

.emails-radio {
    -webkit-appearance: none;
    appearance: none;
    display: grid;
    place-content: center;
    justify-self: center;
    box-sizing: border-box;
    width: 22px;
    height: 22px;
    margin: 0;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.emails-radio::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--pc-teal, #11a191);
    transform: scale(0);
    transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.emails-radio:checked {
    border-color: var(--pc-teal, #11a191);
    box-shadow: 0 0 0 4px rgba(17, 161, 145, 0.12);
}

.emails-radio:checked::before {
    transform: scale(1);
}

.emails-item.is-pickable:hover .emails-radio:not(:checked):not(:disabled) {
    border-color: #94a3b8;
}

.emails-radio:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(17, 161, 145, 0.28);
}

.emails-hint {
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--pc-muted, #64748b);
}

.emails-status {
    margin: 0;
    font-size: 0.86rem;
    line-height: 1.5;
}

.emails-status:empty {
    display: none;
}

.emails-status-text--ok {
    color: #0b7a6e;
}

.emails-status-text--error {
    color: #c62f3f;
}

.emails-status a {
    color: inherit;
    font-weight: 600;
}

/* ---------- "Your emails" dialog (on the page's .page-dialog-overlay backdrop) ---------- */

.emails-sheet {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(640px, 100%);
    max-height: min(780px, calc(100vh - 48px));
    max-height: min(780px, calc(100dvh - 48px));
    box-sizing: border-box;
    border-radius: 20px;
    background: #fff;
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.06),
        0 12px 28px rgba(15, 23, 42, 0.14),
        0 32px 64px rgba(15, 23, 42, 0.16);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    text-align: left;
    opacity: 0;
    transform: translateY(22px) scale(0.97);
    transition: opacity 0.3s ease, transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

.page-dialog-overlay.is-open .emails-sheet {
    opacity: 1;
    transform: none;
}

.page-dialog-overlay.is-closing .emails-sheet {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    transition-duration: 0.22s;
}

.emails-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 18px 6px 24px;
}

.emails-sheet-head h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--pc-ink, #0f172a);
}

.emails-sheet-close:hover:not(:disabled) {
    background: #f1f5f9;
    color: #334155;
}

.emails-sheet-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 6px 24px 22px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.emails-sheet-foot {
    display: flex;
    justify-content: flex-end;
    padding: 14px 24px 18px;
    border-top: 1px solid var(--pc-line, #e6ebef);
}

.emails-sheet-foot .emails-btn {
    min-width: 112px;
}

/* ---------- Phones ---------- */

@media screen and (max-width: 768px) {
    #profileEmails {
        gap: 12px;
    }

    .emails-title {
        font-size: 0.7rem;
    }

    .emails-head {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .emails-intro {
        font-size: 0.86rem;
    }

    .emails-open {
        height: 46px;
    }

    .emails-skeleton--button {
        width: 100%;
        height: 46px;
    }

    .emails-item {
        grid-template-columns: 32px minmax(0, 1fr);
        gap: 10px 12px;
        padding: 12px;
    }

    .emails-item-icon {
        width: 32px;
        height: 32px;
        border-radius: 9px;
    }

    .emails-item-icon svg {
        width: 16px;
        height: 16px;
    }

    .emails-item-controls {
        grid-column: 2;
        flex-wrap: wrap;
        margin-top: -2px;
    }

    .cselect--emlabel {
        --cselect-height: 40px;
        --cselect-font-size: 0.88rem;
        width: 124px;
    }

    .emails-link,
    .emails-icon-btn {
        height: 40px;
    }

    .emails-item-controls .emails-icon-btn {
        width: 40px;
        margin-left: auto;
    }

    .emails-add {
        grid-template-columns: minmax(0, 1fr);
        padding: 14px;
    }

    #addEmailInput {
        font-size: 16px;
    }

    .emails-kind-option {
        flex: 1;
    }

    .emails-add-actions .emails-btn {
        flex: 1;
        height: 48px;
    }

    /* Bottom sheet */
    .page-dialog-overlay.emails-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .emails-sheet {
        width: 100%;
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px);
        border-radius: 22px 22px 0 0;
        transform: translateY(40px);
    }

    .page-dialog-overlay.is-closing .emails-sheet {
        transform: translateY(40px);
    }

    .emails-sheet-head {
        padding: 18px 12px 4px 18px;
    }

    .emails-sheet-body {
        padding: 6px 18px 18px;
    }

    .emails-sheet-foot {
        padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .emails-sheet-foot .emails-btn {
        flex: 1;
        height: 48px;
    }
}
