/* ==========================================================================\n   MGS Users\n   Profile, Profile Edit, Password Reset\n   ========================================================================== */

/* ==========================================================================\n   1. PROFILE DISPLAY\n   ========================================================================== */
.user-profile-card {
    width: min(100% - 32px, 760px);
    margin: 32px auto;
    overflow: hidden;
    background: var(--surface-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 16px 45px rgba(0, 0, 0, .08);
    font-family: var(--font-body);
}

.user-profile-card .profile-header {
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 30px 32px;
    background: color-mix(in srgb, var(--page-background) 72%, var(--surface-color));
    border-bottom: 1px solid var(--border-color);
}

.user-profile-card .profile-photo {
    flex: 0 0 auto;
    width: 92px;
    height: 92px;
    overflow: hidden;
    border: 3px solid var(--surface-color);
    border-radius: 50%;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .10);
    background: var(--page-background);
}

.user-profile-card .profile-photo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-profile-card .profile-info {
    min-width: 0;
}

.user-profile-card .profile-info h2 {
    margin: 0 0 6px;
    color: var(--text-color);
    font-family: var(--font-heading);
    font-size: var(--h2-size);
    font-weight: var(--h2-weight);
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.user-profile-card .profile-info p {
    margin: 0;
    color: var(--muted-color);
    font-size: 14px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.user-profile-card .profile-details {
    padding: 10px 32px 4px;
}

.user-profile-card .detail-row {
    display: grid;
    grid-template-columns: minmax(145px, 34%) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.user-profile-card .detail-row .label {
    color: var(--muted-color);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.55;
}

.user-profile-card .detail-row .value {
    min-width: 0;
    color: var(--text-color);
    font-size: 14px;
    line-height: 1.55;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.user-profile-card .profile-group {
    display: flex;
    justify-content: flex-end;
    padding: 20px 32px 28px;
    border-top: 1px solid var(--border-color);
}

/* Joomla uses .btn-primary in the current profile override.\n   Keep it visually consistent with the template's .btn.dark button. */
.user-profile-card .btn.btn-primary {
    background: var(--theme-color);
    border-color: var(--theme-color);
    color: var(--theme-on-color);
}

.user-profile-card .btn.btn-primary:hover,
.user-profile-card .btn.btn-primary:focus-visible {
    background: var(--theme-accent);
    border-color: var(--theme-accent);
    color: var(--theme-on-color);
    text-decoration: none;
}

/* ==========================================================================\n   2. PROFILE EDIT\n   ========================================================================== */
.form-container {
    width: 100%;
    margin: 32px auto;
    padding: 0 16px;
    color: var(--text-color);
    font-family: var(--font-body);
}

.form-container .form-wrapper {
    width: min(100%, 700px);
    margin: 0 auto;
}

.form-container .right-panel {
    padding: 32px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 16px 45px rgba(0, 0, 0, .08);
}

.form-container .right-panel > h2 {
    margin: 0 0 26px;
    color: var(--text-color);
    font-family: var(--font-heading);
    font-size: var(--h2-size);
    font-weight: var(--h2-weight);
    line-height: 1.3;
    text-align: center;
}

.profile-form,
.profile-edit-card {
    margin: 0;
}

.profile-edit-card .form-group {
    position: relative;
    margin: 0 0 18px;
}

.profile-edit-card .form-group > label {
    display: block;
    margin: 0 0 7px;
    color: var(--text-color);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.45;
}

/* The PHP override currently wraps Joomla field HTML in a div.form-control.\n   Treat that wrapper as structural rather than as an input itself. */
.profile-edit-card div.form-control,
.profile-edit-card .form-group.form-control {
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.profile-edit-card input[type="text"],
.profile-edit-card input[type="email"],
.profile-edit-card input[type="password"],
.profile-edit-card input[type="tel"],
.profile-edit-card input[type="url"],
.profile-edit-card input[type="number"],
.profile-edit-card input[type="date"],
.profile-edit-card input[type="time"],
.profile-edit-card select,
.profile-edit-card textarea {
    display: block;
    width: 100%;
    min-height: 46px;
    box-sizing: border-box;
    padding: 10px 13px;
    border: 1px solid var(--border-color);
    border-radius: 7px;
    background: var(--surface-color);
    color: var(--text-color);
    font: inherit;
    font-size: 14px;
    line-height: 1.45;
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}

.profile-edit-card textarea {
    min-height: 110px;
    resize: vertical;
}

.profile-edit-card select {
    cursor: pointer;
}

.profile-edit-card input::placeholder,
.profile-edit-card textarea::placeholder {
    color: var(--muted-color);
    opacity: .82;
}

.profile-edit-card input:hover:not([readonly]):not([disabled]),
.profile-edit-card select:hover:not([disabled]),
.profile-edit-card textarea:hover:not([readonly]):not([disabled]) {
    border-color: var(--muted-color);
}

.profile-edit-card input:focus,
.profile-edit-card select:focus,
.profile-edit-card textarea:focus {
    border-color: var(--theme-color);
    outline: 0;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-color) 12%, transparent);
}

.profile-edit-card input[readonly],
.profile-edit-card input:disabled,
.profile-edit-card select:disabled,
.profile-edit-card textarea[readonly],
.profile-edit-card textarea:disabled {
    background: var(--page-background);
    color: var(--muted-color);
    cursor: not-allowed;
}

/* Suppress Bootstrap/Joomla validation decorations that conflict with the\n   custom theme while retaining a clear valid/invalid state. */
.profile-edit-card .form-control.is-valid,
.profile-edit-card .form-control.valid,
.profile-edit-card .form-control-success {
    background-image: none;
}

.profile-edit-card input.is-invalid,
.profile-edit-card select.is-invalid,
.profile-edit-card textarea.is-invalid,
.profile-edit-card input.invalid,
.profile-edit-card select.invalid,
.profile-edit-card textarea.invalid {
    border-color: #c62828;
}

.profile-edit-card .form-control-feedback,
.profile-edit-card .invalid-feedback,
.profile-edit-card .form-text,
.profile-edit-card small {
    display: block;
    margin-top: 6px;
    color: var(--muted-color);
    font-size: 12px;
    line-height: 1.45;
}

.profile-edit-card .invalid-feedback,
.profile-edit-card .form-control-feedback.invalid {
    color: #c62828;
}

/* Checkbox and radio fields generated by Joomla/custom fields. */
.profile-edit-card input[type="checkbox"],
.profile-edit-card input[type="radio"] {
    accent-color: var(--theme-color);
}

.profile-edit-card .checkboxes,
.profile-edit-card .radios,
.profile-edit-card fieldset {
    min-width: 0;
}

.profile-edit-card fieldset {
    margin: 0;
    padding: 0;
    border: 0;
}

.profile-edit-card fieldset legend {
    margin: 0 0 8px;
    color: var(--text-color);
    font-size: 13px;
    font-weight: 600;
}

/* Password fields in the current override. */
.profile-edit-card .password-wrapper {
    position: relative;
}

.profile-edit-card .password-wrapper input {
    padding-right: 48px;
}

.profile-edit-card .password-wrapper .fa-eye,
.profile-edit-card .password-wrapper .fa-eye-slash {
    position: absolute !important;
    top: 50% !important;
    right: 8px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    transform: translateY(-50%) !important;
    border-radius: 5px;
    color: var(--muted-color);
    cursor: pointer;
}

.profile-edit-card .password-wrapper .fa-eye:hover,
.profile-edit-card .password-wrapper .fa-eye-slash:hover {
    background: var(--page-background);
    color: var(--text-color);
}

.profile-edit-card .password-wrapper .fa-eye:focus-visible,
.profile-edit-card .password-wrapper .fa-eye-slash:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--theme-color) 18%, transparent);
    outline-offset: 2px;
}

