/* =========================================================================
   BP Member — Public CSS Tokens (v1.3.0+)
   Sibling plugins (bp-ticket, etc.) consume these. Do not rename.
   ========================================================================= */
:root {
    --bp-color-primary: #e11d48;
    --bp-color-primary-hover: #c1123c;
    --bp-color-text: #333;
    --bp-color-heading: #111;
    --bp-color-muted: #666;
    --bp-color-placeholder: #999;
    --bp-color-border: #ddd;
    --bp-color-bg: #f5f5f5;
    --bp-color-card: #fff;
    --bp-color-error: #e11d48;
    --bp-color-error-bg: #fef2f2;
    --bp-color-success: #15803d;
    --bp-color-success-bg: #f0fdf4;

    --bp-font: 'Kanit', -apple-system, BlinkMacSystemFont, sans-serif;

    --bp-radius-card: 12px;
    --bp-radius-input: 8px;
    --bp-radius-pill: 24px;
    --bp-radius-header: 16px;

    --bp-shadow-card: 0 4px 24px rgba(0, 0, 0, 0.12);
    --bp-shadow-input-focus: 0 0 0 3px rgba(225, 29, 72, 0.15);

    --bp-spacing-card: 24px;
    --bp-spacing-stack: 16px;

    --bp-header-bg: #fff;
    --bp-header-height: 64px;
    --bp-header-max: 1320px;
    --bp-content-max: 1200px;
}

/* =========================================================================
   BP Member — Base Styles
   ========================================================================= */

/* Reset */
.bp-member-page { margin: 0; padding: 0; background: var(--bp-color-bg); font-family: var(--bp-font); color: var(--bp-color-text); min-height: 100vh; }
.bp-member-page *, .bp-member-page *::before, .bp-member-page *::after { box-sizing: border-box; font-family: inherit; }

