/* ChatLoca Company PWA — CSS v2 */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700&display=swap');
:root { --blue: #2E7CC9; --red: #E02020; --gold: #F5C518; --bg: #F7F8FA; --white: #FFFFFF; --text: #1A1A2E; --text-2: #4A4A68; --text-3: #8E8EA0; --border: #E8E8EF; --green: #22C55E; --radius: 16px; --radius-sm: 10px; }
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Sora', sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; overflow: hidden; height: 100dvh; }
#app { height: 100dvh; display: flex; flex-direction: column; }
.screen { height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
.center-screen { justify-content: center; align-items: center; padding: 32px; text-align: center; }

/* Topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--white); border-bottom: 1px solid var(--border); flex-shrink: 0; padding-top: max(12px, env(safe-area-inset-top)); }
.topbar-title { font-size: 1.1rem; font-weight: 700; }
.icon-btn { background: none; border: none; font-size: 1.3rem; cursor: pointer; padding: 6px; }
.back-btn { background: none; border: none; font-size: 1.4rem; cursor: pointer; padding: 6px 12px 6px 0; }
.abs-back { position: absolute; top: 16px; left: 16px; }

/* Bottombar */
.bottombar { display: flex; background: var(--white); border-top: 1px solid var(--border); flex-shrink: 0; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; border: none; background: none; font-size: .65rem; color: var(--text-3); cursor: pointer; font-family: inherit; }
.tab.active { color: var(--blue); }

/* Forms */
.form-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 12px; }
.form-card input, .form-card textarea, .form-card select { padding: 13px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: .9rem; font-family: inherit; background: var(--white); }
.form-card input:focus, .form-card textarea:focus { outline: none; border-color: var(--blue); }
.form-card textarea { resize: vertical; }
.form-content { flex: 1; overflow-y: auto; padding: 20px 16px; display: flex; flex-direction: column; align-items: center; }
.file-upload { padding: 14px 16px; border-radius: var(--radius-sm); border: 1px dashed var(--border); cursor: pointer; color: var(--text-3); font-size: .85rem; text-align: center; }

/* Buttons */
.btn-primary { padding: 14px 24px; background: var(--blue); color: white; border: none; border-radius: var(--radius-sm); font-size: .95rem; font-weight: 600; cursor: pointer; font-family: inherit; }
.btn-primary:active { transform: scale(.97); }
.btn-logout { padding: 12px; background: none; border: 1px solid var(--red); color: var(--red); border-radius: var(--radius-sm); font-size: .85rem; cursor: pointer; margin-top: 20px; width: 100%; max-width: 400px; font-family: inherit; }
.msg-box { margin-top: 12px; font-size: .85rem; }
.msg-ok { color: var(--green); } .msg-err { color: var(--red); }
.sub { color: var(--text-3); font-size: .85rem; margin-bottom: 20px; line-height: 1.5; }
.switch-link { font-size: .82rem; color: var(--text-3); margin-top: 16px; }
.switch-link a { color: var(--blue); text-decoration: none; font-weight: 600; }
.logo-big { font-size: 3rem; margin-bottom: 12px; }
h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }
.loading { display: flex; align-items: center; justify-content: center; padding: 32px; color: var(--text-3); font-size: .85rem; flex: 1; }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; text-align: center; color: var(--text-3); flex: 1; }
.empty p { font-size: .9rem; margin-bottom: 12px; }

/* Dashboard */
.dash-content { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.dash-stats { display: flex; gap: 8px; padding: 16px; }
.stat { flex: 1; background: var(--white); border-radius: var(--radius-sm); padding: 16px 12px; text-align: center; border: 1px solid var(--border); }
.stat-num { display: block; font-size: 1.3rem; font-weight: 700; color: var(--blue); }
.stat-label { font-size: .7rem; color: var(--text-3); }
.dash-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 0 16px 16px; }
.dash-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 8px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-size: 1.3rem; font-family: inherit; }
.dash-btn span { font-size: .65rem; color: var(--text-3); }
.dash-btn:active { background: var(--bg); }
.section-title { font-size: .85rem; font-weight: 600; padding: 0 16px 8px; color: var(--text-3); }