/* Joomla MFA configuration block. */
.profile-edit-card .com-users-methods-list,
.profile-edit-card .com-users-method-edit,
.profile-edit-card .com-users-profile__edit-mfa {
    margin-top: 8px;
}

.profile-edit-card .form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid var(--border-color);
}

/* Current PHP uses Joomla-style .btn-primary / .btn-cancel classes. */
.profile-edit-card .btn.btn-primary {
    background: var(--theme-color);
    border-color: var(--theme-color);
    color: var(--theme-on-color);
}

.profile-edit-card .btn.btn-primary:hover,
.profile-edit-card .btn.btn-primary:focus-visible {
    background: var(--theme-accent);
    border-color: var(--theme-accent);
    color: var(--theme-on-color);
}

.profile-edit-card .btn.btn-cancel {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-color);
}

.profile-edit-card .btn.btn-cancel:hover,
.profile-edit-card .btn.btn-cancel:focus-visible {
    background: var(--page-background);
    border-color: var(--muted-color);
    color: var(--text-color);
}

/* ==========================================================================\n   3. PASSWORD RESET\n   Existing reset styles preserved.\n   ========================================================================== */
.mgs-reset {
    width: 100%;
    margin: 32px auto;
    color: var(--text-color);
    font-family: var(--font-body);
}

.mgs-reset-card {
    width: min(100%, 500px);
    margin: auto;
    padding: 32px;
    box-sizing: border-box;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 16px 45px rgba(0, 0, 0, .08);
}

.mgs-reset-header {
    margin-bottom: 24px;
    text-align: center;
}

.mgs-reset-title {
    margin: 0 0 7px;
    color: var(--text-color);
    font-family: var(--font-heading);
    font-size: var(--h2-size);
    font-weight: var(--h2-weight);
    line-height: 1.3;
}

.mgs-reset-subtitle,
.mgs-reset-description {
    margin: 0;
    color: var(--muted-color);
    font-size: 14px;
    line-height: 1.6;
}

.mgs-reset-message {
    margin: 0 0 18px;
    padding: 11px 13px;
    border-radius: 7px;
    font-size: 13px;
}

