/* ==========================================================
   MySP User Profile — Stylesheet
   Override warna lewat CSS: .mysp-user-profile-wrap { --mysp-accent: #xxxxxx; }
========================================================== */

.mysp-user-profile-wrap {
    --mysp-accent: #2271b1;
    --mysp-accent-dark: #135e96;
    --mysp-accent-soft: #eaf3fb;
    --mysp-text: #1d2327;
    --mysp-muted: #6b7280;
    --mysp-border: #e2e5ea;
    --mysp-bg-soft: #f7f8fa;
    --mysp-danger: #d63638;
    --mysp-success: #1a7f37;

    max-width: 640px;
    margin: 40px auto;
    background: #fff;
    border: 1px solid var(--mysp-border);
    border-radius: 16px;
    box-shadow: 0 8px 28px rgba(16, 24, 40, .07);
    overflow: hidden;

    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--mysp-text);
    box-sizing: border-box;
}

.mysp-user-profile-wrap *,
.mysp-user-profile-wrap *::before,
.mysp-user-profile-wrap *::after {
    box-sizing: border-box;
}

/* ==========================
   Hero (avatar + identitas)
========================== */
.mysp-user-profile-hero {
    padding: 36px 24px 24px;
    text-align: center;
    background: linear-gradient(180deg, var(--mysp-hero-from, #eaf3fb) 0%, var(--mysp-hero-to, #ffffff) 100%);
    border-bottom: 1px solid var(--mysp-border);
}

.mysp-user-profile-avatar {
    position: relative;
    width: 112px;
    height: 112px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: #e9ecef;
    box-shadow: 0 0 0 4px #fff, 0 4px 14px rgba(16, 24, 40, .15);
}

.mysp-user-profile-avatar label {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
}

.mysp-user-profile-avatar img {
    display: block;
    width: 112px !important;
    height: 112px !important;
    max-width: none;
    border-radius: 50%;
    object-fit: cover;
    aspect-ratio: 1 / 1;
}

.mysp-user-profile-avatar-badge {
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--mysp-accent);
    color: #fff;
    border: 3px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: background .2s ease, transform .2s ease;
}

.mysp-user-profile-avatar-badge .dashicons {
    width: 16px;
    height: 16px;
    font-size: 16px;
    line-height: 1;
}

.mysp-user-profile-avatar:hover .mysp-user-profile-avatar-badge,
.mysp-user-profile-avatar:focus-within .mysp-user-profile-avatar-badge {
    background: var(--mysp-accent-dark);
    transform: scale(1.08);
}

.mysp-user-profile-avatar:focus-within {
    outline: 2px solid var(--mysp-accent);
    outline-offset: 3px;
}

.mysp-user-profile-avatar.is-loading img {
    opacity: .45;
}

.mysp-user-profile-avatar.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 255, 255, .8);
    border-top-color: var(--mysp-accent);
    border-radius: 50%;
    animation: myspUserProfileSpin .7s linear infinite;
}

.mysp-user-profile-hero-name {
    margin: 0 0 2px;
    padding: 0;
    font-size: 1.35rem;
    font-weight: 650;
    line-height: 1.3;
    color: var(--mysp-text);
}

.mysp-user-profile-hero-meta {
    margin: 0;
    font-size: .9rem;
    color: var(--mysp-muted);
    word-break: break-word;
}

/* ==========================
   Body
========================== */
.mysp-user-profile-body {
    padding: 28px 32px 32px;
}

.mysp-user-profile-section-title {
    margin: 0 0 18px;
    padding: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--mysp-text);
}

/* ==========================
   View mode (daftar info)
========================== */
.mysp-user-profile-list {
    margin: 0;
    padding: 0;
}

.mysp-user-profile-row {
    display: grid;
    grid-template-columns: 170px 1fr;
    gap: 4px 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--mysp-border);
}

.mysp-user-profile-row:last-child {
    border-bottom: 0;
}

.mysp-user-profile-row dt {
    margin: 0;
    font-size: .88rem;
    font-weight: 500;
    color: var(--mysp-muted);
}

.mysp-user-profile-row dd {
    margin: 0;
    font-weight: 500;
    color: var(--mysp-text);
    word-break: break-word;
    white-space: pre-line;
}

