/* ═══════════════════════════════════════════
   #CHAT — style.css  (v2 — mobile first)
═══════════════════════════════════════════ */
:root {
  --green-50:  #f0faf4;
  --green-100: #d8f3e3;
  --green-200: #b3e6c8;
  --green-300: #7dd3a8;
  --green-400: #4abe84;
  --accent:    #3cbf79;
  --accent-dk: #1e8f52;

  --bg:      #f5fcf7;
  --surface: #ffffff;
  --surface2:#f0faf4;
  --border:  #d0eddb;

  --text-1:  #1a2e22;
  --text-2:  #4a6858;
  --text-3:  #88a895;

  --red:       #e05252;
  --red-light: #fdeaea;

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 32px;

  --shadow-sm: 0 2px 8px rgba(45,168,102,0.08);
  --shadow-md: 0 8px 32px rgba(45,168,102,0.13);
  --shadow-lg: 0 20px 60px rgba(45,168,102,0.18);

  --font: 'Nunito', sans-serif;
  --mono: 'Space Mono', monospace;

  --sidebar-w: 68px;
  --panel-w:   320px;
  --nav-h:     60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: var(--font); background: var(--bg); color: var(--text-1); font-size: 15px; overflow: hidden; }

/* ══════════════════════════
   AUTH
══════════════════════════ */
.screen { display: none; width: 100vw; height: 100vh; }
.screen.active { display: flex; }

#auth-screen {
  align-items: center; justify-content: center;
  background: var(--green-50);
  position: relative; overflow: hidden;
}
.auth-bg { position: absolute; inset: 0; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.3; }
.b1 { width: 420px; height: 420px; background: var(--green-300); top:-100px; left:-80px; animation: drift 9s ease-in-out infinite alternate; }
.b2 { width: 340px; height: 340px; background: var(--green-200); bottom:-60px; right:-40px; animation: drift 11s ease-in-out infinite alternate-reverse; }
.b3 { width: 260px; height: 260px; background: var(--green-400); top:50%; left:55%; animation: drift 7s ease-in-out infinite alternate; }
@keyframes drift { from { transform: translate(0,0); } to { transform: translate(25px,30px); } }

.auth-card {
  position: relative; z-index: 1;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-xl);
  padding: 36px 28px 28px;
  width: 100%; max-width: 390px;
  margin: 16px;
  box-shadow: var(--shadow-lg);
}
.logo { font-family: var(--mono); font-size: 2.2rem; color: var(--accent); text-align: center; margin-bottom: 4px; }
.tagline { text-align: center; color: var(--text-3); font-size: 0.82rem; margin-bottom: 24px; }

.tab-bar { display: flex; gap: 5px; background: var(--green-50); border-radius: var(--r-md); padding: 4px; margin-bottom: 20px; }
.tab-btn { flex: 1; padding: 9px 0; border: none; border-radius: var(--r-sm); background: transparent; color: var(--text-2); font-family: var(--font); font-size: 0.88rem; font-weight: 700; cursor: pointer; transition: all 0.2s; }
.tab-btn.active { background: var(--surface); color: var(--accent-dk); box-shadow: var(--shadow-sm); }
.tab-btn:not(.active):hover { background: var(--green-100); }

.form-panel { display: none; flex-direction: column; gap: 10px; }
.form-panel.active { display: flex; }

.input-group { display: flex; align-items: center; gap: 9px; background: var(--green-50); border: 1.5px solid var(--border); border-radius: var(--r-sm); padding: 0 13px; transition: border-color 0.2s, box-shadow 0.2s; }
.input-group:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(60,191,121,0.12); }
.ig-icon { font-size: 0.95rem; flex-shrink: 0; opacity: 0.65; }
.input-group input { flex: 1; border: none; background: transparent; padding: 12px 0; font-family: var(--font); font-size: 0.88rem; color: var(--text-1); outline: none; min-width: 0; }
.input-group input::placeholder { color: var(--text-3); }

