/* ════════════════════════════════════════════════════════════════
   PropertyAI — Main Stylesheet
   ════════════════════════════════════════════════════════════════ */

/* ── CSS VARIABLES ── */
:root {
  --primary:   #1B6FD8;
  --primary-h: #1558B0;
  --primary-l: #E8F1FC;
  --accent:    #E8372A;
  --bg:        #F5F6FA;
  --bg2:       #FFFFFF;
  --text:      #1A1D23;
  --text2:     #4B5563;
  --muted:     #9CA3AF;
  --border:    #E5E7EB;
  --border2:   #D1D5DB;
  --success:   #059669;
  --success-l: #D1FAE5;
  --danger:    #DC2626;
  --danger-l:  #FEE2E2;
  --info:      #2563EB;
  --info-l:    #DBEAFE;
  --warn:      #D97706;
  --warn-l:    #FEF3C7;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow:    0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 32px rgba(0,0,0,0.1);
  --radius:    10px;
  --radius-sm: 6px;
}

/* ── RESET ── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.5;
}

/* ── AUTH ── */
#auth-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1.5rem;
  background: linear-gradient(135deg,#EBF2FF 0%,#F5F6FA 50%,#FFF3ED 100%);
}
.auth-box {
  width: 100%; max-width: 440px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg); animation: fadeUp .5s ease both;
}
.auth-header    { display: flex; align-items: center; gap: .75rem; margin-bottom: .4rem; }
.auth-logo      { font-family: 'Plus Jakarta Sans',sans-serif; font-size: 1.4rem; font-weight: 800; color: var(--text); letter-spacing: -.02em; }
.auth-logo span { color: var(--primary); }
.auth-sub       { font-size: .82rem; color: var(--muted); margin-bottom: 2rem; }
.tab-row        { display: flex; margin-bottom: 1.8rem; background: var(--bg); border-radius: var(--radius-sm); padding: 4px; }
.tab-btn        { flex: 1; padding: .55rem 0; background: none; border: none; cursor: pointer; font-family: 'Inter',sans-serif; font-size: .82rem; font-weight: 500; color: var(--muted); border-radius: 4px; transition: all .18s; }
.tab-btn.active { background: var(--bg2); color: var(--primary); font-weight: 600; box-shadow: var(--shadow-sm); }
.form-group     { margin-bottom: 1rem; }
label           { display: block; font-size: .78rem; font-weight: 500; color: var(--text2); margin-bottom: .4rem; }
input, textarea, select {
  width: 100%; padding: .65rem .9rem;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: 'Inter',sans-serif; font-size: .88rem;
  transition: border-color .18s, box-shadow .18s; outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27,111,216,.1);
  background: var(--bg2);
}
textarea { resize: vertical; min-height: 90px; }
.btn {
  width: 100%; padding: .75rem;
  background: var(--primary); border: none; border-radius: var(--radius-sm);
  color: white; font-family: 'Inter',sans-serif; font-size: .88rem; font-weight: 600;
  cursor: pointer; transition: background .18s, transform .1s, box-shadow .18s;
  box-shadow: 0 2px 8px rgba(27,111,216,.3);
}
.btn:hover    { background: var(--primary-h); box-shadow: 0 4px 12px rgba(27,111,216,.35); }
.btn:active   { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn-outline  { background: transparent; border: 1.5px solid var(--border2); color: var(--text2); box-shadow: none; }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-l); box-shadow: none; }

/* ── APP LAYOUT ── */
#app-screen { display: none; }
.layout     { display: flex; min-height: 100vh; }

