/* Alerts app (static/alerts/alerts.css) - WhatsApp-like inbox for bot alerts; tokens copied from static/messages/messages.css */
:root{
  color-scheme:dark;  /* Native controls (audio player, scrollbars) follow the dark theme */
  --bg:#0b1016; --header:#101826; --brand:#2f86a8; --brand-2:#2dd4bf;
  --surface:#121a26; --surface-2:#18222f; --surface-3:#1f2b3a;
  --text:#eaf1f7; --muted:#9db0c3; --faint:#6b7f93;
  --ok:#34d399; --warn:#fbbf24; --bad:#f87171; --info:#60a5fa;
  --border:rgba(148,163,184,.14); --border-strong:rgba(148,163,184,.28);
  --unread-bg:rgba(45,212,191,.09);
  --radius:14px; --radius-sm:10px; --radius-xs:8px;
  --shadow:0 12px 32px rgba(2,6,12,.45); --shadow-sm:0 4px 14px rgba(2,6,12,.30);
  --ring:0 0 0 2px rgba(45,212,191,.45);
  --safe-top:env(safe-area-inset-top,0px); --safe-bottom:env(safe-area-inset-bottom,0px);
}
*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{
  background:var(--bg); color:var(--text);
  font:15px/1.45 "Inter",system-ui,-apple-system,"Segoe UI",sans-serif;
  -webkit-font-smoothing:antialiased; -webkit-tap-highlight-color:transparent;
}
button{font:inherit;color:inherit;cursor:pointer}
button:focus-visible,a:focus-visible,textarea:focus-visible,input:focus-visible{outline:none;box-shadow:var(--ring)}
[hidden]{display:none!important}

/* ====== Layout ====== */
/* Pinned to the visible viewport: in the installed Android app 100dvh counted the system bars and pushed the composer
   below the screen; position:fixed + inset:0 follows the area the user actually sees (and the keyboard). */
.app{display:grid;grid-template-columns:minmax(300px,380px) minmax(0,1fr);position:fixed;inset:0;overflow:hidden}
.inbox{display:flex;flex-direction:column;min-width:0;background:var(--surface);border-right:1px solid var(--border);min-height:0}
.chat{display:flex;flex-direction:column;min-width:0;min-height:0;background:var(--bg)}