.mysp-user-profile-empty {
    color: #9aa0a8;
    font-weight: 400;
    font-style: italic;
}

/* ==========================
   Form
========================== */
.mysp-user-profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}

.mysp-user-profile-field {
    margin-bottom: 18px;
}

.mysp-user-profile-field label {
    display: block;
    margin: 0 0 6px;
    font-size: .9rem;
    font-weight: 600;
    color: #374151;
}

.mysp-user-profile-field label span {
    font-size: .85em;
    font-weight: 400;
    color: var(--mysp-muted);
}

.mysp-user-profile-field label .required {
    color: var(--mysp-danger);
    font-weight: 700;
}

.mysp-user-profile-field input,
.mysp-user-profile-field textarea {
    display: block;
    width: 100%;
    margin: 0;
    padding: 11px 14px;
    border: 1px solid #cfd4db;
    border-radius: 10px;
    background: #fff;
    color: var(--mysp-text);
    font: inherit;
    font-size: .95rem;
    box-shadow: none;
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.mysp-user-profile-field input[readonly],
.mysp-user-profile-field textarea[readonly] {
    background: var(--mysp-bg-soft);
    color: var(--mysp-muted);
    cursor: not-allowed;
}

.mysp-user-profile-field input:focus,
.mysp-user-profile-field textarea:focus {
    outline: none;
    border-color: var(--mysp-accent);
    box-shadow: 0 0 0 3px rgba(34, 113, 177, .18);
}

.mysp-user-profile-field input.is-invalid,
.mysp-user-profile-field textarea.is-invalid {
    border-color: var(--mysp-danger);
    box-shadow: 0 0 0 3px rgba(214, 54, 56, .12);
}

.mysp-user-profile-field textarea {
    min-height: 96px;
    resize: vertical;
}

.mysp-user-profile-help {
    display: block;
    margin-top: 6px;
    font-size: .8rem;
    color: var(--mysp-muted);
}

.mysp-user-profile-help.is-error {
    color: var(--mysp-danger);
}

/* Select */
.mysp-user-profile-field select {
    display: block;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 11px 14px;
    border: 1px solid #cfd4db;
    border-radius: 10px;
    background-color: #fff;
    color: var(--mysp-text);
    font: inherit;
    font-size: .95rem;
    box-shadow: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.mysp-user-profile-field select:focus {
    outline: none;
    border-color: var(--mysp-accent);
    box-shadow: 0 0 0 3px rgba(34, 113, 177, .18);
}

/* Judul seksi di dalam form / daftar */
.mysp-user-profile-form-section {
    margin: 28px 0 16px;
    padding: 20px 0 0;
    border-top: 1px solid var(--mysp-border);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--mysp-text);
}

/* Input dengan awalan (@) */
.mysp-user-profile-affix {
    display: flex;
    align-items: stretch;
}

.mysp-user-profile-affix > span {
    display: flex;
    align-items: center;
    padding: 0 14px;
    border: 1px solid #cfd4db;
    border-right: 0;
    border-radius: 10px 0 0 10px;
    background: var(--mysp-bg-soft);
    color: var(--mysp-muted);
}

.mysp-user-profile-affix input {
    border-radius: 0 10px 10px 0 !important;
}

.mysp-user-profile-row dd a {
    color: var(--mysp-accent);
    text-decoration: none;
    word-break: break-all;
}

.mysp-user-profile-row dd a:hover {
    text-decoration: underline;
}

/* Password: toggle tampil/sembunyi */
.mysp-user-profile-pwd {
    position: relative;
}

.mysp-user-profile-pwd input {
    padding-right: 46px;
}

.mysp-user-profile-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--mysp-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mysp-user-profile-toggle:hover {
    color: var(--mysp-text);
    background: var(--mysp-bg-soft);
}

.mysp-user-profile-toggle:focus-visible {
    outline: 2px solid var(--mysp-accent);
}

.mysp-user-profile-toggle .dashicons {
    width: 20px;
    height: 20px;
    font-size: 20px;
}

/* Password strength */
.mysp-user-profile-meter {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}

.mysp-user-profile-meter i {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: #e5e7eb;
    transition: background .2s ease;
}

.mysp-user-profile-meter[data-level="1"] i:nth-child(-n+1) { background: #dc2626; }
.mysp-user-profile-meter[data-level="2"] i:nth-child(-n+2) { background: #f59e0b; }
.mysp-user-profile-meter[data-level="3"] i:nth-child(-n+3) { background: #84cc16; }
.mysp-user-profile-meter[data-level="4"] i:nth-child(-n+4) { background: #16a34a; }

/* ==========================
   Buttons
========================== */
.mysp-user-profile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 26px;
}

.mysp-user-profile-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1 1 160px;
    min-height: 44px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    font: inherit;
    font-size: .95rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none !important;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease, transform .1s ease, box-shadow .2s ease;
}

.mysp-user-profile-btn .dashicons {
    width: 18px;
    height: 18px;
    font-size: 18px;
    line-height: 1;
}

.mysp-user-profile-btn:active {
    transform: scale(.98);
}

.mysp-user-profile-btn:focus-visible {
    outline: 2px solid var(--mysp-accent);
    outline-offset: 2px;
}

.mysp-user-profile-btn-primary {
    background: var(--mysp-accent);
    color: #fff;
}

.mysp-user-profile-btn-primary:hover,
.mysp-user-profile-btn-primary:focus {
    background: var(--mysp-accent-dark);
    color: #fff;
}

.mysp-user-profile-btn-secondary {
    background: #fff;
    color: #374151;
    border-color: #cfd4db;
}

.mysp-user-profile-btn-secondary:hover,
.mysp-user-profile-btn-secondary:focus {
    background: var(--mysp-bg-soft);
    color: var(--mysp-text);
}

.mysp-user-profile-btn[disabled],
.mysp-user-profile-btn.is-loading {
    opacity: .75;
    cursor: progress;
    pointer-events: none;
}

.mysp-user-profile-btn.is-loading .dashicons {
    animation: myspUserProfileSpin .8s linear infinite;
}

/* ==========================
   Alert (fallback tanpa JS)
========================== */
.mysp-user-profile-alert {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 22px;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: .92rem;
    font-weight: 500;
}

.mysp-user-profile-alert-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b42318;
}

.mysp-user-profile-alert-success {
    background: #ecfdf3;
    border-color: #abefc6;
    color: #067647;
}

/* Login prompt */
.mysp-user-profile-login {
    max-width: 420px;
    padding: 36px 28px;
    text-align: center;
}

.mysp-user-profile-login p {
    margin: 0 0 18px;
    color: var(--mysp-muted);
}

.mysp-user-profile-login .mysp-user-profile-btn {
    flex: none;
    width: 100%;
}

/* ==========================
   Toast
========================== */
#mysp-user-profile-toast {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.mysp-user-profile-toast {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 360px;
    padding: 13px 18px;
    border-radius: 10px;
    color: #fff;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
    animation: myspUserProfileToast .25s ease;
}

.mysp-user-profile-toast .dashicons {
    flex: none;
    width: 18px;
    height: 18px;
    font-size: 18px;
}

.mysp-user-profile-toast-success { background: #16a34a; }
.mysp-user-profile-toast-error   { background: #dc2626; }

.mysp-user-profile-toast.is-leaving {
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity .25s ease, transform .25s ease;
}

@keyframes myspUserProfileToast {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes myspUserProfileSpin {
    to { transform: rotate(360deg); }
}

/* Aksesibilitas: teks khusus screen reader */
.mysp-user-profile-sr {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* ==========================
   Responsive
========================== */
@media (max-width: 600px) {
    .mysp-user-profile-wrap {
        margin: 16px 12px;
        border-radius: 14px;
    }

    .mysp-user-profile-body {
        padding: 22px 18px 24px;
    }

    .mysp-user-profile-row {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .mysp-user-profile-grid {
        grid-template-columns: 1fr;
    }

    .mysp-user-profile-btn {
        flex: 1 1 100%;
    }


    #mysp-user-profile-toast {
        top: 12px;
        left: 12px;
        right: 12px;
        align-items: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mysp-user-profile-wrap *,
    .mysp-user-profile-toast {
        animation: none !important;
        transition: none !important;
    }
}
