/* ============================================================================
   การ์ดตัวแทนจากลิงก์แนะนำ (?ref=รหัสตัวแทน) - งาน #113
   components/agent-referral/card (hero | sheet | section | preview), hero, dock + agent-referral.js
   layouts/property ไม่กำหนด --theme-font-family จึงตั้งฟอนต์ของการ์ดเอง (แบบเดียวกับ agent-missions.css)
   ไม่มีแถบสีขอบซ้าย ไม่ยกการ์ดตอน hover (CLAUDE.md / ux-review lessons)
   ========================================================================== */

.arc, .arc-hero, .ard, .ard-panel {
    font-family: var(--theme-font-family, 'Sarabun', 'Segoe UI', sans-serif);
}
.arc-name, .ard-panel-title, .ard-fab-name, .arc-initial {
    font-family: var(--theme-font-family-heading, 'Prompt', 'Segoe UI', sans-serif);
}

/* ── การ์ด ─────────────────────────────────────────────────────────────── */
.arc {
    background: #fff;
    border-radius: 20px;
    color: #1e293b;
    text-align: left;
    min-width: 0;
}
.arc-head {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}
.arc-avatar {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    background: #E3F3E9;
    box-shadow: 0 0 0 3px #fff, 0 6px 16px rgba(3, 84, 50, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
}
.arc-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.arc-avatar--initial {
    background: linear-gradient(145deg, #0B7A46 0%, #035432 100%);
}
.arc-initial {
    color: #fff;
    font-weight: 600;
    font-size: 1.75rem;
    line-height: 1;
    /* พยัญชนะไทยนั่งต่ำกว่ากลางกล่องบรรทัดประมาณ .05em (วัดจากพิกเซลที่วาดจริง) - ยกขึ้นให้อยู่กลางวง */
    padding-bottom: .1em;
}
/* ตัวอักษรละติน/ตัวเลขนั่งสูงกว่ากลางกล่องอยู่แล้ว (.5px ที่ 19px) - ไม่ยกซ้ำ ดึงลงนิดเดียว */
.arc-initial--latin {
    padding-bottom: 0;
    padding-top: .08em;
}

/* ไอคอนในวง/กล่อง (Bootstrap Icons) ต้องอยู่กลางจริงที่พิกเซล ไม่ใช่แค่กลางกล่อง layout (2026-11-05, ผู้ใช้เจอซ้ำหลายครั้ง):
   1) <i> สืบฟอนต์ตัวหนังสือของหน้า (Sarabun) เป็นฟอนต์ค้ำบรรทัด -> baseline ของไอคอนเลื่อนขึ้น 1-2px
      แก้ด้วย font-family: bootstrap-icons + line-height: 1 ที่ตัว <i> เอง
   2) font-size เป็นเศษ (1.12rem = 17.92px) ทำให้ glyph ถูก raster ไม่ตรงพิกเซล เยื้อง .5-1px ที่จอ 1x
      ใช้ px จำนวนเต็มคู่ (12/14/16/18/20/22/24) ในวงที่กว้างเป็น px อยู่แล้ว
   ตรวจ: npm run browser:check -- --centre=".arc-row-icon|.arc-row-icon i" (วัดพิกเซลที่วาด ไม่ใช่กรอบกล่อง) */
.ard-fab-badge .bi,
.ard-close .bi,
.arc-row-icon .bi {
    font-family: bootstrap-icons;
    line-height: 1;
}
.arc-who {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}
.arc-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #E3F3E9;
    color: #035432;
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1.3;
    padding: 3px 10px 3px 8px;
    border-radius: 999px;
    margin-bottom: 3px;
}
.arc-eyebrow .bi {
    font-size: 0.82rem;
    line-height: 1;
}
.arc-eyebrow .bi::before { vertical-align: -0.1em; }
.arc-name {
    font-size: 1.16rem;
    font-weight: 600;
    color: #023F25;
    line-height: 1.35;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
/* ชื่อนิติบุคคลยาว (ห้างหุ้นส่วนจำกัด ... (ประเทศไทย)) ต้องเห็นครบ - ตัวเล็กลงและได้ 3 บรรทัด */
.arc-name--long {
    font-size: 1rem;
    -webkit-line-clamp: 3;
}
.arc-meta {
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.4;
}

/* แถวช่องทางติดต่อ: ไอคอน + ป้าย/ค่า + ปุ่มบอกว่ากดแล้วได้อะไร ทั้งแถวกดได้ (≥ 54px) */
.arc-list {
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
/* flex-wrap: ตัวอักษรใหญ่ (ตั้งค่าบนมือถือ) แล้วที่ไม่พอ ปุ่มด้านขวาลงบรรทัดใหม่ แทนการหักเบอร์/ไลน์ไอดีกลางคำ */
.arc-row {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    min-height: 56px;
    padding: 8px 10px 8px 8px;
    border: 1px solid #E3EBE6;
    border-radius: 14px;
    background: #fff;
    color: inherit;
    text-decoration: none;
    text-align: left;
    font: inherit;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.arc-row:hover,
.arc-row:focus {
    background: #F6FAF7;
    border-color: #CFE3D7;
    color: inherit;
    text-decoration: none;
}
.arc-row:active { background: #EDF6F0; }
.arc-row:focus-visible {
    outline: 2px solid #035432;
    outline-offset: 2px;
}
.arc-row-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
}
.arc-row-icon .bi::before { vertical-align: 0; }
.arc-row--phone .arc-row-icon { background: #035432; }
.arc-row--line .arc-row-icon { background: #06C755; font-size: 22px; }
.arc-row--fb .arc-row-icon { background: #1877F2; font-size: 20px; }
.arc-row--web .arc-row-icon { background: #475569; }
.arc-row-text {
    flex: 1 1 7.2rem; /* กว้างพอเบอร์ 10 หลัก (rem ตามขนาดตัวอักษรที่ผู้ใช้ตั้ง - body ของหน้าเป็น px) ไม่พอ = ปุ่มขวาลงบรรทัดใหม่ */
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}
.arc-row-label {
    font-size: 0.74rem;
    color: #64748b;
    font-weight: 600;
}
/* ไลน์ไอดี/เบอร์ต้องเห็นครบทุกตัว (ลูกค้าเอาไปค้นเอง) - ไม่ตัด "..." ยาวเกินขึ้นบรรทัดใหม่ได้ 2 บรรทัด */
.arc-row-value {
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.arc-row-value--tel {
    white-space: nowrap;
    overflow-wrap: normal;
}
.arc-row-go {
    flex-shrink: 0;
    margin-left: auto;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.2;
    padding: 7px 12px;
    border-radius: 999px;
    white-space: nowrap;
}
.arc-row--phone .arc-row-go { background: #E3F3E9; color: #035432; }
.arc-row--line .arc-row-go { background: #E3F8EC; color: #047A36; }
.arc-row--fb .arc-row-go { background: #E8F1FE; color: #1461C9; }
.arc-row--web .arc-row-go { background: #F1F5F9; color: #334155; }

/* ── หน้าแรก: การ์ดบนสุดของ hero ─────────────────────────────────────── */
.arc-hero {
    max-width: 900px;
    margin: 0 auto 1.25rem;
    position: relative;
    z-index: 3;
}
.arc--hero {
    padding: 16px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 24px 48px -20px rgba(2, 40, 24, 0.6);
}
.arc-preview-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px 12px;
    background: #FFF7E6;
    border: 1px solid #FFD591;
    color: #7A4B00;
    border-radius: 14px;
    padding: 8px 12px;
    margin-bottom: 10px;
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1.4;
}
.arc-preview-note-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.arc-preview-note a {
    color: #035432;
    font-weight: 700;
    text-decoration: underline;
}
@media (min-width: 768px) {
    .arc--hero {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
        gap: 22px;
        align-items: center;
        padding: 20px 22px;
    }
    .arc--hero .arc-avatar { width: 92px; height: 92px; }
    .arc--hero .arc-initial { font-size: 2.3rem; }
    .arc--hero .arc-name { font-size: 1.4rem; }
    .arc--hero .arc-name--long { font-size: 1.15rem; }
    .arc--hero .arc-list { margin-top: 0; }
}

/* ── หน้าทรัพย์: การ์ดในคอลัมน์ขวา (มือถืออยู่ตำแหน่งเดียวกับการ์ดเจ้าของทรัพย์) ─────── */
.pd-agent-ref-section { padding: 1rem 1.1rem; }
.pd-agent-ref-section .pd-section-title { margin-bottom: 0.75rem; }
.arc--section { background: transparent; border-radius: 0; }
.arc--section .arc-avatar { width: 52px; height: 52px; box-shadow: 0 0 0 2px #fff, 0 6px 14px rgba(3, 84, 50, 0.16); }
.arc--section .arc-initial { font-size: 1.38rem; }
.arc--section .arc-name { font-size: 1rem; }
.arc--section .arc-list { margin-top: 12px; }
.arc--section .arc-row-value { font-size: 0.94rem; }
.arc--section .arc-row-go { padding: 6px 10px; }
@media (min-width: 768px) {
    .pd-agent-ref-section { padding: 1.2rem 1.45rem; }
}
@media (max-width: 991.98px) {
    #pd-agent-ref-section { order: 6; }
}

/* ── หน้าโปรไฟล์ตัวแทน: ตัวอย่างการ์ด ─────────────────────────────────── */
/* อยู่ในการ์ดของหน้าโปรไฟล์อยู่แล้ว - ไม่ใส่กรอบซ้อนกรอบ และไม่เว้นที่ให้ส่วนหัวที่เอาออกไป */
.arc--preview {
    background: transparent;
    border-radius: 0;
    padding: 0;
}
.arc--preview .arc-list { margin-top: 0; }
.arc-empty {
    margin: 0;
    padding: 14px 16px;
    border: 1px dashed #CBD9D0;
    border-radius: 14px;
    background: #F7FAF8;
    color: #4b5563;
    font-size: 0.88rem;
    line-height: 1.55;
}

/* ── ปุ่มลอย "ตัวแทนของคุณ" ────────────────────────────────────────────── */
.ard {
    position: fixed;
    right: 12px;
    bottom: 72px;
    z-index: 1036;
    transition: opacity 0.2s ease, visibility 0.2s ease, bottom 0.25s ease;
}
.ard.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.ard-fab {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100vw - 24px);
    padding: 5px 16px 5px 5px;
    border: 0;
    border-radius: 999px;
    background: #fff;
    color: #023F25;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.14), 0 10px 28px -8px rgba(2, 40, 24, 0.5);
    font: inherit;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: box-shadow 0.15s ease;
}
.ard-fab:hover { box-shadow: 0 1px 2px rgba(15, 23, 42, 0.14), 0 14px 32px -8px rgba(2, 40, 24, 0.62); }
.ard-fab:focus-visible { outline: 2px solid #035432; outline-offset: 3px; }
.ard-fab-avatar {
    position: relative;
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #E3F3E9;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ard-fab-avatar.arc-avatar--initial {
    background: linear-gradient(145deg, #0B7A46 0%, #035432 100%);
}
.ard-fab-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}
.ard-fab-avatar .arc-initial { font-size: 1.2rem; }
.ard-fab-badge {
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #0B7A46;
    color: #fff;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px #fff;
}
.ard-fab-badge .bi::before { vertical-align: 0; }
.ard-fab-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}
.ard-fab-kicker {
    font-size: 0.7rem;
    color: #64748b;
    font-weight: 600;
}
.ard-fab-name {
    font-size: 0.95rem;
    font-weight: 600;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (min-width: 1200px) {
    .ard { right: 24px; bottom: 24px; }
    .ard-fab-name { max-width: 200px; }
}
/* หน้าทรัพย์จอใหญ่: การ์ดตัวแทนอยู่ใต้การ์ดจองในคอลัมน์ขวาแล้ว ปุ่มลอยจะไปบังการ์ดจอง จึงไม่แสดง */
@media (min-width: 992px) {
    .ard[data-ard-desktop-off] { display: none; }
}

/* ── แผ่นติดต่อ: มือถือ = แผ่นจากล่างจอ, จอใหญ่ = การ์ดเหนือปุ่มลอย ─────────────── */
.ard-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1070;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.ard-backdrop.is-open { opacity: 1; }
.ard-backdrop[hidden],
.ard-panel[hidden] { display: none; }
.ard-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1071;
    background: #fff;
    border-radius: 22px 22px 0 0;
    padding: 12px 16px calc(18px + env(safe-area-inset-bottom, 0px));
    max-height: 88vh;
    max-height: 88dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.28);
    transform: translateY(100%);
    transition: transform 0.22s ease;
}
.ard-panel.is-open { transform: translateY(0); }
.ard-panel:focus { outline: none; }
.ard-panel-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.ard-panel-title {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 600;
    color: #023F25;
}
.ard-close {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 0;
    background: #F1F5F9;
    color: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
}
.ard-close .bi::before { vertical-align: 0; }
.ard-close:hover { background: #E2E8F0; }
.ard-close:focus-visible { outline: 2px solid #035432; outline-offset: 2px; }
.arc--sheet { border-radius: 0; }
body.ard-open { overflow: hidden; }
@media (min-width: 768px) {
    .ard-backdrop { background: transparent; }
    .ard-panel {
        left: auto;
        right: 24px;
        width: 384px;
        border-radius: 20px;
        padding: 14px 18px 18px;
        max-height: calc(100vh - 140px);
        box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1), 0 24px 56px -12px rgba(15, 23, 42, 0.38);
        transform: translateY(10px);
        opacity: 0;
        transition: transform 0.18s ease, opacity 0.18s ease;
    }
    .ard-panel.is-open { transform: translateY(0); opacity: 1; }
    body.ard-open { overflow: auto; }
}

/* ตัวแทนที่ล็อกอินเห็นการ์ดของตัวเอง (แผ่นติดต่อ / หน้าทรัพย์) - บอกว่าลูกค้าเห็นแบบนี้ + ลิงก์ไปแก้ */
.arc-self-note {
    margin: 12px 0 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 8px;
    padding: 8px 12px;
    border-radius: 12px;
    background: #F1F5F9;
    color: #475569;
    font-size: 0.82rem;
    line-height: 1.45;
}
.arc-self-note .bi { color: #64748B; line-height: 1; }
.arc-self-note span { flex: 1 1 10rem; min-width: 0; }
.arc-self-note a {
    font-weight: 700;
    color: #035432;
    text-decoration: none;
    white-space: nowrap;
}
.arc-self-note a:hover { text-decoration: underline; }