/* ── TOPBAR ── */
.topbar            { position: fixed; top: 0; left: 0; right: 0; height: 60px; background: var(--bg2); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 1.5rem 0 0; z-index: 200; box-shadow: var(--shadow-sm); }
.topbar-logo       { width: 240px; flex-shrink: 0; display: flex; align-items: center; gap: .6rem; padding: 0 1.5rem; border-right: 1px solid var(--border); height: 100%; }
.topbar-brand      { font-family: 'Plus Jakarta Sans',sans-serif; font-size: 1rem; font-weight: 800; color: var(--text); letter-spacing: -.02em; }
.topbar-brand span { color: var(--primary); }
.topbar-center     { flex: 1; padding: 0 1.5rem; }
.topbar-search     { max-width: 400px; position: relative; }
.topbar-search input       { padding-left: 2.4rem; background: var(--bg); border-color: var(--border); border-radius: 20px; font-size: .82rem; height: 36px; }
.topbar-search-icon        { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .9rem; pointer-events: none; }
.topbar-right      { display: flex; align-items: center; gap: .75rem; }
.topbar-btn        { padding: .45rem 1rem; background: var(--primary); border: none; border-radius: 6px; color: white; font-size: .78rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: .4rem; transition: background .15s; font-family: 'Inter',sans-serif; }
.topbar-btn:hover  { background: var(--primary-h); }
.agent-pill        { display: flex; align-items: center; gap: .6rem; padding: .35rem .9rem .35rem .35rem; background: var(--bg); border: 1px solid var(--border); border-radius: 24px; cursor: pointer; }
.agent-avatar      { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; color: white; font-size: .72rem; font-weight: 700; flex-shrink: 0; }
.agent-pill-name   { font-size: .78rem; font-weight: 600; color: var(--text); line-height: 1.2; }
.agent-pill-email  { font-size: .68rem; color: var(--muted); line-height: 1.2; }