/* Conversations */
.convs-list { flex: 1; }
.conv-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.conv-item:active { background: rgba(46,124,201,.04); }
.conv-avatar { width: 44px; height: 44px; flex-shrink: 0; }
.conv-info { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; margin-bottom: 3px; }
.conv-name { font-weight: 600; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: .7rem; color: var(--text-3); flex-shrink: 0; }
.conv-bottom { display: flex; justify-content: space-between; }
.conv-msg { font-size: .8rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-badge { background: var(--blue); color: white; font-size: .65rem; font-weight: 700; min-width: 20px; height: 20px; border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 0 6px; }
.avatar { border-radius: 50%; object-fit: cover; }
.avatar-init { background: var(--blue); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; }

/* Chat */
.chat-screen { background: #E8EDF2; }
.chat-header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--white); border-bottom: 1px solid var(--border); flex-shrink: 0; padding-top: max(10px, env(safe-area-inset-top)); }
.chat-header-info { display: flex; flex-direction: column; }
.chat-header-name { font-weight: 600; font-size: .95rem; }
.chat-header-sub { font-size: .7rem; color: var(--text-3); }
.messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 3px; }
.msg { display: flex; max-width: 80%; } .msg-mine { align-self: flex-end; } .msg-other { align-self: flex-start; } .msg-system { align-self: center; max-width: 90%; }
.msg-bubble { padding: 8px 12px; border-radius: 16px; font-size: .88rem; line-height: 1.45; word-break: break-word; }
.msg-mine .msg-bubble { background: var(--blue); color: white; border-bottom-right-radius: 4px; }
.msg-other .msg-bubble { background: var(--white); color: var(--text); border-bottom-left-radius: 4px; }
.msg-system .msg-bubble { background: rgba(0,0,0,.06); color: var(--text-3); font-size: .78rem; text-align: center; border-radius: 12px; }
.msg-meta { font-size: .6rem; opacity: .6; margin-left: 8px; white-space: nowrap; }
.msg-form { display: flex; gap: 8px; padding: 8px 12px; background: var(--white); border-top: 1px solid var(--border); flex-shrink: 0; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.msg-form input { flex: 1; padding: 10px 14px; border-radius: 24px; border: 1px solid var(--border); font-size: .88rem; font-family: inherit; background: var(--bg); }
.msg-form input:focus { outline: none; border-color: var(--blue); }
.send-btn { width: 42px; height: 42px; border-radius: 50%; background: var(--blue); color: white; border: none; font-size: 1.1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.typing-indicator { padding: 4px 16px; display: flex; gap: 4px; }
.typing-indicator span { width: 7px; height: 7px; background: var(--text-3); border-radius: 50%; animation: bounce .6s infinite alternate; }
.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }
@keyframes bounce { to { transform: translateY(-5px); opacity: .3; } }

/* QR */
.qr-img { width: 220px; height: 220px; border-radius: 16px; margin: 20px 0 12px; box-shadow: 0 4px 20px rgba(0,0,0,.08); }
.qr-code { font-size: 1.6rem; font-weight: 700; letter-spacing: 4px; color: var(--blue); margin-bottom: 8px; }

/* Promos */
.promos-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.promo-card { background: var(--white); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; display: flex; flex-direction: column; position: relative; }
.promo-img { width: 100%; height: 160px; object-fit: cover; }
.promo-info { padding: 14px 16px; }
.promo-info h4 { font-size: .95rem; font-weight: 600; margin-bottom: 4px; }
.promo-info p { font-size: .82rem; color: var(--text-3); line-height: 1.4; }
.promo-status { font-size: .72rem; margin-top: 6px; display: inline-block; }
.promo-del { position: absolute; top: 10px; right: 10px; background: rgba(255,255,255,.9); border: none; border-radius: 50%; width: 32px; height: 32px; cursor: pointer; font-size: 1rem; }

/* Profile/Settings */
.profile-avatar { position: relative; margin-bottom: 16px; }
.avatar-upload-btn { position: absolute; bottom: 0; right: 0; width: 28px; height: 28px; background: var(--white); border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,.12); cursor: pointer; font-size: .75rem; }
.hours-row { display: flex; align-items: center; gap: 8px; }
.hours-row label { width: 36px; font-size: .78rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; flex-shrink: 0; }
.hours-row input { flex: 1; }
