﻿/* 플라워링크 상담 — 메신저형 디자인. 색·글꼴·로고는 홈페이지(site.css·site.master)와 같게(남색+장미색, Pretendard). 색은 아래 변수로만. 흐리지 않게: 본문 진하게·테두리 분명하게 */
:root {
    --navy: #14305c;
    --navy-2: #0b1f40;
    --primary: #14305c;      /* 홈페이지 주 색(남색) */
    --primary-2: #0b1f40;
    --primary-soft: #e8edf6;
    --rose: #e2456f;         /* 홈페이지 포인트 색 */
    --rose-2: #c32f58;
    --rose-soft: #fde8ee;
    --ink: #0f172a;          /* 본문 */
    --ink-2: #263244;        /* 보조(그래도 진하게) */
    --ink-3: #3f4b5e;        /* 시간 등 작은 글 */
    --line: #a3b1c6;         /* 테두리 */
    --line-strong: #6a7a93;
    --bg: #f3f6fb;           /* 대화 바탕 */
    --surface: #ffffff;
    --surface-2: #f2f5fa;
    --ok: #12a150;
    --warn: #e07800;
    --warn-soft: #fff4e5;
    --danger: #d02f2f;
    --sys-bg: #d9e1ec;
    --sys-ink: #1b2636;
    --radius: 18px;
    --shadow: 0 2px 10px rgba(13, 35, 71, .14);
    --font: "Pretendard Variable", "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
    font-family: var(--font); font-size: 15.5px; color: var(--ink); background: var(--bg);
    -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased;
}
button, textarea, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
svg { display: block; }