/* Header */
.bp-header { background: var(--bp-header-bg); padding: 0 24px; height: var(--bp-header-height); display: flex; align-items: center; max-width: var(--bp-header-max); margin: 0 auto; border-radius: 0 0 var(--bp-radius-header) var(--bp-radius-header); }
.bp-header-inner { max-width: var(--bp-content-max); width: 100%; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.bp-logo { text-decoration: none; color: var(--bp-color-primary); font-size: 22px; display: flex; align-items: center; }
.bp-logo-img { height: 36px; width: auto; display: block; }
.bp-card-logo .bp-logo-img { height: 48px; }
.bp-header-btn { background: #111; color: #fff; padding: 8px 20px; border-radius: var(--bp-radius-pill); text-decoration: none; font-size: 14px; white-space: nowrap; }
.bp-header-btn:hover { background: #333; }

/* Logged-in header dropdown */
.bp-header-dropdown { position: relative; }
.bp-header-user { display: flex; align-items: center; gap: 8px; background: #111; color: #fff; padding: 6px 16px 6px 8px; border-radius: var(--bp-radius-pill); font-size: 14px; text-decoration: none; border: none; cursor: pointer; }
.bp-header-user:hover { background: #333; }
.bp-header-user svg { transition: transform 0.2s; }
.bp-header-avatar { width: 28px; height: 28px; border-radius: 50%; background: #ccc; }
.bp-header-menu { display: none; position: absolute; top: calc(100% + 8px); right: 0; background: var(--bp-color-card); border-radius: var(--bp-radius-card); box-shadow: var(--bp-shadow-card); min-width: 280px; z-index: 100; overflow: hidden; padding: 8px 0; }
.bp-header-menu.open { display: block; }
.bp-header-menu a { display: flex; align-items: center; gap: 10px; padding: 12px 20px; color: var(--bp-color-text); text-decoration: none; font-size: 14px; transition: background 0.15s; }
.bp-header-menu a:hover { background: #f5f5f5; }
.bp-header-menu a svg { color: var(--bp-color-muted); flex-shrink: 0; }

/* Profile card section at the top of the dropdown */
.bp-header-menu-profile { display: flex; align-items: center; gap: 12px; padding: 16px 20px 12px; }
.bp-header-menu-avatar { width: 44px; height: 44px; border-radius: 50%; background: #e5e7eb; display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; }
.bp-header-menu-avatar img { width: 100%; height: 100%; object-fit: cover; }
.bp-header-menu-avatar svg { color: #9ca3af; }
.bp-header-menu-identity { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.bp-header-menu-name { font-size: 15px; font-weight: 700; color: var(--bp-color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bp-header-menu-email { font-size: 13px; color: var(--bp-color-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Black pill "edit profile" button — full-width within dropdown */
.bp-header-menu-edit { background: #111; color: #fff !important; border-radius: 999px; margin: 0 16px 12px; padding: 10px 18px !important; justify-content: center; font-weight: 600; }
/* Specificity bumped to beat the generic `.bp-header-menu a:hover` rule above
   (0,2,1) which otherwise paints the pill light-gray and hides the white text. */
.bp-header-menu a.bp-header-menu-edit:hover { background: #000; }
.bp-header-menu-edit svg { color: #fff !important; }

/* Section divider — used between profile/links and links/logout */
.bp-header-menu-divider { border: 0; border-top: 1px solid var(--bp-color-border); margin: 4px 0; }

/* Back link */
.bp-back-link { align-self: flex-start; display: inline-block; color: var(--bp-color-muted); text-decoration: none; font-size: 14px; border: 1px solid var(--bp-color-border); padding: 6px 16px; border-radius: 20px; margin-bottom: 16px; }
.bp-back-link:hover { background: var(--bp-color-card); }

/* Main */
.bp-main { display: flex; flex-direction: column; align-items: center; padding: 24px 0 60px; max-width: 1320px; margin: 0 auto; }

/* Alert banner */
.bp-alert { max-width: 1200px; margin: 0 auto 16px; padding: 12px 16px; border-radius: 8px; font-size: 14px; }
.bp-alert-error { background: var(--bp-color-error-bg); color: #b91c1c; border: 1px solid #fecaca; }
.bp-alert-success { background: var(--bp-color-success-bg); color: var(--bp-color-success); border: 1px solid #bbf7d0; }

/* Card wrapper */
.bp-card-wrap { width: 100%; max-width: 520px; }
.bp-card-wrap-wide { max-width: 860px; }
.bp-card-wrap-wide > * + * { margin-top: 20px; }
.bp-card-wrap-profile { max-width: 1200px; }
.bp-card-wrap-profile > * + * { margin-top: 20px; }

/* Card */
.bp-card { background: var(--bp-color-card); border-radius: var(--bp-radius-card); padding: 40px; width: 100%; }
.bp-card-wide { max-width: 860px; }
.bp-card-logo { display: flex; justify-content: center; font-size: 28px; color: var(--bp-color-primary); margin-bottom: 12px; }
.bp-card-title { text-align: center; font-size: 22px; font-weight: 700; color: var(--bp-color-heading); margin: 0 0 8px; }
.bp-card-subtitle { text-align: center; color: var(--bp-color-muted); font-size: 14px; margin: 0 0 8px; }
.bp-card-footer { text-align: center; margin-top: 24px; font-size: 14px; color: var(--bp-color-muted); }

/* Social buttons */
.bp-social-buttons { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.bp-social-btn { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; padding: 13px 16px; border: 1px solid var(--bp-color-border); border-radius: var(--bp-radius-input); text-decoration: none; color: var(--bp-color-text); font-size: 14px; background: var(--bp-color-card); cursor: pointer; transition: background 0.2s; }
.bp-social-btn img, .bp-social-btn svg { position: absolute; left: 16px; width: 20px; height: 20px; display: block; }
.bp-social-btn:hover { background: #f9f9f9; }

/* Divider */
.bp-divider { display: flex; align-items: center; margin: 20px 0; }
.bp-divider::before, .bp-divider::after { content: ''; flex: 1; border-bottom: 1px solid #ddd; }
.bp-divider span { padding: 0 16px; color: var(--bp-color-placeholder); font-size: 14px; }

/* Form fields */
.bp-field { margin-bottom: 16px; }
.bp-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.bp-required { color: var(--bp-color-primary); margin-left: 2px; }
.bp-member-page .bp-input { width: 100% !important; height: auto !important; padding: 12px 14px !important; border: 1px solid var(--bp-color-border) !important; border-radius: var(--bp-radius-input) !important; background: var(--bp-color-card) !important; color: var(--bp-color-text) !important; font-size: 14px !important; line-height: 1.4 !important; outline: none !important; box-shadow: none !important; transition: border-color 0.2s; font-family: inherit !important; }
.bp-member-page .bp-input:focus { border-color: var(--bp-color-heading) !important; box-shadow: none !important; }
.bp-member-page .bp-input.bp-input-error { border-color: var(--bp-color-error) !important; }
.bp-member-page .bp-input[readonly] { background: var(--bp-color-bg) !important; color: var(--bp-color-placeholder) !important; cursor: not-allowed; }
.bp-member-page input::placeholder, .bp-member-page textarea::placeholder { font-family: inherit; color: var(--bp-color-placeholder); opacity: 1; }
.bp-member-page input::-webkit-input-placeholder, .bp-member-page textarea::-webkit-input-placeholder { font-family: inherit; color: var(--bp-color-placeholder); }
.bp-member-page input::-moz-placeholder, .bp-member-page textarea::-moz-placeholder { font-family: inherit; color: var(--bp-color-placeholder); opacity: 1; }
.bp-member-page input:-ms-input-placeholder, .bp-member-page textarea:-ms-input-placeholder { font-family: inherit; color: var(--bp-color-placeholder); }
.bp-field-error { display: block; color: var(--bp-color-error); font-size: 12px; margin-top: 4px; min-height: 16px; }
.bp-field-hint { color: var(--bp-color-placeholder); font-size: 12px; margin-top: 4px; }

/* Select/Dropdown */
.bp-member-page .bp-select { width: 100% !important; height: auto !important; padding: 12px 14px !important; border: 1px solid var(--bp-color-border) !important; border-radius: var(--bp-radius-input) !important; font-size: 14px !important; line-height: 1.4 !important; color: var(--bp-color-text) !important; outline: none !important; box-shadow: none !important; background: var(--bp-color-card) !important; -webkit-appearance: none !important; -moz-appearance: none !important; appearance: none !important; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E") !important; background-repeat: no-repeat !important; background-position: right 14px center !important; cursor: pointer; font-family: inherit !important; }
.bp-member-page .bp-select:focus { border-color: var(--bp-color-heading) !important; box-shadow: none !important; }
.bp-member-page .bp-select.bp-input-error { border-color: var(--bp-color-error) !important; }

/* Buttons */
.bp-member-page .bp-btn { display: inline-flex !important; align-items: center !important; justify-content: center !important; height: auto !important; padding: 12px 24px !important; border-radius: 50px !important; font-size: 16px !important; font-weight: 600 !important; line-height: 1.4 !important; border: none !important; cursor: pointer; transition: background 0.2s, opacity 0.2s; text-decoration: none !important; text-transform: none !important; text-shadow: none !important; font-family: inherit !important; }
.bp-member-page .bp-btn-primary { background: #111 !important; color: #fff !important; }
.bp-member-page .bp-btn-primary:hover { background: #333 !important; }
.bp-member-page .bp-btn-secondary { background: #fff !important; color: #111 !important; border: 1px solid #171717 !important; }
.bp-member-page .bp-btn-secondary:hover { background: #f5f5f5 !important; }
.bp-member-page .bp-btn-full { width: 100% !important; }
.bp-member-page .bp-btn-submit { display: block !important; min-width: 160px; width: fit-content !important; margin: 0 auto !important; }
.bp-member-page .bp-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.bp-btn-row { display: flex; gap: 12px; margin-top: 24px; }
.bp-btn-row.bp-btn-row-stretch .bp-btn { flex: 1; }

/* Link */
.bp-link { color: #e11d48; text-decoration: none; }
.bp-link:hover { text-decoration: underline; }
.bp-link-policy { color: #111; text-decoration: underline; }
.bp-link-policy:hover { color: #333; }

/* OTP Input */
.bp-otp-inputs { display: flex; gap: 10px; justify-content: center; margin: 24px 0; }
.bp-member-page .bp-otp-input { width: 52px !important; height: 60px !important; padding: 0 !important; text-align: center !important; font-size: 24px !important; font-weight: 700 !important; line-height: 1 !important; color: #111 !important; background: #fff !important; border: 1px solid #ddd !important; border-radius: 8px !important; outline: none !important; box-shadow: none !important; font-family: inherit !important; }
.bp-member-page .bp-otp-input:focus { border-color: #111 !important; box-shadow: none !important; }
.bp-member-page .bp-otp-input.error { border-color: #E01C24 !important; color: #E01C24 !important; }
.bp-member-page .bp-otp-input.success { border-color: #4CAF50 !important; }
.bp-otp-info { text-align: center; color: #666; font-size: 14px; margin-bottom: 8px; }

/* Password validation rules */
.bp-password-rules { list-style: none; padding: 0; margin: 12px 0; }
.bp-password-rules li { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 6px; color: #333; }
.bp-password-rules li .icon { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.bp-password-rules li .icon svg { fill: #E01C24; }
.bp-password-rules li.valid .icon svg { fill: #16a34a; }

/* Password toggle */
.bp-password-wrapper { position: relative; }
.bp-member-page .bp-password-wrapper .bp-input { padding-right: 44px !important; }
.bp-password-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none !important; border: none !important; cursor: pointer; color: #111; padding: 4px !important; display: flex; align-items: center; box-shadow: none !important; }
.bp-input-icon-wrap { position: relative; }
.bp-input-icon-wrap .bp-input-icon-left { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: #666; pointer-events: none; display: flex; align-items: center; }
.bp-member-page .bp-input-icon-wrap .bp-input { padding-left: 44px !important; }
/* Lucide icon base */
.bp-member-page svg { display: inline-block; vertical-align: middle; flex-shrink: 0; color: #111; }
.bp-back-link svg { vertical-align: -3px; }
.bp-consent-check svg { display: block; }

/* Checkbox */
.bp-checkbox-group { margin: 20px 0; }
.bp-checkbox-label { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: #333; margin-bottom: 10px; cursor: pointer; }
.bp-checkbox-label input[type="checkbox"] { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; accent-color: #e11d48; }
.bp-checkbox-label.bp-checkbox-master { font-weight: 600; padding-bottom: 8px; border-bottom: 1px solid #eee; margin-bottom: 12px; }
.bp-checkbox-sub { padding-left: 0; }

/* Two-column grid */
.bp-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
@media (max-width: 600px) {
    .bp-main { padding-left: 16px; padding-right: 16px; }
    .bp-grid-2 { grid-template-columns: 1fr; }
    .bp-card { padding: 20px 16px; }
    .bp-profile-section { padding: 20px 16px; }
    .bp-btn-row { flex-wrap: wrap; }
}

/* Toast notification */
.bp-toast { position: fixed; top: 24px; left: 50%; transform: translateX(-50%) translateY(-16px); background: #24B472CC; color: #262626; padding: 14px 32px; border-radius: 0; font-size: 15px; font-weight: 600; z-index: 9999; opacity: 0; min-width: 220px; text-align: center; white-space: nowrap; transition: opacity 0.3s, transform 0.3s; pointer-events: none; }
.bp-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.bp-toast.error { background: #e11d48; color: #fff; }

/* Modal/Popup */
.bp-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 9998; }
.bp-modal { background: #fff; border-radius: 12px; padding: 40px; max-width: 480px; width: 90%; text-align: center; }
.bp-modal-title { font-size: 20px; font-weight: 700; margin: 0 0 12px; color: #262626; }
.bp-modal-message { font-size: 14px; color: #666; margin: 0 0 24px; line-height: 1.6; }
.bp-modal-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.bp-modal-actions .bp-btn { min-width: 120px; }

/* Profile sections */
.bp-profile-section { background: #fff; border-radius: 12px; padding: 30px; margin-bottom: 20px; }
.bp-profile-section-title { font-size: 18px; font-weight: 700; margin: 0 0 20px; color: #111; display: flex; align-items: center; justify-content: space-between; }
.bp-profile-avatar { position: relative; width: 160px; height: 160px; border-radius: 50%; background: #f0f0f0; border: 3px solid #e0e0e0; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #ccc; }
.bp-profile-avatar > svg { width: 72px; height: 72px; }
.bp-avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.bp-header-avatar { overflow: hidden; }
.bp-header-avatar .bp-avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.bp-avatar-upload-btn { position: absolute; bottom: 6px; right: 6px; width: 36px; height: 36px; background: #fff; border: 2px solid #ddd; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.1); transition: background 0.2s; z-index: 2; }
.bp-avatar-upload-btn:hover { background: #f5f5f5; }
.bp-avatar-upload-btn svg { color: #888; pointer-events: none; }
.bp-avatar-uploading { opacity: 0.5; pointer-events: none; }
.bp-avatar-uploading::after { content: ''; position: absolute; top: 50%; left: 50%; width: 24px; height: 24px; margin: -12px 0 0 -12px; border: 2px solid #ccc; border-top-color: #333; border-radius: 50%; animation: bp-spin 0.6s linear infinite; }
.bp-profile-card { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "title title" "avatar form"; gap: 0 30px; }
.bp-profile-card > .bp-profile-section-title { grid-area: title; }
.bp-profile-card > .bp-profile-avatar-wrap { grid-area: avatar; align-self: start; }
.bp-profile-card > .bp-profile-form-wrap { grid-area: form; min-width: 0; }
.bp-profile-row { display: flex; gap: 30px; }
.bp-profile-avatar-wrap { flex-shrink: 0; }
.bp-profile-form-wrap { flex: 1; min-width: 0; }
.bp-profile-bottom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* Social account list */
.bp-social-list { display: flex; flex-direction: column; gap: 12px; }
.bp-social-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid #f0f0f0; }
.bp-social-item:last-child { border-bottom: none; }
.bp-social-item-info { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.bp-social-item-icon { width: 24px; height: 24px; }

/* Consent display */
.bp-consent-item { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; margin-bottom: 10px; }
.bp-consent-check { color: #16a34a; font-size: 16px; flex-shrink: 0; }
.bp-consent-check.unchecked { color: #e11d48; }

/* Loading spinner */
.bp-loading { pointer-events: none; opacity: 0.7; }
.bp-spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid #fff; border-top-color: transparent; border-radius: 50%; animation: bp-spin 0.6s linear infinite; }
@keyframes bp-spin { to { transform: rotate(360deg); } }

/* Social link actions */
.bp-social-link-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.bp-social-link-actions .bp-btn { min-width: 160px; }

/* Profile responsive (must be after base profile rules) */
@media (max-width: 768px) {
    .bp-profile-card { grid-template-columns: 1fr; grid-template-areas: "avatar" "title" "form"; justify-items: center; gap: 16px 0; }
    .bp-profile-card > .bp-profile-section-title { justify-content: center; flex-direction: column; align-items: center; gap: 10px; text-align: center; width: 100%; }
    .bp-profile-card > .bp-profile-form-wrap { width: 100%; justify-self: stretch; }
    .bp-profile-avatar { width: 120px; height: 120px; }
    .bp-profile-avatar > svg { width: 54px; height: 54px; }
    .bp-profile-bottom-grid { grid-template-columns: 1fr; }
    .bp-social-link-actions { flex-direction: column; }
    .bp-social-link-actions .bp-btn { width: 100%; min-width: unset; }
}

/* =========================================================================
   Login Modal — bpMember.requireAuth() (since 1.3.0)
   ========================================================================= */
.bp-auth-modal { display: none; position: fixed; inset: 0; z-index: 9999; overflow-y: auto; }
.bp-auth-modal.bp-auth-modal-open { display: block; }
.bp-auth-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.bp-auth-modal-dialog { position: relative; max-width: 420px; margin: 80px auto; background: var(--bp-color-card); border-radius: var(--bp-radius-card); padding: var(--bp-spacing-card); box-shadow: var(--bp-shadow-card); font-family: var(--bp-font); }
@media (max-width: 480px) { .bp-auth-modal-dialog { margin: 16px; } }
.bp-auth-modal-close { position: absolute; top: 12px; right: 12px; background: transparent; border: none; cursor: pointer; color: var(--bp-color-muted); padding: 4px; }
.bp-auth-modal-close:hover { color: var(--bp-color-heading); }
.bp-auth-modal-title { font-size: 22px; font-weight: 700; color: var(--bp-color-heading); margin: 0 0 4px; text-align: center; }
.bp-auth-modal-subtitle { font-size: 14px; color: var(--bp-color-muted); margin: 0 0 20px; text-align: center; }
.bp-auth-modal-form { display: flex; flex-direction: column; gap: 12px; }
.bp-auth-modal-footer { font-size: 14px; color: var(--bp-color-muted); margin-top: 16px; text-align: center; }
.bp-auth-modal-footer a { color: var(--bp-color-primary); text-decoration: none; font-weight: 600; }
body.bp-auth-modal-locked { overflow: hidden; }