/* ── SIDEBAR ── */
.sidebar            { width: 240px; flex-shrink: 0; background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 60px; left: 0; bottom: 0; z-index: 100; overflow-y: auto; }
nav                 { flex: 1; padding: 1rem .75rem; }
.nav-section-label  { font-size: .65rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: 0 .75rem; margin: 1rem 0 .4rem; }
.nav-section-label:first-child { margin-top: 0; }
.nav-item           { display: flex; align-items: center; gap: .65rem; padding: .6rem .75rem; border-radius: var(--radius-sm); cursor: pointer; font-size: .84rem; font-weight: 500; color: var(--text2); transition: all .15s; margin-bottom: 2px; }
.nav-item:hover     { color: var(--text); background: var(--bg); }
.nav-item.active    { color: var(--primary); background: var(--primary-l); font-weight: 600; }
.nav-icon           { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }
.nav-badge          { margin-left: auto; background: var(--primary); color: white; font-size: .62rem; font-weight: 700; padding: 2px 7px; border-radius: 10px; min-width: 20px; text-align: center; }
.nav-badge.danger   { background: var(--danger); }
.sidebar-divider    { height: 1px; background: var(--border); margin: .75rem; }
.sidebar-footer     { padding: .75rem; border-top: 1px solid var(--border); }
.portal-link        { display: flex; align-items: center; gap: .65rem; padding: .6rem .75rem; border-radius: var(--radius-sm); font-size: .82rem; font-weight: 500; color: var(--success); background: var(--success-l); text-decoration: none; cursor: pointer; transition: all .15s; margin-bottom: .5rem; }
.portal-link:hover  { background: #A7F3D0; }

/* ── MAIN CONTENT ── */
.main         { margin-left: 240px; margin-top: 60px; flex: 1; padding: 2rem; min-height: calc(100vh - 60px); }
.page         { display: none; animation: fadeUp .3s ease both; }
.page.active  { display: block; }
.page-header  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-title   { font-family: 'Plus Jakarta Sans',sans-serif; font-size: 1.4rem; font-weight: 700; color: var(--text); letter-spacing: -.02em; }
.page-sub     { font-size: .8rem; color: var(--muted); margin-top: .2rem; }

/* ── CHAT ── */
.chat-layout        { display: grid; grid-template-columns: 1fr 340px; gap: 1.5rem; }
.chat-box           { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; height: 68vh; box-shadow: var(--shadow-sm); }
.chat-header        { padding: .9rem 1.2rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .6rem; }
.chat-header-dot    { width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: pulse 2s infinite; }
.chat-header-title  { font-size: .84rem; font-weight: 600; color: var(--text); }
.chat-messages      { flex: 1; overflow-y: auto; padding: 1.2rem; display: flex; flex-direction: column; gap: .9rem; }
.chat-messages::-webkit-scrollbar       { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
.msg            { display: flex; flex-direction: column; gap: .25rem; animation: fadeUp .25s ease both; }
.msg-bubble     { padding: .75rem 1rem; border-radius: var(--radius); font-size: .84rem; line-height: 1.6; max-width: 80%; }
.msg.user       { align-items: flex-end; }
.msg.user .msg-bubble { background: var(--primary); color: white; border-radius: 12px 12px 2px 12px; }
.msg.bot  .msg-bubble { background: var(--bg); border: 1px solid var(--border); border-radius: 2px 12px 12px 12px; color: var(--text); }
.msg-time       { font-size: .63rem; color: var(--muted); }
.result-card    { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; font-size: .8rem; max-width: 88%; }
.result-card .rc-tag { display: inline-flex; align-items: center; gap: .35rem; padding: 3px 10px; border-radius: 20px; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-bottom: .7rem; }
.tag-lead       { background: var(--success-l); color: var(--success); }
.tag-property   { background: var(--info-l); color: var(--info); }
.tag-junk       { background: var(--danger-l); color: var(--danger); }
.rc-row         { display: flex; gap: .5rem; margin-bottom: .3rem; align-items: flex-start; }
.rc-key         { color: var(--muted); min-width: 110px; font-size: .75rem; font-weight: 500; }
.rc-val         { color: var(--text); font-size: .75rem; }
.chat-input-area    { padding: .9rem 1.2rem; border-top: 1px solid var(--border); background: var(--bg); border-radius: 0 0 var(--radius) var(--radius); }
.chat-input-row     { display: flex; gap: .6rem; align-items: flex-end; }
.chat-input-row textarea { flex: 1; min-height: 52px; max-height: 130px; font-size: .84rem; border-radius: var(--radius-sm); }
.send-btn           { width: 46px; height: 46px; flex-shrink: 0; background: var(--primary); border: none; border-radius: var(--radius-sm); color: white; font-size: 1rem; cursor: pointer; transition: background .15s; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(27,111,216,.3); }
.send-btn:hover     { background: var(--primary-h); }
.send-btn:disabled  { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* ── CHAT MEDIA ALBUM ── */
.chat-media-album   { margin-top: .8rem; padding-top: .8rem; border-top: 1px solid var(--border); }
.chat-media-label   { font-size: .62rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .5rem; }
.chat-img-grid      { display: flex; flex-wrap: wrap; gap: .4rem; }
.chat-img-thumb     { width: 80px; height: 65px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; transition: transform .15s, box-shadow .15s; display: block; }
.chat-img-thumb:hover { transform: scale(1.07); box-shadow: var(--shadow); }
.chat-vid-btn       { display: flex; align-items: center; gap: .5rem; padding: .5rem .9rem; background: #1A1D23; color: #fff; border: none; border-radius: 8px; font-size: .75rem; font-weight: 600; cursor: pointer; transition: opacity .15s; margin-top: .4rem; }
.chat-vid-btn:hover { opacity: .78; }
.chat-vid-btn .play-icon { font-size: 1.1rem; }

/* ── UPLOAD PANEL ── */
.upload-panel   { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; height: fit-content; box-shadow: var(--shadow-sm); }
.panel-label    { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 1rem; }
.file-drop      { border: 1.5px dashed var(--border2); border-radius: var(--radius-sm); padding: 1.2rem; text-align: center; cursor: pointer; transition: border-color .18s, background .18s; margin-bottom: .75rem; background: var(--bg); }
.file-drop:hover         { border-color: var(--primary); background: var(--primary-l); }
.file-drop .fd-icon      { font-size: 1.6rem; margin-bottom: .4rem; }
.file-drop .fd-text      { font-size: .75rem; color: var(--muted); }
.file-drop .fd-name      { font-size: .72rem; color: var(--primary); margin-top: .25rem; font-weight: 500; }
.example-section { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* ── TABLES ── */
.data-table-wrap  { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.table-toolbar    { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); background: var(--bg); }
.table-toolbar h3 { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--text2); }
.refresh-btn      { padding: .4rem .9rem; background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius-sm); color: var(--text2); font-size: .75rem; font-weight: 500; cursor: pointer; font-family: 'Inter',sans-serif; transition: all .15s; display: inline-flex; align-items: center; gap: .3rem; }
.refresh-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-l); }
table             { width: 100%; border-collapse: collapse; }
thead th          { padding: .7rem 1rem; text-align: left; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); border-bottom: 1px solid var(--border); background: var(--bg); white-space: nowrap; }
tbody tr          { border-bottom: 1px solid var(--border); transition: background .12s; }
tbody tr:hover    { background: var(--bg); }
tbody tr:last-child { border-bottom: none; }
tbody td          { padding: .75rem 1rem; font-size: .82rem; color: var(--text); vertical-align: middle; }
.td-muted         { color: var(--muted); font-size: .75rem; }
.del-btn          { padding: .28rem .7rem; background: transparent; border: 1px solid rgba(220,38,38,.3); border-radius: var(--radius-sm); color: var(--danger); font-size: .72rem; font-weight: 500; cursor: pointer; font-family: 'Inter',sans-serif; transition: all .15s; }
.del-btn:hover    { background: var(--danger-l); border-color: var(--danger); }
.empty-state      { text-align: center; padding: 4rem 2rem; color: var(--muted); font-size: .84rem; }
.empty-state .es-icon { font-size: 2.5rem; margin-bottom: 1rem; opacity: .35; display: block; }
.badge            { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 20px; font-size: .68rem; font-weight: 600; }
.badge-lead       { background: var(--success-l); color: var(--success); }
.badge-prop       { background: var(--info-l); color: var(--info); }
.badge-junk       { background: var(--danger-l); color: var(--danger); }
.badge-inq        { background: var(--warn-l); color: var(--warn); }