.btn-primary { width: 100%; padding: 13px; border: none; border-radius: var(--r-sm); background: var(--accent); color: #fff; font-family: var(--font); font-size: 0.92rem; font-weight: 800; cursor: pointer; transition: background 0.2s, transform 0.1s; box-shadow: 0 4px 14px rgba(60,191,121,0.28); margin-top: 2px; }
.btn-primary:hover { background: var(--accent-dk); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary.sm { padding: 10px; font-size: 0.85rem; }

.btn-secondary { width: 100%; padding: 11px; border: 1.5px solid var(--border); border-radius: var(--r-sm); background: transparent; color: var(--text-2); font-family: var(--font); font-size: 0.88rem; font-weight: 700; cursor: pointer; transition: all 0.2s; }
.btn-secondary:hover { background: var(--green-50); border-color: var(--accent); color: var(--accent-dk); }
.btn-secondary.sm { padding: 9px; font-size: 0.83rem; }

.form-error { font-size: 0.8rem; color: var(--red); min-height: 16px; text-align: center; }
.form-error.success { color: var(--accent-dk); }

.avatar-upload-wrap { display: flex; flex-direction: column; align-items: center; gap: 5px; margin-bottom: 2px; }
.avatar-label { cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.avatar-preview { width: 68px; height: 68px; border-radius: 50%; background: var(--green-100); border: 2px dashed var(--green-300); display: flex; align-items: center; justify-content: center; overflow: hidden; transition: border-color 0.2s; }
.avatar-preview:hover { border-color: var(--accent); }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.av-plus { font-size: 1.5rem; color: var(--green-400); }
.av-hint { font-size: 0.75rem; color: var(--text-3); }

/* ══════════════════════════
   APP LAYOUT
══════════════════════════ */
#app-screen { flex-direction: row; position: relative; }

/* SIDEBAR — desktop only */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-right: 1.5px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 0 12px;
  height: 100vh; gap: 4px;
}
.sidebar-logo { font-family: var(--mono); font-size: 0.7rem; color: var(--accent); text-align: center; margin-bottom: 12px; font-weight: 700; }
.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; align-items: center; }
.side-btn { width: 44px; height: 44px; border: none; border-radius: var(--r-md); background: transparent; font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.15s; position: relative; }
.side-btn:hover { background: var(--green-50); }
.side-btn.active { background: var(--green-100); }
.side-btn.danger { color: var(--red); }
.side-btn.danger:hover { background: var(--red-light); }
.side-bottom { display: flex; flex-direction: column; align-items: center; gap: 6px; }

/* PANEL AREA */
.panel-area {
  width: var(--panel-w); flex-shrink: 0;
  border-right: 1.5px solid var(--border);
  height: 100vh; overflow: hidden;
  position: relative;
  background: var(--surface);
}
.panel { display: none; flex-direction: column; height: 100%; }
.panel.active { display: flex; }

.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 12px; border-bottom: 1.5px solid var(--border); flex-shrink: 0; }
.panel-title { font-size: 1.1rem; font-weight: 900; }
.header-actions { display: flex; gap: 6px; }

.scroll-list { flex: 1; overflow-y: auto; }
.scroll-list::-webkit-scrollbar { width: 3px; }
.scroll-list::-webkit-scrollbar-thumb { background: var(--green-200); border-radius: 3px; }

/* BOTTOM NAV — mobile only */
.bottom-nav { display: none; }