/* ====== Inbox ====== */
.inbox-head,.chat-head{
  display:flex;align-items:center;gap:12px;padding:calc(10px + var(--safe-top)) 16px 10px;
  background:var(--header);border-bottom:1px solid var(--border);min-height:60px;
}
.inbox-head h1{font-size:19px;font-weight:700;margin:0;flex:1}
.inbox-logo{border-radius:10px}
.total-badge{background:var(--brand-2);color:#04201c;font-weight:700;font-size:12px;border-radius:999px;padding:2px 8px}
.icon-btn{
  display:inline-grid;place-items:center;width:40px;height:40px;border-radius:50%;
  background:transparent;border:0;color:var(--muted);text-decoration:none;
}
.icon-btn:hover{background:var(--surface-3);color:var(--text)}

.banner{
  display:flex;align-items:center;gap:10px;margin:10px 12px 0;padding:10px 12px;
  background:var(--surface-2);border:1px solid var(--border-strong);border-radius:var(--radius-sm);
  font-size:13px;color:var(--muted)
}
.banner i{color:var(--brand-2)}
.banner span{flex:1}
.banner-btn{background:var(--brand);border:0;border-radius:999px;padding:6px 12px;font-weight:600;font-size:13px;white-space:nowrap}
.banner-close{background:none;border:0;font-size:20px;line-height:1;color:var(--faint);padding:0 4px}

.bot-list{list-style:none;margin:6px 0 0;padding:0;overflow-y:auto;flex:1}
.bot-item{
  display:flex;align-items:center;gap:12px;padding:12px 16px;cursor:pointer;
  border-bottom:1px solid var(--border);
}
.bot-item:hover{background:var(--surface-2)}
.bot-item.active{background:var(--surface-3)}
.bot-meta{flex:1;min-width:0}
.bot-row{display:flex;align-items:baseline;gap:8px}
.bot-name{font-weight:600;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.bot-time{font-size:12px;color:var(--faint)}
.bot-item.has-unread .bot-time{color:var(--brand-2);font-weight:600}
.bot-preview{display:flex;align-items:center;gap:8px;margin-top:2px}
.bot-preview p{margin:0;flex:1;font-size:13.5px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.bot-item.has-unread .bot-preview p{color:var(--text)}
.unread-count{
  min-width:22px;height:22px;padding:0 7px;border-radius:999px;background:var(--brand-2);color:#04201c;
  font-size:12px;font-weight:700;display:grid;place-items:center
}
.lvl-dot{width:8px;height:8px;border-radius:50%;flex:none}
.lvl-error{background:var(--bad)} .lvl-warning{background:var(--warn)} .lvl-info{background:var(--info)} .lvl-report{background:var(--ok)}

.avatar{
  width:46px;height:46px;border-radius:50%;flex:none;display:grid;place-items:center;overflow:hidden;
  background:var(--surface-3);color:var(--text);font-weight:700;font-size:17px;border:1px solid var(--border)
}
.avatar img{width:100%;height:100%;object-fit:cover}
.avatar i{font-size:19px}
.empty{color:var(--faint);text-align:center;padding:32px 16px}

/* ====== Chat ====== */
.chat-placeholder{flex:1;display:grid;place-content:center;justify-items:center;gap:12px;color:var(--faint)}
.chat-placeholder img{border-radius:22px;opacity:.85}
.chat-title{flex:1;min-width:0}
.chat-title h2{margin:0;font-size:16px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-title span{font-size:12px;color:var(--faint)}
.chat-head .avatar{width:40px;height:40px}
.back-btn{display:none}
.pill-btn{
  display:inline-flex;align-items:center;gap:8px;padding:8px 14px;border-radius:999px;
  background:var(--surface-2);border:1px solid var(--border-strong);font-size:13px;font-weight:500;white-space:nowrap
}
.pill-btn:hover{background:var(--surface-3)}
.pill-btn i{color:var(--brand-2)}

.chat-body{flex:1;overflow-y:auto;padding:16px clamp(12px,4vw,56px) 24px;overscroll-behavior:contain}
.load-more{display:block;margin:0 auto 12px;background:var(--surface-2);border:1px solid var(--border);border-radius:999px;padding:6px 14px;font-size:13px;color:var(--muted)}
.day-sep{display:flex;justify-content:center;margin:14px 0 10px}
.day-sep span{background:var(--surface-2);color:var(--muted);font-size:12px;padding:4px 12px;border-radius:999px;border:1px solid var(--border)}
.unread-sep{display:flex;align-items:center;gap:10px;margin:14px 0;color:var(--brand-2);font-size:12px;font-weight:600}
.unread-sep::before,.unread-sep::after{content:"";flex:1;height:1px;background:rgba(45,212,191,.35)}

.msg{
  position:relative;max-width:min(720px,88%);margin:0 0 8px;padding:9px 12px 6px;
  background:var(--surface);border:1px solid var(--border);border-left:3px solid var(--border-strong);
  border-radius:4px var(--radius) var(--radius) var(--radius);box-shadow:var(--shadow-sm);cursor:pointer;
}
.msg.out{margin-left:auto;background:#163a4a;border-left-color:transparent;border-radius:var(--radius) 4px var(--radius) var(--radius);cursor:default}
.msg.lvl-error{border-left-color:var(--bad)} .msg.lvl-warning{border-left-color:var(--warn)}
.msg.lvl-info{border-left-color:var(--info)} .msg.lvl-report{border-left-color:var(--ok)}
.msg.unread{background:var(--unread-bg);border-color:rgba(45,212,191,.35)}
.msg.unread.lvl-error{border-left-color:var(--bad)} .msg.unread.lvl-warning{border-left-color:var(--warn)}
.msg-img-link{display:block;margin:-3px -6px 8px;border-radius:10px;overflow:hidden;background:var(--surface-3)}
.msg-img{display:block;width:100%;max-height:420px;object-fit:contain}
.msg-file{display:flex;align-items:center;gap:10px;margin-bottom:8px;padding:10px 12px;border-radius:10px;background:var(--surface-3);color:var(--text);text-decoration:none}
.msg-file i{color:var(--brand-2);font-size:18px}
.msg-file span{flex:1;overflow-wrap:anywhere}
.msg-file small{color:var(--faint)}
.msg-text{white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word}
.msg-text a{color:var(--brand-2)}
.msg-text code{font-family:ui-monospace,monospace;font-size:13px;background:var(--surface-3);padding:1px 4px;border-radius:4px}
.msg-foot{display:flex;align-items:center;gap:8px;justify-content:flex-end;margin-top:4px;font-size:11.5px;color:var(--faint)}
.msg-foot .src{margin-right:auto;font-family:ui-monospace,monospace;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:60%}
.hits{background:var(--surface-3);color:var(--warn);font-weight:700;border-radius:999px;padding:0 7px;font-size:11.5px}
.trash{background:none;border:0;color:var(--faint);padding:2px 4px;border-radius:6px}
.trash:hover{color:var(--bad);background:var(--surface-3)}
.new-dot{width:8px;height:8px;border-radius:50%;background:var(--brand-2)}

/* Files */
.file-row{
  display:flex;align-items:center;gap:12px;padding:12px;margin:0 0 8px;border-radius:var(--radius-sm);
  background:var(--surface);border:1px solid var(--border);text-decoration:none;color:inherit
}
.file-row.unread{background:var(--unread-bg);border-color:rgba(45,212,191,.35)}
.file-icon{width:44px;height:44px;border-radius:10px;background:var(--surface-3);display:grid;place-items:center;font-size:20px;flex:none;color:var(--brand-2)}
.file-main{flex:1;min-width:0}
.file-name,.file-sub,.file-caption{display:block}
.file-name{font-weight:600;overflow-wrap:anywhere}
.file-sub{font-size:12px;color:var(--faint);margin-top:2px}
.file-caption{font-size:13px;color:var(--muted);margin-top:4px;white-space:pre-wrap}
.file-dl{color:var(--brand-2);font-size:18px;padding:6px}

/* Composer */
.composer{
  display:flex;align-items:flex-end;gap:10px;padding:10px 12px calc(10px + var(--safe-bottom));
  background:var(--header);border-top:1px solid var(--border)
}
.composer textarea{
  flex:1;resize:none;max-height:160px;padding:10px 14px;border-radius:22px;border:1px solid var(--border-strong);
  background:var(--surface-2);color:var(--text);font:inherit
}
.send-btn{width:44px;height:44px;border-radius:50%;border:0;background:var(--brand);display:grid;place-items:center}
.composer .icon-btn{flex:none;width:44px;height:44px}
.files-upload{
  display:flex;align-items:center;gap:14px;padding:10px 14px calc(10px + var(--safe-bottom));
  background:var(--header);border-top:1px solid var(--border)
}
.files-btn{width:auto;border-radius:999px;padding:0 18px;gap:8px;display:inline-flex;font-weight:600;font-size:14px}
.files-hint{font-size:12.5px;color:var(--faint)}
.chat-body.drop-target{outline:2px dashed var(--brand-2);outline-offset:-10px}
@media (max-width:760px){.files-hint{display:none}.files-btn{flex:1;justify-content:center}}
.attach-preview,.recording{
  display:flex;align-items:center;gap:10px;padding:10px 14px;background:var(--header);border-top:1px solid var(--border);font-size:14px
}
.attach-preview i{color:var(--brand-2)}
.attach-preview span{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.recording{padding-bottom:calc(10px + var(--safe-bottom))}
.rec-dot{width:12px;height:12px;border-radius:50%;background:var(--bad);animation:rec-pulse 1s ease-in-out infinite}
.rec-hint{flex:1;color:var(--muted)}
@keyframes rec-pulse{50%{opacity:.35}}
@media (prefers-reduced-motion:reduce){.rec-dot{animation:none}}
.msg-audio{display:block;width:100%;min-width:220px;margin-bottom:6px}
.msg-video{display:block;width:100%;max-height:420px;border-radius:10px;background:#000;margin-bottom:6px}
.msg-file-link{display:inline-flex;gap:6px;align-items:center;font-size:12.5px;color:var(--brand-2);text-decoration:none;margin-bottom:6px}

.toast{
  position:fixed;left:50%;bottom:calc(24px + var(--safe-bottom));transform:translateX(-50%);
  background:var(--surface-3);border:1px solid var(--border-strong);padding:10px 16px;border-radius:999px;
  box-shadow:var(--shadow);font-size:13px;z-index:20
}

/* ====== Mobile: one pane at a time ====== */
@media (max-width:760px){
  .app{grid-template-columns:minmax(0,1fr)}
  .chat{display:none}
  .app.show-chat .inbox{display:none}
  .app.show-chat .chat{display:flex}
  .back-btn{display:inline-grid}
  .chat-placeholder{display:none}
  .pill-btn span{display:none}
  .pill-btn{padding:10px 12px}
  .chat-body{padding:12px 10px 20px}
  .msg{max-width:94%}
}

/* ====== Login ====== */
.login-page{display:grid;place-items:center;min-height:100dvh;padding:16px}
.login-card{
  width:min(380px,100%);background:var(--surface);border:1px solid var(--border);border-radius:20px;
  padding:32px 24px;box-shadow:var(--shadow);text-align:center
}
.login-logo{border-radius:20px}
.login-card h1{margin:14px 0 2px;font-size:22px}
.login-sub{margin:0 0 20px;color:var(--muted);font-size:14px}
.login-error{background:rgba(248,113,113,.12);color:var(--bad);border:1px solid rgba(248,113,113,.35);border-radius:var(--radius-xs);padding:8px;font-size:14px}
.login-card form{display:grid;gap:6px;text-align:left}
.login-card label{font-size:13px;color:var(--muted);margin-top:8px}
.login-card input{padding:12px 14px;border-radius:var(--radius-sm);border:1px solid var(--border-strong);background:var(--surface-2);color:var(--text);font:inherit;font-size:16px}
.login-card button{margin-top:18px;padding:12px;border:0;border-radius:var(--radius-sm);background:var(--brand);font-weight:600;font-size:15px}