/* ── TOAST ── */
#toast-container  { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast            { padding: .75rem 1.1rem; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); font-size: .8rem; color: var(--text); min-width: 260px; box-shadow: var(--shadow); animation: slideIn .3s ease both; display: flex; align-items: center; gap: .6rem; }
.toast.success    { border-left: 3px solid var(--success); }
.toast.error      { border-left: 3px solid var(--danger); }
.toast.info       { border-left: 3px solid var(--primary); }
.spinner          { display: inline-block; width: 15px; height: 15px; border: 2px solid var(--border2); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }

/* ── ANIMATIONS ── */
@keyframes fadeUp   { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn  { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes pulse    { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes bounce   { 0%,80%,100% { transform: translateY(0); } 40% { transform: translateY(-5px); } }
@keyframes popSlide { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes lbFade   { from { opacity: 0; } to { opacity: 1; } }
@keyframes lbPop    { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }
.typing-dots span   { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; margin: 0 2px; }
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
.ab-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--success); margin-right: 5px; animation: pulse 2s infinite; }

/* ── EDIT IMAGE MANAGER ── */
.img-manager        { margin-top: .6rem; }
.img-manager-label  { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text2); margin-bottom: .5rem; display: block; }
.img-manager-grid   { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: .6rem; min-height: 0; }
.img-mgr-item       { position: relative; width: 72px; height: 60px; border-radius: 7px; overflow: hidden; border: 1.5px solid var(--border); flex-shrink: 0; }
.img-mgr-item img   { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-mgr-item.new-img { border-color: var(--primary); border-style: dashed; }
.img-mgr-remove     { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; background: rgba(220,38,38,.85); border: none; color: #fff; font-size: .65rem; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; font-weight: 700; z-index: 2; transition: background .15s; }
.img-mgr-remove:hover { background: var(--danger); }
.img-mgr-add        { width: 72px; height: 60px; border: 1.5px dashed var(--border2); border-radius: 7px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; color: var(--muted); font-size: .62rem; gap: 2px; transition: border-color .15s, color .15s; flex-shrink: 0; }
.img-mgr-add:hover  { border-color: var(--primary); color: var(--primary); }
.img-mgr-add span   { font-size: 1.1rem; }
.img-count-note     { font-size: .68rem; color: var(--muted); margin-top: .3rem; }

/* ── EDIT BTN ── */
.edit-icon-btn        { padding: .28rem .6rem; background: transparent; border: 1px solid rgba(27,111,216,.3); border-radius: var(--radius-sm); color: var(--primary); font-size: .72rem; font-weight: 500; cursor: pointer; font-family: 'Inter',sans-serif; transition: all .15s; margin-right: .3rem; }
.edit-icon-btn:hover  { background: var(--primary-l); border-color: var(--primary); }

/* ── MEDIA CELLS ── */
.media-thumb        { width: 52px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); display: block; cursor: pointer; transition: transform .15s, box-shadow .15s; }
.media-thumb:hover  { transform: scale(1.1); box-shadow: var(--shadow); }
.media-empty        { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 40px; background: var(--bg); border: 1.5px dashed var(--border2); border-radius: 6px; color: var(--muted); font-size: .65rem; }
.vid-badge          { display: inline-flex; align-items: center; gap: .35rem; padding: 4px 10px; background: #1A1D23; color: #fff; border-radius: 6px; font-size: .72rem; font-weight: 600; cursor: pointer; white-space: nowrap; border: none; transition: opacity .15s; }
.vid-badge:hover    { opacity: .78; }

/* ── JUNK RED ROWS ── */
tr.junk-new         { background: rgba(220,38,38,.07) !important; border-left: 3px solid var(--danger); }
.junk-new-badge     { display: inline-block; background: var(--danger); color: #fff; font-size: .58rem; font-weight: 800; padding: 1px 6px; border-radius: 4px; margin-left: 6px; vertical-align: middle; text-transform: uppercase; }
.junk-popup         { position: fixed; top: 76px; right: 20px; z-index: 9999; background: var(--danger); color: #fff; border-radius: var(--radius); padding: 1rem 1.2rem; min-width: 300px; max-width: 380px; box-shadow: 0 8px 28px rgba(220,38,38,.45); animation: popSlide .4s cubic-bezier(.22,1,.36,1) both; cursor: pointer; }
.junk-popup-title   { font-size: .88rem; font-weight: 800; margin-bottom: .3rem; }
.junk-popup-reason  { font-size: .75rem; opacity: .9; margin-bottom: .4rem; }
.junk-popup-msg     { font-size: .72rem; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.junk-popup-close   { position: absolute; top: .5rem; right: .75rem; background: none; border: none; color: #fff; font-size: 1rem; cursor: pointer; opacity: .8; line-height: 1; }
.junk-popup-close:hover { opacity: 1; }

/* ── EDIT MODAL ── */
.modal-overlay        { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 8000; align-items: center; justify-content: center; padding: 1rem; }
.modal-overlay.open   { display: flex; animation: fadeUp .2s ease both; }
.modal-box            { background: var(--bg2); border-radius: var(--radius); width: 100%; max-width: 520px; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-head           { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.4rem; border-bottom: 1px solid var(--border); background: var(--bg); }
.modal-head-title     { font-size: .95rem; font-weight: 700; color: var(--text); font-family: 'Plus Jakarta Sans',sans-serif; }
.modal-close-btn      { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--muted); padding: .2rem; line-height: 1; transition: color .15s; }
.modal-close-btn:hover { color: var(--danger); }
.modal-body           { padding: 1.4rem; }
.modal-form-row       { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.modal-footer         { display: flex; gap: .6rem; justify-content: flex-end; padding: 1rem 1.4rem; border-top: 1px solid var(--border); background: var(--bg); }
.save-btn             { padding: .6rem 1.4rem; background: var(--primary); color: white; border: none; border-radius: var(--radius-sm); font-size: .82rem; font-weight: 600; cursor: pointer; font-family: 'Inter',sans-serif; transition: background .15s; }
.save-btn:hover       { background: var(--primary-h); }
.save-btn:disabled    { opacity: .5; cursor: not-allowed; }
.cancel-btn           { padding: .6rem 1.2rem; background: transparent; color: var(--text2); border: 1px solid var(--border2); border-radius: var(--radius-sm); font-size: .82rem; font-weight: 500; cursor: pointer; font-family: 'Inter',sans-serif; transition: all .15s; }
.cancel-btn:hover     { border-color: var(--danger); color: var(--danger); }

/* ── LIGHTBOX ── */
#lightbox     { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 10000; align-items: center; justify-content: center; padding: 1.5rem; cursor: pointer; }
#lightbox.open { display: flex; animation: lbFade .2s ease both; }
#lb-inner     { position: relative; max-width: 900px; width: 100%; background: #000; border-radius: 12px; overflow: hidden; cursor: default; animation: lbPop .22s ease both; box-shadow: 0 24px 60px rgba(0,0,0,.7); }
#lb-img       { width: 100%; max-height: 82vh; object-fit: contain; display: block; }
#lb-vid       { width: 100%; max-height: 82vh; display: block; outline: none; background: #000; }
#lb-close     { position: absolute; top: .7rem; right: .8rem; background: rgba(0,0,0,.6); border: none; color: #fff; width: 32px; height: 32px; border-radius: 50%; font-size: 1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 2; transition: background .15s; line-height: 1; }
#lb-close:hover { background: var(--danger); }

/* ── GPS LOCATION ── */
.gps-pin-btn {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .45rem .9rem;
  background: var(--bg2); border: 1.5px solid var(--border2);
  border-radius: var(--radius-sm); color: var(--text2);
  font-size: .78rem; font-weight: 500; cursor: pointer;
  font-family: 'Inter',sans-serif; transition: all .15s;
  white-space: nowrap;
}
.gps-pin-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-l); }
.gps-badge-wrap {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem .75rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .75rem; min-height: 30px; flex: 1;
}
.gps-map-link {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: 2px 8px; background: var(--primary-l);
  color: var(--primary); border-radius: 4px;
  font-size: .68rem; font-weight: 600; text-decoration: none;
  white-space: nowrap;
}
.gps-map-link:hover { background: var(--primary); color: #fff; }

/* ── GPS LOCATION DETAIL BUTTON (in table) ── */
.gps-location-btn {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: 3px 9px;
  background: var(--primary-l); border: 1px solid rgba(27,111,216,.2);
  border-radius: 6px; color: var(--primary);
  font-size: .72rem; font-weight: 600; cursor: pointer;
  font-family: 'Inter',sans-serif; transition: all .15s;
  max-width: 130px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.gps-location-btn:hover {
  background: var(--primary); color: #fff;
}
.gps-location-btn span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}


/* ════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile & Tablet
   Breakpoints:
     ≤ 768px  → mobile
     769–1024px → tablet
   ════════════════════════════════════════════════════════════════ */

/* ── Hamburger Button (hidden on desktop) ── */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 38px; height: 38px;
  background: none; border: none; cursor: pointer;
  padding: 4px; border-radius: 6px;
  flex-shrink: 0;
}
.hamburger span {
  display: block; width: 22px; height: 2.5px;
  background: var(--text2); border-radius: 2px;
  transition: all .25s ease;
}
.hamburger.open span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.open span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

/* ── Sidebar Overlay (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* ══════════════════════════════
   TABLET  (769px – 1024px)
══════════════════════════════ */
@media (max-width: 1024px) {
  .topbar-center { display: none; }
  .topbar-logo   { width: 200px; }
  .sidebar       { width: 200px; }
  .main          { margin-left: 200px; }

  .chat-layout   { grid-template-columns: 1fr; }
  .upload-panel  { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
  .example-section { grid-column: 1 / -1; }
  .chat-box      { height: 55vh; }

  .modal-box     { max-width: 95vw; }
}

/* ══════════════════════════════
   MOBILE  (≤ 768px)
══════════════════════════════ */
@media (max-width: 768px) {

  /* ── Topbar ── */
  .topbar {
    padding: 0 .9rem;
    height: 56px;
  }
  .topbar-logo {
    width: auto;
    border-right: none;
    padding: 0;
    flex: 1;
  }
  .topbar-brand { font-size: .9rem; }
  .topbar-center { display: none; }
  .topbar-right  { gap: .4rem; }
  .topbar-btn    { display: none; }
  .agent-pill    { padding: .3rem .6rem .3rem .3rem; }
  .agent-pill-email { display: none; }
  .agent-pill-name  { font-size: .72rem; }
  .agent-avatar     { width: 26px; height: 26px; font-size: .65rem; }
  .hamburger        { display: flex; }

  /* ── Sidebar — slide in from left ── */
  .sidebar {
    width: 260px;
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    z-index: 100;
    top: 56px;
    box-shadow: 4px 0 20px rgba(0,0,0,.12);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  /* ── Main content — full width on mobile ── */
  .main {
    margin-left: 0;
    margin-top: 56px;
    padding: 1rem .75rem;
  }

  /* ── Page header ── */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: .6rem;
    margin-bottom: 1rem;
  }
  .page-title { font-size: 1.15rem; }
  .page-sub   { font-size: .74rem; }
  .page-header .refresh-btn { align-self: flex-start; }

  /* ── Chat layout — stacked ── */
  .chat-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .chat-box { height: 52vh; }
  .chat-messages { padding: .85rem; gap: .7rem; }
  .msg-bubble { font-size: .8rem; max-width: 92%; }
  .result-card { max-width: 96%; }

  /* ── Upload panel — stacked ── */
  .upload-panel {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    padding: 1rem;
  }
  .file-drop { padding: .9rem; margin-bottom: 0; }
  .file-drop .fd-icon { font-size: 1.3rem; }

  /* ── Chat input ── */
  .chat-input-area  { padding: .75rem; }
  .chat-input-row textarea { min-height: 44px; font-size: .8rem; }
  .send-btn { width: 42px; height: 42px; font-size: .9rem; }

  /* ── Tables — horizontal scroll ── */
  .data-table-wrap { border-radius: var(--radius); overflow: hidden; }
  .table-toolbar   { padding: .75rem 1rem; flex-wrap: wrap; gap: .5rem; }
  .table-toolbar h3 { font-size: .72rem; }

  /* Wrap table in scrollable container */
  #leads-table-body,
  #props-table-body,
  #junk-table-body,
  #inq-table-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  #leads-table-body table,
  #props-table-body table,
  #junk-table-body  table,
  #inq-table-body   table {
    min-width: 600px;
  }
  thead th { font-size: .65rem; padding: .6rem .75rem; }
  tbody td  { font-size: .78rem; padding: .6rem .75rem; }

  /* ── Edit Modal ── */
  .modal-overlay { padding: .5rem; align-items: flex-end; }
  .modal-box {
    max-width: 100%;
    border-radius: 14px 14px 0 0;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
  }
  .modal-body {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
  }
  .modal-head   { padding: .85rem 1rem; }
  .modal-footer { padding: .85rem 1rem; }
  .modal-form-row { grid-template-columns: 1fr; gap: 0; }
  .save-btn, .cancel-btn { padding: .6rem 1rem; font-size: .8rem; }

  /* ── Auth ── */
  .auth-box { padding: 1.75rem 1.25rem; border-radius: 12px; }
  .auth-logo { font-size: 1.2rem; }

  /* ── Register grid ── */
  #register-form [style*="grid-template-columns:1fr 1fr"] {
    display: flex !important;
    flex-direction: column;
  }

  /* ── Badges & buttons in tables ── */
  .del-btn, .edit-icon-btn { padding: .22rem .5rem; font-size: .68rem; }
  .badge { font-size: .62rem; padding: 1px 7px; }
  .media-thumb { width: 42px; height: 34px; }
  .vid-badge { font-size: .65rem; padding: 3px 7px; }

  /* ── Toast ── */
  #toast-container {
    bottom: 1rem; right: .75rem; left: .75rem;
  }
  .toast { min-width: unset; width: 100%; font-size: .78rem; }

  /* ── GPS modal ── */
  #gps-backdrop > div { border-radius: 12px 12px 0 0 !important; max-width: 100% !important; }
  #gps-map { height: 240px !important; }

  /* ── Location detail modal ── */
  #loc-detail-backdrop > div { border-radius: 12px 12px 0 0 !important; max-width: 100% !important; }

  /* ── Lightbox ── */
  #lb-inner { border-radius: 8px; }
  #lb-img   { max-height: 75vh; }
  #lb-vid   { max-height: 75vh; }

  /* ── Image manager in edit modal ── */
  .img-mgr-item, .img-mgr-add { width: 64px; height: 54px; }

  /* ── Chat media album ── */
  .chat-img-thumb { width: 68px; height: 55px; }

  /* ── Bottom nav (mobile tab bar) ── */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    z-index: 150;
    height: 58px;
  }
  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    font-size: .56rem;
    font-weight: 600;
    color: var(--muted);
    transition: color .15s;
    border: none;
    background: none;
    font-family: 'Inter', sans-serif;
    position: relative;
  }
  .mobile-nav-item .mn-icon { font-size: 1.15rem; line-height: 1; }
  .mobile-nav-item.active   { color: var(--primary); }
  .mobile-nav-item .mn-badge {
    position: absolute;
    top: 6px; right: calc(50% - 14px);
    background: var(--danger); color: #fff;
    font-size: .5rem; font-weight: 800;
    padding: 1px 4px; border-radius: 8px;
    min-width: 14px; text-align: center;
    line-height: 1.4;
  }
  /* Push main content above bottom nav */
  .main { padding-bottom: 70px; }
}

/* ══════════════════════════════
   VERY SMALL  (≤ 360px)
══════════════════════════════ */
@media (max-width: 360px) {
  .main { padding: .75rem .5rem; padding-bottom: 70px; }
  .page-title { font-size: 1rem; }
  .chat-box   { height: 48vh; }
  .topbar     { padding: 0 .6rem; }
  .agent-pill { display: none; }
}
.img-mgr-item img:hover {
  transform: scale(1.05);
  transition: transform 0.2s;
  filter: brightness(1.1);
}