.mgs-reset-message--success {
    color: #17663f;
    background: #eefaf3;
    border: 1px solid #c8ead7;
}

.mgs-reset-message--error {
    color: #c62828;
    background: #fff1f1;
    border: 1px solid #f3caca;
}

.mgs-reset-field {
    margin: 0 0 17px;
}

.mgs-reset-label {
    display: block;
    margin: 0 0 7px;
    color: var(--text-color);
    font-size: 13px;
    font-weight: 500;
}

.mgs-reset-input,
.mgs-reset-otp-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border-color);
    border-radius: 7px;
    background: var(--surface-color);
    color: var(--text-color);
    font: inherit;
}

.mgs-reset-input {
    display: block;
    min-height: 46px;
    padding: 10px 13px;
    font-size: 14px;
}

.mgs-reset-input:focus,
.mgs-reset-otp-input:focus {
    border-color: var(--theme-color);
    outline: 0;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-color) 12%, transparent);
}

/* Visual styling comes from the global .btn.dark system. */
.mgs-reset-submit {
    width: 100%;
}

.mgs-reset-otp {
    text-align: center;
}

.mgs-reset-description {
    margin-bottom: 20px;
    font-size: 13px;
}

.mgs-reset-otp-input {
    min-height: 54px;
    padding: 10px 14px;
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: .32em;
}

.mgs-reset-resend {
    margin-top: 17px;
    color: var(--muted-color);
    font-size: 12px;
    text-align: center;
}

.mgs-reset-resend-button {
    display: inline;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--link-color);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.mgs-reset-resend-button:hover,
.mgs-reset-resend-button:focus {
    color: var(--link-hover-color);
    text-decoration: underline;
}

.mgs-reset-resend-button:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--theme-color) 18%, transparent);
    outline-offset: 3px;
}

.mgs-reset-resend-button:disabled {
    color: var(--muted-color);
    text-decoration: none;
    cursor: not-allowed;
}

.mgs-reset-countdown {
    margin-top: 6px;
    color: var(--muted-color);
}

.mgs-reset-password {
    position: relative;
}

.mgs-reset-password .mgs-reset-input {
    padding-right: 48px;
}

.mgs-reset-password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    transform: translateY(-50%);
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--muted-color);
    cursor: pointer;
}

.mgs-reset-password-toggle:hover {
    background: var(--page-background);
    color: var(--text-color);
}

.mgs-reset-password-toggle:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--theme-color) 18%, transparent);
    outline-offset: 2px;
}

/* ==========================================================================\n   4. RESPONSIVE\n   ========================================================================== */
@media (max-width: 575px) {
    .user-profile-card {
        width: calc(100% - 32px);
        margin: 16px auto;
    }

    .user-profile-card .profile-header {
        flex-direction: column;
        gap: 14px;
        padding: 26px 20px 22px;
        text-align: center;
    }

    .user-profile-card .profile-photo {
        width: 82px;
        height: 82px;
    }

    .user-profile-card .profile-info h2 {
        font-size: 22px;
    }

    .user-profile-card .profile-details {
        padding: 6px 20px 2px;
    }

    .user-profile-card .detail-row {
        grid-template-columns: 1fr;
        gap: 4px;
        padding: 13px 0;
    }

    .user-profile-card .profile-group {
        padding: 18px 20px 22px;
    }

    .user-profile-card .profile-group .btn {
        width: 100%;
    }

    .form-container {
        margin: 16px auto;
        padding: 0 16px;
    }

    .form-container .right-panel {
        padding: 26px 20px 22px !important;
    }

    .form-container .right-panel > h2 {
        margin-bottom: 22px;
        font-size: 22px;
    }

    .profile-edit-card .form-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .profile-edit-card .form-actions .btn {
        width: 100%;
    }

    .mgs-reset {
        margin: 16px auto;
    }

    .mgs-reset-card {
        width: calc(100% - 32px);
        padding: 26px 20px 22px;
    }

    .mgs-reset-otp-input {
        font-size: 21px;
        letter-spacing: .25em;
    }
}

@media (prefers-reduced-motion: reduce) {
    .profile-edit-card input,
    .profile-edit-card select,
    .profile-edit-card textarea,
    .user-profile-card .btn,
    .profile-edit-card .btn {
        transition: none;
    }
}

/* ==========================================================================\n   PROFILE EDIT - CLEANED PHP PASSWORD TOGGLE\n   ========================================================================== */
.profile-edit-card .password-wrapper .profile-password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    transform: translateY(-50%);
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--muted-color);
    cursor: pointer;
}

.profile-edit-card .password-wrapper .profile-password-toggle:hover {
    background: var(--page-background);
    color: var(--text-color);
}

.profile-edit-card .password-wrapper .profile-password-toggle:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--theme-color) 18%, transparent);
    outline-offset: 2px;
}

.profile-edit-card .password-wrapper .profile-password-toggle .fa {
    position: static !important;
    width: auto;
    height: auto;
    transform: none !important;
    background: transparent;
}
