/* user-details.css */
@import url('styles.css');

:root {
    --header-bottom-spacing: 1rem;
    --main-content-top-spacing: 0rem;
    /* No fixed-header offset needed — spacing comes from .app-header's margin,
       kept 0 for consistency with the other pages (incl. mobile). */
    --mobile-header-offset: 0rem;
}

/* Main content layout - aligned with dashboard-main */
.app-main {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 70vh;
    padding: 0 1rem;
    margin-top: calc(var(--main-content-top-spacing) + var(--mobile-header-offset));
    width: 100%;
}

/* Basic container layout */
.user-profile-card {
    background: linear-gradient(150deg, #fff 0%, var(--very-light-blue) 100%);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-hard-lift);
    border: var(--border-chunky);
    margin: 0 auto;
}

/* Profile header section */
.user-profile-header {
    display: flex;
    align-items: center;
    margin-bottom: 30px;
}

.profile-picture {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 20px;
    /* Match the header avatar's double-ring (white ring + ink outline + gold
       offset) so the profile picture reads as the same component. */
    border: 3px solid #fff;
    box-shadow: 0 0 0 3px var(--ink), 4px 5px 0 var(--sun-gold);
    background-color: #fff;
}

/* Skeleton shimmer shown until the real avatar (photo or initials disc) is
   ready, so the placeholder never flashes into the final image. */
.profile-picture.avatar-loading {
    background-image: linear-gradient(100deg, #e9eef3 30%, #f6f9fb 50%, #e9eef3 70%);
    background-size: 200% 100%;
    animation: avatarShimmer 1.2s ease-in-out infinite;
}
@keyframes avatarShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
    .profile-picture.avatar-loading { animation: none; }
}

/* The profile initials disc is created with BOTH `.initials-avatar` and
   `.profile-picture`. header.css / styles.css size `.initials-avatar` for the
   40px top-right HEADER avatar — and styles.css even uses `!important` on phones
   (≤600px → 34px). The profile disc shares that class, so without this it
   collapsed from the 100px placeholder to a tiny 40/34px disc ("loads big, then
   reloads small"). Scope to the card (higher specificity) + `!important` on
   mobile so the FULL profile size always wins, for both the <img> photo and the
   initials disc, and both stay the SAME size — no jump. */
.user-profile-header .profile-picture,
.user-profile-header .initials-avatar {
    width: 100px !important;
    height: 100px !important;
    font-size: 38px;   /* legible initials on the big disc (header sets ~15px) */
}
@media (max-width: 600px) {
    .user-profile-header .profile-picture,
    .user-profile-header .initials-avatar {
        width: 80px !important;
        height: 80px !important;
        font-size: 30px !important;
    }
}

.user-name {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 26px;
    color: var(--ink);
    margin: 0;
    letter-spacing: -0.3px;
}

/* User details list */
.user-details-list {
    list-style-type: none;
    padding: 0;
}

.user-details-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-line);
}

.user-details-item:last-child {
    border-bottom: none;
}

.user-details-label {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--deep-blue);
    flex-basis: 40%;
}