/* ── 단추 ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink);
    font-weight: 700; padding: 9px 16px; border-radius: 10px; cursor: pointer; white-space: nowrap;
    transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.small { padding: 6px 12px; font-size: 14px; border-radius: 9px; }
.btn.primary { background: var(--primary); border-color: var(--primary-2); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { background: var(--danger); border-color: #a32020; color: #fff; }
.btn.warn { background: var(--warn); border-color: #b35f00; color: #fff; }
.btn.ghost-w { background: transparent; border-color: rgba(255, 255, 255, .7); color: #fff; }
.btn.ghost-w:hover { background: rgba(255, 255, 255, .12); }

.icon-btn {
    width: 42px; height: 42px; border-radius: 50%; border: 0; flex: none; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; transition: background .15s, transform .1s;
}
.icon-btn:active { transform: scale(.94); }

/* ── 머리 공통 ── */
.logo { width: 40px; height: 40px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; }
.logo svg { width: 100%; height: 100%; }
.logo.sm { width: 34px; height: 34px; background: #fff; padding: 2px; }   /* 남색 머리 위에서도 보이게 흰 테 */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(18, 161, 80, .22); }
.dot.wait { background: var(--warn); box-shadow: 0 0 0 3px rgba(224, 120, 0, .22); }
.dot.idle { background: var(--primary); }
.dot.end { background: #5b6a80; }

/* ── 대화 ── */
.log {
    flex: 1; overflow-y: auto; padding: 10px 12px 12px; background: var(--bg);
    -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.day { display: flex; justify-content: center; margin: 16px 0 8px; }
.day span {
    background: rgba(20, 48, 92, .86); color: #fff; font-size: 12.5px; font-weight: 600;
    padding: 4px 12px; border-radius: 999px;
}
.row { display: flex; gap: 8px; margin-top: 3px; align-items: flex-start; }
.row.first { margin-top: 12px; }
.row.me { justify-content: flex-end; }
.row .col { display: flex; flex-direction: column; max-width: 76%; min-width: 0; }
.row.me .col { align-items: flex-end; }
.row .line { display: flex; align-items: flex-end; gap: 6px; max-width: 100%; }
.row.me .line { flex-direction: row-reverse; }
.bub {
    padding: 9px 13px; border-radius: var(--radius); line-height: 1.45; font-size: 15.5px;
    white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; min-width: 0;
}
.row.me .bub { background: var(--primary); color: #fff; }
.row.other .bub { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.row.me.last .bub { border-bottom-right-radius: 5px; }     /* 꼬리 */
.row.other.last .bub { border-bottom-left-radius: 5px; }
.time { font-size: 11.5px; font-weight: 600; color: var(--ink-3); white-space: nowrap; flex: none; padding-bottom: 2px; }
.row:not(.last) .time { display: none; }
.av {
    width: 36px; height: 36px; border-radius: 50%; background: var(--navy); color: #fff; flex: none;
    font-weight: 800; font-size: 15px; display: flex; align-items: center; justify-content: center;
}
.row.cont .av { visibility: hidden; height: 1px; }
.name { font-size: 13px; font-weight: 700; color: var(--ink-2); margin: 0 0 4px 2px; }
.row.sys { justify-content: center; margin: 12px 0; }
.pill {
    background: var(--sys-bg); color: var(--sys-ink); border: 1px solid #b9c5d6; font-size: 13px; font-weight: 600;
    padding: 6px 14px; border-radius: 999px; max-width: 90%; text-align: center; line-height: 1.4;
}
.row.anim { animation: rise .22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 말풍선 안 사진 */
.bub.img {
    padding: 0; max-width: 100%; overflow: hidden; position: relative; line-height: 0; cursor: zoom-in;
    background: #c9d3e2 !important; border: 1px solid var(--line) !important;
}
.bub.img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pending .bub.img img { opacity: .7; }
.prog { position: absolute; left: 10px; right: 10px; bottom: 10px; height: 6px; background: rgba(0, 0, 0, .4); border-radius: 3px; overflow: hidden; }
.prog i { display: block; height: 100%; width: 0; background: #fff; transition: width .15s; }
.retry {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); line-height: 1.2;
    background: var(--danger); color: #fff; border: 2px solid #fff; border-radius: 999px;
    padding: 7px 14px; font-weight: 800; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.pending:not(.failed) .retry { display: none; }
.pending.failed .prog { display: none; }

/* ── 입력줄 ── */
.composer {
    display: flex; align-items: flex-end; gap: 8px; background: var(--surface);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(13, 35, 71, .07);
}
.attach { background: var(--surface-2); color: var(--navy); border: 1.5px solid var(--line-strong); }
.attach:hover { background: var(--rose-soft); }
.sendbtn { background: var(--rose); color: #fff; }
.sendbtn:hover { background: var(--rose-2); }
.sendbtn:disabled { background: #93a3ba; cursor: default; transform: none; }
.field {
    flex: 1; min-width: 0; display: flex; align-items: center; min-height: 42px; padding: 0 16px;
    background: var(--surface-2); border: 1.5px solid var(--line-strong); border-radius: 22px;
    transition: border-color .15s, box-shadow .15s;
}
.field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(20, 48, 92, .18); background: #fff; }
.field textarea {
    flex: 1; min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; resize: none; color: var(--ink);
    font-size: 16px; line-height: 22px; padding: 9px 0; height: 40px; max-height: 130px; /* 5줄 */
}
.field textarea::placeholder { color: #5d6b80; }

/* ── 아래에서 올라오는 메뉴 ── */
.sheet-bg {
    position: fixed; inset: 0; z-index: 50; background: rgba(8, 18, 36, .5);
    display: flex; align-items: flex-end; justify-content: center; animation: fade .15s;
}
.sheet {
    width: 100%; max-width: 480px; background: var(--surface); border-radius: 18px 18px 0 0;
    padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); animation: up .22s ease-out;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, .2);
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: #9aa8bc; margin: 2px auto 8px; }
.sheet .item {
    display: flex; align-items: center; gap: 14px; width: 100%; padding: 13px 12px; border: 0;
    background: transparent; border-radius: 12px; font-size: 16px; font-weight: 700; color: var(--ink); cursor: pointer; text-align: left;
}
.sheet .item:hover { background: var(--surface-2); }
.sheet .item .ic { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; background: var(--primary); }
.sheet .item .ic.green { background: var(--ok); }
.sheet .cancel {
    width: 100%; margin-top: 6px; padding: 12px; border-radius: 12px; border: 1.5px solid var(--line);
    background: var(--surface-2); font-weight: 700; font-size: 16px; cursor: pointer;
}
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ── 확인 창 ── */
.modal-bg {
    position: fixed; inset: 0; z-index: 60; background: rgba(8, 18, 36, .5);
    display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .15s;
}
.modal { width: 100%; max-width: 340px; background: var(--surface); border-radius: 16px; padding: 20px; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); animation: pop .18s ease-out; }
.modal h3 { margin: 0 0 8px; font-size: 18px; }
.modal p { margin: 0 0 18px; color: var(--ink-2); line-height: 1.5; }
.modal .acts { display: flex; gap: 8px; justify-content: flex-end; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── 사진 크게 보기 ── */
.viewer { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .93); display: flex; align-items: center; justify-content: center; animation: fade .15s; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; -webkit-touch-callout: default; }
.viewer .close {
    position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 12px; width: 46px; height: 46px;
    border-radius: 50%; background: rgba(255, 255, 255, .18); color: #fff; border: 1.5px solid rgba(255, 255, 255, .7);
}

/* ── 알림 띠 ── */
.toast {
    position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 80;
    background: var(--danger); color: #fff; font-weight: 700; padding: 10px 16px; border-radius: 12px;
    box-shadow: var(--shadow); max-width: calc(100% - 24px); animation: fade .15s;
}

@media (prefers-reduced-motion: reduce) {
    .row.anim, .sheet, .sheet-bg, .modal, .modal-bg, .viewer, .toast { animation: none; }
}

/* ════════ 고객 상담창 ════════ */
body.cust .app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: var(--surface); }
.top {
    display: flex; align-items: center; gap: 12px; background: var(--surface); position: relative; z-index: 2;
    padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
    border-bottom: 1px solid var(--line); box-shadow: 0 2px 10px rgba(13, 35, 71, .1);
}
.top h1 { margin: 0; font-size: 17px; font-weight: 800; color: var(--ink); }
.top .st { display: flex; align-items: center; gap: 7px; margin-top: 3px; font-size: 13.5px; font-weight: 700; color: var(--ink-2); }
@media (min-width: 520px) {
    body.cust { display: flex; align-items: center; justify-content: center; padding: 20px; }
    body.cust .app {
        width: 100%; max-width: 480px; height: calc(100vh - 40px); height: calc(100dvh - 40px); max-height: 900px;
        border-radius: 22px; overflow: hidden; border: 1px solid var(--line); box-shadow: 0 14px 44px rgba(13, 35, 71, .25);
    }
}

/* ════════ 상담원 로그인 ════════ */
body.login { display: flex; align-items: center; justify-content: center; padding: 20px; min-height: 100vh; min-height: 100dvh; }
.login-box { width: 100%; max-width: 380px; background: var(--surface); border-radius: 20px; border: 1px solid var(--line); box-shadow: 0 14px 44px rgba(13, 35, 71, .2); padding: 26px 22px; }
.login-box .head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.login-box h1 { margin: 0; font-size: 19px; font-weight: 800; }
.login-box .sub { font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-top: 2px; }
.login-box form { display: flex; flex-direction: column; gap: 8px; }
.login-box label { font-weight: 700; font-size: 14px; color: var(--ink-2); margin-top: 6px; }
.login-box input {
    border: 1.5px solid var(--line-strong); border-radius: 12px; padding: 12px 14px; font-size: 16px; background: var(--surface-2);
}
.login-box input:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(20, 48, 92, .18); background: #fff; }
.login-box .msgline { color: var(--danger); font-weight: 700; min-height: 1.4em; font-size: 14px; }
.login-box .btn { padding: 13px; font-size: 16px; border-radius: 12px; }

/* ════════ 상담원 화면 ════════ */
body.agent .aapp { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.atop {
    display: flex; align-items: center; gap: 10px; background: var(--navy); color: #fff; position: relative; z-index: 3;
    padding: 8px 14px; padding-top: calc(8px + env(safe-area-inset-top)); box-shadow: 0 2px 12px rgba(0, 0, 0, .25);
}
.atop h1 { margin: 0; font-size: 17px; font-weight: 800; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.atop .me { font-weight: 700; font-size: 14px; white-space: nowrap; }
.statusbtn {
    display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
    background: rgba(255, 255, 255, .12); color: #fff; border: 1.5px solid rgba(255, 255, 255, .65); font-weight: 700; font-size: 14px;
}
.statusbtn:hover { background: rgba(255, 255, 255, .2); }
.abody { flex: 1; display: flex; min-height: 0; }
.side { width: clamp(230px, 36%, 340px); background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side .scroll { flex: 1; overflow-y: auto; padding-bottom: 10px; }
.sec {
    position: sticky; top: 0; z-index: 1; background: var(--surface); display: flex; align-items: center; gap: 6px;
    padding: 12px 16px 6px; font-size: 13.5px; font-weight: 800; color: var(--ink-2);
}
.cnt { min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px; background: var(--navy); color: #fff; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; }
.cnt.warn { background: var(--warn); }
.rooms { list-style: none; margin: 0; padding: 0 8px; }
.rooms li {
    display: flex; align-items: center; gap: 10px; padding: 10px; margin: 3px 0; border-radius: 14px; cursor: pointer;
    border: 1.5px solid transparent; transition: background .12s, border-color .12s;
}
.rooms li:hover { background: var(--surface-2); }
.rooms li.sel { background: var(--primary-soft); border-color: var(--primary); }
.rooms li.wait { border-color: var(--warn); background: var(--warn-soft); }
.rooms li.wait.sel { box-shadow: 0 0 0 2px var(--warn) inset; }
.ravatar { width: 44px; height: 44px; border-radius: 50%; color: #fff; font-weight: 800; font-size: 14px; display: flex; align-items: center; justify-content: center; flex: none; }
.rooms .info { flex: 1; min-width: 0; }
.rooms .l1 { display: flex; align-items: baseline; gap: 6px; }
.rooms .t { flex: 1; font-weight: 800; font-size: 15px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rooms .tm { font-size: 12px; font-weight: 600; color: var(--ink-3); white-space: nowrap; }
.rooms .l2 { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.rooms .p { flex: 1; font-size: 14px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--rose); color: #fff; font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.badge.warn { background: var(--warn); }
.rooms .empty { cursor: default; color: var(--ink-2); font-weight: 600; font-size: 14px; padding: 10px 8px; }
.rooms .empty:hover { background: transparent; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); position: relative; }
.mhead {
    display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--surface); position: relative; z-index: 1;
    border-bottom: 1px solid var(--line); box-shadow: 0 2px 8px rgba(13, 35, 71, .08); min-height: 58px;
}
.mhead .mt { flex: 1; min-width: 0; }
.mhead strong { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mhead .sub { font-size: 13px; font-weight: 700; color: var(--ink-2); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.back { background: transparent; color: var(--navy); display: none; }
.empty-main { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--ink-2); font-weight: 700; padding: 20px; text-align: center; }
.main.drag::after {
    content: "여기에 사진을 놓으면 보냅니다"; position: absolute; inset: 10px; z-index: 5; border-radius: 16px;
    border: 3px dashed var(--rose); background: rgba(253, 232, 238, .92); color: var(--primary-2);
    display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 800; pointer-events: none;
}

/* 폭 480 이상 = 무조건 두 칸, 480 미만 = 목록↔대화 전환 */
@media (max-width: 479.98px) {
    .side { width: 100%; border-right: 0; }
    .main { display: none; }
    body.show-room .side { display: none; }
    body.show-room .main { display: flex; }
    .back { display: inline-flex; }
    .atop .me { display: none; }
    .atop h1 { font-size: 16px; }
}
