/* Standalone Telegram Live Chat — full-page UI */
:root {
    --sc-brand: #2563eb;
    --sc-brand-dark: #1d4ed8;
    --sc-bg: #f3f4f6;
    --sc-agent: #ffffff;
    --sc-text: #1f2937;
    --sc-muted: #6b7280;
    --sc-border: #e5e7eb;
    --sc-radius: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* a `display:flex` rule must not defeat the hidden attribute */
html, body { height: 100%; margin: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--sc-bg);
    color: var(--sc-text);
    -webkit-font-smoothing: antialiased;
}

.sc-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;            /* mobile: account for the dynamic address bar */
    max-width: 720px;
    margin: 0 auto;
    background: var(--sc-bg);
    box-shadow: 0 0 40px rgba(0,0,0,.06);
}

/* Header */
.sc-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: linear-gradient(135deg, var(--sc-brand), var(--sc-brand-dark));
    color: #fff;
    flex: none;
}
.sc-header-av {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
}
.sc-header-meta { flex: 1 1 auto; min-width: 0; }
.sc-header-title { font-weight: 700; font-size: 16px; line-height: 1.2; }
.sc-header-sub { font-size: 12.5px; opacity: .9; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.sc-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 0 rgba(74,222,128,.6); animation: sc-pulse 2s infinite; }
@keyframes sc-pulse { 0%{box-shadow:0 0 0 0 rgba(74,222,128,.5);} 70%{box-shadow:0 0 0 7px rgba(74,222,128,0);} 100%{box-shadow:0 0 0 0 rgba(74,222,128,0);} }
.sc-end-btn {
    flex: none;
    background: rgba(255,255,255,.16);
    color: #fff; border: 0;
    padding: 7px 12px; border-radius: 999px;
    font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.sc-end-btn:hover { background: rgba(255,255,255,.28); }

/* Body / thread */
.sc-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Pre-chat form */
.sc-welcome { text-align: center; margin: auto 0; padding: 24px 8px; }
.sc-welcome h2 { font-size: 22px; margin: 0 0 6px; }
.sc-welcome p { color: var(--sc-muted); margin: 0 0 22px; font-size: 14.5px; }
.sc-form { display: flex; flex-direction: column; gap: 12px; max-width: 340px; margin: 0 auto; }
.sc-form input {
    padding: 13px 15px; border: 1px solid var(--sc-border); border-radius: 12px;
    font-size: 15px; outline: none; transition: border-color .15s;
}
.sc-form input:focus { border-color: var(--sc-brand); }
.sc-form button {
    padding: 13px; border: 0; border-radius: 12px; cursor: pointer;
    background: var(--sc-brand); color: #fff; font-size: 15px; font-weight: 600;
}
.sc-form button:hover { background: var(--sc-brand-dark); }
.sc-form .sc-formerr { color: #dc2626; font-size: 13px; min-height: 16px; text-align: left; }

/* Messages */
.sc-msg { display: flex; flex-direction: column; max-width: 78%; }
.sc-msg-customer { align-self: flex-end; align-items: flex-end; }
.sc-msg-agent { align-self: flex-start; align-items: flex-start; }
.sc-bubble {
    padding: 10px 14px; border-radius: var(--sc-radius);
    font-size: 14.5px; line-height: 1.45; word-wrap: break-word; white-space: pre-wrap;
}
.sc-msg-customer .sc-bubble { background: var(--sc-brand); color: #fff; border-bottom-right-radius: 5px; }
.sc-msg-agent .sc-bubble { background: var(--sc-agent); color: var(--sc-text); border: 1px solid var(--sc-border); border-bottom-left-radius: 5px; }
.sc-meta { font-size: 11px; color: var(--sc-muted); margin: 3px 6px 0; }
.sc-sender { font-weight: 600; }

/* System notices */
.sc-system { align-self: center; max-width: 90%; text-align: center; }
.sc-system .sc-bubble {
    background: #eef2ff; color: #4338ca; border: 1px solid #e0e7ff;
    font-size: 13px; border-radius: 12px;
}

/* Attachments */
.sc-att img { max-width: 220px; border-radius: 12px; display: block; cursor: pointer; }
.sc-att a {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 12px; border-radius: 12px; text-decoration: none;
    background: rgba(255,255,255,.18); color: inherit; font-size: 13.5px; font-weight: 500;
}
.sc-msg-agent .sc-att a { background: #f3f4f6; color: var(--sc-text); }

/* Footer / composer */
.sc-footer { flex: none; border-top: 1px solid var(--sc-border); background: #fff; padding: 10px 12px; position: relative; }
.sc-compose { display: flex; align-items: center; gap: 6px; }
.sc-attach, .sc-emojibtn {
    flex: none; cursor: pointer; color: var(--sc-muted); border: 0; background: transparent;
    display: flex; align-items: center; justify-content: center; padding: 8px; border-radius: 10px;
}
.sc-attach:hover, .sc-emojibtn:hover { color: var(--sc-brand); background: #f3f4f6; }
.sc-emojipanel {
    position: absolute; left: 12px; right: 12px; bottom: calc(100% + 6px);
    background: #fff; border: 1px solid var(--sc-border); border-radius: 12px;
    box-shadow: 0 10px 28px rgba(0,0,0,.14); padding: 8px; max-height: 200px; overflow-y: auto;
    display: flex; flex-wrap: wrap; gap: 2px; z-index: 30;
}
.sc-emoji { border: 0; background: transparent; cursor: pointer; font-size: 21px; line-height: 1; padding: 5px; border-radius: 8px; }
.sc-emoji:hover { background: #f3f4f6; }
.sc-input {
    flex: 1 1 auto; resize: none; border: 1px solid var(--sc-border); border-radius: 18px;
    padding: 10px 14px; font-size: 14.5px; line-height: 1.4; max-height: 120px; outline: none;
    font-family: inherit; overflow-y: hidden;
}
.sc-input:focus { border-color: var(--sc-brand); }
.sc-send-btn {
    flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer;
    background: var(--sc-brand); color: #fff; display: flex; align-items: center; justify-content: center;
}
.sc-send-btn:hover { background: var(--sc-brand-dark); }
.sc-send-btn:disabled { opacity: .5; cursor: default; }

.sc-filepreview {
    margin-top: 8px; font-size: 13px; color: var(--sc-muted);
    display: flex; align-items: center; gap: 8px;
}
.sc-filepreview button { border: 0; background: #f3f4f6; border-radius: 8px; cursor: pointer; padding: 2px 7px; font-size: 14px; }

/* Ended state */
.sc-ended { text-align: center; margin: auto 0; padding: 24px; }
.sc-ended p { color: var(--sc-muted); font-size: 14.5px; margin: 0 0 18px; }
.sc-newchat {
    border: 0; border-radius: 12px; cursor: pointer; padding: 12px 22px;
    background: linear-gradient(135deg, var(--sc-brand), var(--sc-brand-dark));
    color: #fff; font-size: 14.5px; font-weight: 600;
}

/* Lightbox */
.sc-lightbox {
    position: fixed; inset: 0; background: rgba(0,0,0,.82); z-index: 9999;
    display: flex; align-items: center; justify-content: center; padding: 24px;
}
.sc-lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }

.sc-typing { font-style: italic; color: var(--sc-muted); font-size: 13px; padding: 2px 6px; }

/* Quote / reply */
.sc-line { display: flex; align-items: center; gap: 4px; max-width: 100%; }
.sc-replybtn {
    flex: none; border: 0; background: transparent; color: var(--sc-muted);
    cursor: pointer; font-size: 16px; line-height: 1; padding: 4px 6px; border-radius: 8px;
    opacity: 0; transition: opacity .15s;
}
.sc-replybtn:hover { background: rgba(0,0,0,.06); color: var(--sc-brand); }
.sc-msg:hover .sc-replybtn { opacity: 1; }
@media (hover: none) { .sc-replybtn { opacity: .5; } }

.sc-quote {
    max-width: 78%; cursor: pointer; margin-bottom: 3px;
    border-left: 3px solid var(--sc-brand); background: rgba(37,99,235,.07);
    padding: 5px 9px; border-radius: 8px; font-size: 12.5px; line-height: 1.35;
    display: flex; flex-direction: column; gap: 1px;
}
.sc-msg-customer .sc-quote { align-self: flex-end; }
.sc-quote-s { font-weight: 700; color: var(--sc-brand); }
.sc-quote-b { color: var(--sc-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }

.sc-flash > .sc-line .sc-bubble { animation: sc-flash 1.2s ease; }
@keyframes sc-flash { 0%,100% { box-shadow: none; } 30% { box-shadow: 0 0 0 3px rgba(37,99,235,.45); } }

/* Reply bar above the composer */
.sc-replybar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: #eff4ff; border: 1px solid #dbe6ff; border-left: 3px solid var(--sc-brand);
    border-radius: 10px; padding: 7px 11px; margin-bottom: 8px;
}
.sc-rb-info { min-width: 0; display: flex; flex-direction: column; }
.sc-rb-info b { font-size: 12.5px; color: var(--sc-brand); }
.sc-rb-info span { font-size: 12.5px; color: var(--sc-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-rb-x { flex: none; border: 0; background: transparent; color: var(--sc-muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px; }
.sc-rb-x:hover { color: #ef4444; }

@media (max-width: 600px) {
    .sc-app { max-width: 100%; box-shadow: none; }
    .sc-msg { max-width: 86%; }
    .sc-att img { max-width: 100%; }
    .sc-quote-b { max-width: 200px; }
    .sc-body { padding: 14px; }
}
@media (max-width: 380px) {
    .sc-header { padding: 12px 14px; gap: 9px; }
    .sc-header-av { width: 36px; height: 36px; font-size: 18px; }
    .sc-header-title { font-size: 15px; }
    .sc-footer { padding: 8px 9px; }
    .sc-input { font-size: 16px; }   /* iOS won't zoom on focus when ≥16px */
}