.user-details-value {
    text-align: right;
    color: var(--text-color, #333);
    font-family: var(--font-sans);
    font-weight: 600;
    flex-basis: 60%;
}

/* Password container */
.password-container {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
}

/* Language tags */
.language-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.language-tag {
    background-color: var(--very-light-blue);
    color: var(--ink);
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 700;
    border: 2px solid var(--ink);
}

/* Membership badge — free is an outline pill that turns gold on hover and
   opens the unlock modal; premium is a solid gold badge. */
.membership-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    /* Opens the unlock modal on a free account — a buy-path control. */
    min-height: var(--tap-min, 44px);
    padding: 6px 14px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13.5px;
    border-radius: var(--radius-pill);
    border: 2px solid var(--ink);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast) var(--ease-spring),
                box-shadow var(--transition-fast) var(--ease-out),
                background-color var(--transition-fast) ease;
}
.membership-badge.free { background: #fff; color: var(--ink); }
.membership-badge.free:hover { background: var(--sun-gold); transform: translate(-1px, -2px); box-shadow: var(--shadow-md); }
.membership-badge.free:active { transform: translate(2px, 3px); box-shadow: var(--shadow-hard-press); }
.membership-badge.premium { background: var(--sun-gold); color: var(--ink); cursor: default; }
.membership-badge:focus-visible { outline: 3px solid var(--deep-blue); outline-offset: 2px; }

/* Chunky password field to match the app's inputs */
.password-container { width: 100%; }
.password-container input {
    width: 100%;
    min-height: var(--tap-min, 44px);
    padding: 8px 40px 8px 14px;
    border: var(--border-chunky-thin);
    border-radius: var(--radius-pill);
    font-family: var(--font-sans);
    color: var(--text-color, #333);
    background: #fff;
    box-shadow: var(--shadow-sm);
}
.password-container input:focus { outline: none; box-shadow: var(--focus-ring); }
.toggle-password { color: var(--deep-blue); }

/* Edit button */
.edit-button {
    background: linear-gradient(150deg, var(--medium-blue), var(--deep-blue));
    color: white;
    border: var(--border-chunky-thin);
    padding: 11px 22px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    box-shadow: var(--shadow-sm);
    transition: background var(--transition-base) var(--ease-standard),
                box-shadow var(--transition-fast) var(--ease-out),
                transform var(--transition-fast) var(--ease-spring);
}

.edit-button:hover {
    background: linear-gradient(150deg, var(--deep-blue), var(--flag-blue));
    box-shadow: var(--shadow-md);
    transform: translate(-1px, -2px);
}

.edit-button:active {
    transform: translate(2px, 3px);
    box-shadow: var(--shadow-hard-press);
}

.dashboard-title {
    color: var(--ink);
    font-size: 2.4rem;
    font-family: var(--font-display);
    font-weight: 800;
    letter-spacing: -0.5px;
    margin: 0;
}

/* Edit profile form */
.edit-form { margin-top: 8px; display: flex; flex-direction: column; gap: 14px; }
.edit-form-title { font-family: var(--font-display); font-weight: 800; color: var(--ink); font-size: 1.2rem; margin: 0 0 2px; }
.edit-field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.edit-field label { font-family: var(--font-display); font-weight: 700; font-size: 0.85rem; color: var(--deep-blue); }
.edit-field input {
    width: 100%;
    padding: 11px 14px;
    border: var(--border-chunky-thin);
    border-radius: var(--radius-pill);
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--text-color, #333);
    background: #fff;
    box-shadow: var(--shadow-sm);
}
.edit-field input:focus { outline: none; box-shadow: var(--focus-ring); }
.edit-password { border: 2px dashed var(--deep-blue); border-radius: var(--radius-md); padding: 10px 12px; }
.edit-password summary { font-family: var(--font-display); font-weight: 700; color: var(--deep-blue); cursor: pointer; }
.edit-password[open] { padding-bottom: 14px; }
.edit-password .edit-field { margin-top: 12px; }
.edit-message { margin: 0; font-family: var(--font-sans); font-weight: 700; color: var(--mastered-green, #1a9e6b); text-align: left; }
.edit-message.error { color: var(--error-red, #d33); }
.edit-actions { display: flex; gap: 12px; margin-top: 4px; }
.edit-btn {
    flex: 1;
    padding: 12px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    border-radius: var(--radius-pill);
    border: var(--border-chunky-thin);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast) var(--ease-spring),
                box-shadow var(--transition-fast) var(--ease-out);
}
.edit-btn.primary { background: linear-gradient(150deg, var(--medium-blue), var(--deep-blue)); color: #fff; }
.edit-btn.ghost { background: #fff; color: var(--ink); }
.edit-btn:hover { transform: translate(-1px, -2px); box-shadow: var(--shadow-md); }
.edit-btn:active { transform: translate(2px, 3px); box-shadow: var(--shadow-hard-press); }
.edit-btn:disabled { opacity: 0.6; cursor: default; transform: none; }

/* Flag typeahead (single-select) — dropdown anchored to its input */
.flag-select { position: relative; width: 100%; }
.flag-select-input { width: 100%; }

.flag-select-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 50;
    margin: 0;
    padding: 4px;
    list-style: none;
    max-height: 240px;
    overflow-y: auto;
    background: #fff;
    border: var(--border-chunky-thin);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-hard-lift);
    -webkit-overflow-scrolling: touch;
}

.flag-select-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-sans);
    font-weight: 600;
    color: var(--ink);
}
.flag-select-option:hover,
.flag-select-option.is-active {
    background: var(--sun-gold);
    color: var(--ink);
}
.flag-select-flag { font-size: 1.25rem; line-height: 1; }
.flag-select-name { flex: 1; }

/* Selected-language chips (multi-select) */
.flag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.flag-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px 5px 12px;
    background: var(--very-light-blue);
    color: var(--ink);
    border: 2px solid var(--ink);
    border-radius: var(--radius-pill);
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 14px;
}
.flag-chip .flag-select-flag { font-size: 1.1rem; }
.flag-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--ink);
    color: #fff;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}
.flag-chip-remove:hover { background: var(--deep-blue); }
.flag-chip-remove:focus-visible { outline: 2px solid var(--deep-blue); outline-offset: 2px; }

/* Mobile responsiveness */
@media (max-width: 768px) {
    .app-main {
        margin-top: calc(var(--main-content-top-spacing) + var(--mobile-header-offset));
        padding: 0 0.5rem;
        width: 100%;
    }

    .user-profile-card {
        padding: 1.5rem;
        width: 95%;
    }

    .user-profile-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .profile-picture {
        margin-right: 0;
        margin-bottom: 15px;
    }

    .user-details-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .user-details-value {
        text-align: left;
        margin-top: 5px;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
    }

    .dashboard-title {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .app-main {
        margin-top: calc(var(--main-content-top-spacing) + var(--mobile-header-offset));
        padding: 0 0.25rem;
    }
    
    .user-profile-card {
        padding: 1rem;
        width: 98%;
    }

    .profile-picture {
        width: 80px;
        height: 80px;
    }

    .user-name {
        font-size: 20px;
    }

    .user-details-label,
    .user-details-value {
        font-size: 14px;
    }

    .language-tag {
        font-size: 12px;
        padding: 4px 8px;
    }

    .edit-button {
        padding: 8px 16px;
        font-size: 14px;
    }

    .dashboard-title {
        font-size: 1.8rem;
    }
}
/* --- Mobile polish (audit) ------------------------------------------------ */
@media (max-width: 600px) {
    .user-details-item { margin-bottom: 9px; padding-bottom: 9px; }
    .user-details-value { margin-top: 2px; }
    .user-profile-header { margin-bottom: 16px; }
    .user-profile-card { padding-bottom: 76px; } /* clear the fixed sound button */
}
/* Demote the password field on the READ-ONLY profile so it stops looking like
   the loudest, editable element (the real change lives in Edit Profile). */
.password-container input {
    border: 2px solid rgba(10, 53, 96, 0.25);
    box-shadow: none;
    padding: 8px 12px;
    background: transparent;
    font-size: 1rem;
}
.password-container input:focus { box-shadow: none; }

/* Empty read-only profile fields ("Not set") — muted so they read as a gentle
   placeholder rather than an actual value. */
.field-empty {
    color: var(--muted-ink, #8a9bb0);
    font-style: italic;
    font-weight: 400;
}