/* CHAT VIEW */
.chat-view {
  flex: 1; display: flex; flex-direction: column;
  height: 100vh; background: var(--bg);
  position: relative;
}
.chat-header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--surface); border-bottom: 1.5px solid var(--border); box-shadow: var(--shadow-sm); flex-shrink: 0; }
.back-btn { display: none; width: 36px; height: 36px; border: none; border-radius: var(--r-sm); background: var(--green-50); font-size: 1.1rem; cursor: pointer; flex-shrink: 0; transition: background 0.15s; }
.back-btn:hover { background: var(--green-100); }
.chat-partner-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.chat-partner-name { font-weight: 800; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-partner-sub { font-size: 0.75rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* GROUP MEMBERS PANEL */
.group-members-panel { background: var(--green-50); border-bottom: 1.5px solid var(--border); max-height: 200px; overflow-y: auto; flex-shrink: 0; }
.group-member-row { display: flex; align-items: center; gap: 10px; padding: 8px 16px; }
.group-member-row .info { flex: 1; font-size: 0.85rem; font-weight: 700; }

/* MESSAGES */
.messages-wrap { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; }
.messages-wrap::-webkit-scrollbar { width: 3px; }
.messages-wrap::-webkit-scrollbar-thumb { background: var(--green-200); border-radius: 3px; }
.messages-list { display: flex; flex-direction: column; gap: 4px; margin-top: auto; }

.msg-row { display: flex; align-items: flex-end; gap: 6px; max-width: 75%; animation: msgIn 0.18s ease; }
@keyframes msgIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }
.msg-row.me { align-self: flex-end; flex-direction: row-reverse; }
.msg-row.them { align-self: flex-start; }

.bubble { padding: 9px 13px; border-radius: 18px; font-size: 0.88rem; line-height: 1.5; word-break: break-word; }
.msg-row.me .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg-row.them .bubble { background: var(--surface); border: 1.5px solid var(--border); color: var(--text-1); border-bottom-left-radius: 4px; }
.msg-sender { font-size: 0.7rem; color: var(--text-3); margin-bottom: 2px; font-weight: 700; }
.msg-time { font-size: 0.65rem; color: var(--text-3); margin-bottom: 2px; white-space: nowrap; }
.msg-row.me .msg-time { text-align: right; }

.msg-date-divider { text-align: center; font-size: 0.72rem; color: var(--text-3); margin: 10px 0 4px; position: relative; }
.msg-date-divider::before, .msg-date-divider::after { content:''; position:absolute; top:50%; width:32%; height:1px; background:var(--border); }
.msg-date-divider::before { left:0; } .msg-date-divider::after { right:0; }

.message-input-bar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; background: var(--surface); border-top: 1.5px solid var(--border); flex-shrink: 0; }
.message-input-bar input { flex: 1; border: 1.5px solid var(--border); border-radius: var(--r-md); padding: 11px 15px; font-family: var(--font); font-size: 0.88rem; background: var(--green-50); outline: none; color: var(--text-1); min-width: 0; transition: border-color 0.2s; }
.message-input-bar input:focus { border-color: var(--accent); background: var(--surface); }
.send-btn { width: 42px; height: 42px; border: none; border-radius: 50%; background: var(--accent); color: #fff; font-size: 1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.2s, transform 0.1s; box-shadow: 0 3px 12px rgba(60,191,121,0.3); flex-shrink: 0; }
.send-btn:hover { background: var(--accent-dk); }
.send-btn:active { transform: scale(0.92); }

/* CHAT LIST ITEMS */
.chat-item { display: flex; align-items: center; gap: 11px; padding: 11px 14px; cursor: pointer; transition: background 0.15s; border-bottom: 1px solid var(--green-50); }
.chat-item:hover { background: var(--green-50); }
.chat-item.active { background: var(--green-100); }
.chat-item .info { flex: 1; overflow: hidden; }
.chat-item .ci-name { font-weight: 700; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .ci-preview { font-size: 0.75rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-badge { background: var(--accent); color: #fff; font-size: 0.68rem; font-weight: 800; border-radius: 99px; padding: 2px 7px; min-width: 18px; text-align: center; flex-shrink: 0; }

/* FRIEND ITEMS */
.friend-section { border-bottom: 1.5px solid var(--border); padding-bottom: 4px; }
.section-label { padding: 12px 16px 6px; font-size: 0.7rem; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-3); }
.friend-item { display: flex; align-items: center; gap: 11px; padding: 10px 14px; transition: background 0.15s; border-bottom: 1px solid var(--green-50); }
.friend-item:hover { background: var(--green-50); }
.friend-item .info { flex: 1; overflow: hidden; }
.friend-item .fi-name { font-weight: 700; font-size: 0.88rem; }
.friend-item .fi-email { font-size: 0.74rem; color: var(--text-3); }
.friend-item .actions { display: flex; gap: 5px; flex-shrink: 0; }

/* SEARCH RESULTS */
.search-input-wrap { display: flex; align-items: center; gap: 9px; margin: 12px 14px; background: var(--green-50); border: 1.5px solid var(--border); border-radius: var(--r-sm); padding: 0 13px; transition: border-color 0.2s; }
.search-input-wrap:focus-within { border-color: var(--accent); }
.search-icon { color: var(--text-3); }
.search-input-wrap input { flex: 1; border: none; background: transparent; padding: 11px 0; font-family: var(--font); font-size: 0.88rem; color: var(--text-1); outline: none; }

.search-result-item { display: flex; align-items: center; gap: 11px; padding: 10px 14px; cursor: pointer; transition: background 0.15s; border-bottom: 1px solid var(--green-50); }
.search-result-item:hover { background: var(--green-50); }
.search-result-item .info { flex: 1; overflow: hidden; }
.search-result-item .sri-name { font-weight: 700; font-size: 0.88rem; }
.search-result-item .sri-email { font-size: 0.74rem; color: var(--text-3); }

/* MYPAGE */
.mypage-content { flex: 1; overflow-y: auto; padding: 0 0 20px; }
.mypage-content::-webkit-scrollbar { width: 3px; }
.mypage-content::-webkit-scrollbar-thumb { background: var(--green-200); border-radius: 3px; }

.profile-card { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 28px 20px 20px; border-bottom: 1.5px solid var(--border); }
.profile-avatar-wrap { position: relative; }
.avatar-edit-btn { position: absolute; bottom: 0; right: 0; width: 26px; height: 26px; background: var(--accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; cursor: pointer; box-shadow: var(--shadow-sm); }
.profile-info { text-align: center; }
.profile-name { font-size: 1.15rem; font-weight: 900; }
.profile-email { font-size: 0.8rem; color: var(--text-3); margin-top: 2px; }

.mypage-section { padding: 16px 16px 8px; border-bottom: 1px solid var(--green-50); display: flex; flex-direction: column; gap: 8px; }

/* AVATARS */
.avatar { border-radius: 50%; background: var(--green-200); overflow: hidden; display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--accent-dk); flex-shrink: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.xs { width: 26px; height: 26px; font-size: 0.65rem; }
.avatar.sm { width: 38px; height: 38px; font-size: 0.88rem; }
.avatar.md { width: 48px; height: 48px; font-size: 1.1rem; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.4rem; }
.avatar.xl { width: 84px; height: 84px; font-size: 1.8rem; }

/* ICON BUTTONS */
.icon-btn { width: 34px; height: 34px; border: none; border-radius: var(--r-sm); background: var(--green-50); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 0.95rem; transition: background 0.15s; flex-shrink: 0; }
.icon-btn:hover { background: var(--green-100); }
.icon-btn.danger { background: var(--red-light); }
.icon-btn.danger:hover { background: #fad4d4; }
.icon-btn.danger-light { background: transparent; opacity: 0.7; }
.icon-btn.danger-light:hover { opacity: 1; background: var(--red-light); }

/* SMALL BUTTONS */
.btn-sm { padding: 5px 11px; border: 1.5px solid var(--border); border-radius: var(--r-sm); background: var(--surface); font-family: var(--font); font-size: 0.76rem; font-weight: 700; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.btn-sm:hover { background: var(--green-100); border-color: var(--accent); }
.btn-sm.danger { border-color: var(--red); color: var(--red); }
.btn-sm.danger:hover { background: var(--red-light); }
.btn-sm.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-sm.primary:hover { background: var(--accent-dk); }

/* FRIEND SELECT (group modal) */
.friend-select-list { max-height: 200px; overflow-y: auto; border: 1.5px solid var(--border); border-radius: var(--r-sm); background: var(--green-50); }
.friend-select-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; transition: background 0.15s; }
.friend-select-item:hover { background: var(--green-100); }
.friend-select-item input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.friend-select-item .name { font-size: 0.88rem; font-weight: 700; }

/* MODALS */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.22); display: flex; align-items: center; justify-content: center; z-index: 1000; backdrop-filter: blur(4px); padding: 16px; }
.modal-card { background: var(--surface); border-radius: var(--r-xl); padding: 32px 24px 24px; width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); position: relative; max-height: 90vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.modal-card.wide { max-width: 680px; }
.modal-title { font-size: 1.1rem; font-weight: 900; }
.modal-close { position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border: none; border-radius: 50%; background: var(--green-50); cursor: pointer; font-size: 0.85rem; transition: background 0.2s; }
.modal-close:hover { background: var(--green-100); }
.modal-select { width: 100%; border: 1.5px solid var(--border); border-radius: var(--r-sm); padding: 10px 12px; font-family: var(--font); font-size: 0.87rem; background: var(--green-50); color: var(--text-1); outline: none; }
.modal-select:focus { border-color: var(--accent); }
.modal-textarea { width: 100%; border: 1.5px solid var(--border); border-radius: var(--r-sm); padding: 10px 12px; font-family: var(--font); font-size: 0.87rem; background: var(--green-50); color: var(--text-1); outline: none; resize: vertical; min-height: 72px; }
.modal-textarea:focus { border-color: var(--accent); }
.modal-input { width: 100%; border: 1.5px solid var(--border); border-radius: var(--r-sm); padding: 10px 12px; font-family: var(--font); font-size: 0.87rem; background: var(--green-50); color: var(--text-1); outline: none; }
.modal-input:focus { border-color: var(--accent); }

/* ADMIN */
.admin-section { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.admin-section.hidden { display: none; }
.admin-user-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: var(--r-sm); background: var(--green-50); }
.admin-user-row .info { flex: 1; }
.admin-user-row .info .name { font-weight: 700; font-size: 0.88rem; }
.admin-user-row .info .email { font-size: 0.75rem; color: var(--text-3); }
.admin-user-row .actions { display: flex; gap: 5px; }
.report-row { border: 1.5px solid var(--border); border-radius: var(--r-sm); padding: 9px 12px; background: var(--green-50); }
.report-row .meta { font-size: 0.74rem; color: var(--text-3); margin-bottom: 3px; }
.report-row .reason { font-weight: 700; font-size: 0.86rem; }
.report-row .detail { font-size: 0.8rem; color: var(--text-2); margin-top: 2px; }
.admin-chat-partner { padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--r-sm); cursor: pointer; font-size: 0.85rem; transition: background 0.15s; }
.admin-chat-partner:hover { background: var(--green-100); }
.admin-chat-partner.active { background: var(--green-100); border-color: var(--accent); font-weight: 700; }

/* MINI INPUT */
.mini-input { width: 100%; border: 1.5px solid var(--border); border-radius: var(--r-sm); padding: 8px 11px; font-family: var(--font); font-size: 0.83rem; background: var(--surface); outline: none; }
.mini-input:focus { border-color: var(--accent); }

/* ADMIN BTN */
.btn-admin { width: 44px; height: 44px; border: none; border-radius: var(--r-md); background: var(--green-50); font-size: 1.1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.15s; }
.btn-admin:hover { background: var(--green-100); }

/* TOAST */
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--text-1); color: #fff; padding: 10px 20px; border-radius: 99px; font-size: 0.85rem; font-weight: 700; z-index: 9999; pointer-events: none; opacity: 0; transition: opacity 0.3s; white-space: nowrap; }
.toast.show { opacity: 1; }

/* UTILS */
.hidden { display: none !important; }
hr.divider { border: none; border-top: 1.5px solid var(--border); }

/* ══════════════════════════
   MOBILE (≤ 768px)
══════════════════════════ */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .panel-area { width: 100vw; border-right: none; }
  .chat-view { display: none; position: fixed; inset: 0; z-index: 200; top: 0; bottom: 0; }
  .chat-view.open { display: flex; }
  .back-btn { display: flex; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-h); background: var(--surface); border-top: 1.5px solid var(--border); z-index: 100; box-shadow: 0 -4px 16px rgba(0,0,0,0.06); }
  .nav-btn { flex: 1; border: none; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; color: var(--text-3); transition: color 0.15s; }
  .nav-btn.active { color: var(--accent); }
  .nav-icon { font-size: 1.3rem; }
  .nav-label { font-size: 0.62rem; font-weight: 700; font-family: var(--font); }
  .panel-area { height: calc(100vh - var(--nav-h)); }
  .panel { height: calc(100vh - var(--nav-h)); }
  .toast { bottom: calc(var(--nav-h) + 12px); }
  .msg-row { max-width: 85%; }
}

/* ══════════════════════════
   DESKTOP (> 768px)
══════════════════════════ */
@media (min-width: 769px) {
  .chat-view { display: flex; }
  /* empty state when no chat selected */
  .chat-view.empty-mode { align-items: center; justify-content: center; }
  .chat-view.empty-mode .chat-header,
  .chat-view.empty-mode .messages-wrap,
  .chat-view.empty-mode .message-input-bar,
  .chat-view.empty-mode .group-members-panel { display: none; }
  .chat-view.empty-mode::after { content: '#CHAT'; font-family: var(--mono); font-size: 4rem; font-weight: 700; color: var(--green-200); letter-spacing: -3px; }
}
