/* SEAM Chat - mobilna aplikacija. Izgled prati WhatsApp/Viber: lista sa avatarima i brojacem neprocitanih,
   mehurici sa vremenom u uglu, polje za pisanje i providna traka sa karticama na dnu.
   Boje su promenljive (svetli/tamni rezim): :root = svetlo, [data-theme="dark"] = tamno. */

:root {
    --bg: #EEF1F6;
    --list-bg: #FFFFFF;
    --surface: #FFFFFF;
    --glass-fill: linear-gradient(180deg, rgba(255,255,255,.62), rgba(255,255,255,.28));
    --glass-edge: rgba(0, 0, 0, .06);
    --glass-shine: rgba(255, 255, 255, .9);
    --tab-on: rgba(27, 79, 224, .12);
    --tab-on-text: #1B4FE0;
    --tab-text: #64748B;
    --text: #0B1530;
    --muted: #64748B;
    --faint: #94A3B8;
    --line: #E3E9F2;
    --line-soft: #D8DEE8;
    --press: #F3F6FB;
    --input: #EEF1F6;
    --primary: #1B4FE0;
    --primary-soft: rgba(27, 79, 224, .12);
    --teal: #0F9E88;
    --bubble-in: #FFFFFF;
    --bubble-out: #DCF3E8;
    --bubble-bot: #E8EEFF;
    --chat-bg: #EFEAE2;
    --doodle: .045;
    --sys-bg: rgba(255, 244, 196, .92);
    --sys-text: #54656f;
    --day-bg: rgba(255, 255, 255, .85);
    --warn-bg: #FEF3C7;
    --warn-text: #92400E;
    --danger: #DC2626;
}

:root[data-theme="dark"] {
    --bg: #17171A;
    --list-bg: #17171A;
    --surface: #262629;
    --glass-fill: linear-gradient(180deg, rgba(255,255,255,.20), rgba(255,255,255,.07));
    --glass-edge: rgba(255, 255, 255, .20);
    --glass-shine: rgba(255, 255, 255, .34);
    --tab-on: rgba(255, 255, 255, .18);
    --tab-on-text: #FFFFFF;
    --tab-text: #E3E3EA;
    --text: #F2F2F7;
    --muted: #8E8E93;
    --faint: #636366;
    --line: #38383C;
    --line-soft: #333337;
    --press: #212124;
    --input: #2A2A2E;
    --primary: #5B8DFF;
    --primary-soft: rgba(91, 141, 255, .18);
    --teal: #2FE0C0;
    --bubble-in: #2C2C30;
    --bubble-out: #005C4B;
    --bubble-bot: #23304F;
    --chat-bg: #121215;
    --doodle: .07;
    --sys-bg: rgba(64, 56, 22, .9);
    --sys-text: #E9DFA6;
    --day-bg: rgba(44, 44, 46, .9);
    --warn-bg: #3B2F0B;
    --warn-text: #FCD34D;
    --danger: #F87171;
}

html, body { height: 100%; margin: 0; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
body { font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }
#app { height: 100%; }
* { box-sizing: border-box; }

.boot { height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--list-bg); }
.boot img { width: 96px; height: 96px; }

#blazor-error-ui { background: #fff3cd; color: #0B1530; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 2000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* ---- Okvir ekrana ---- */
.screen { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: var(--list-bg); padding-top: env(safe-area-inset-top); }
.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--list-bg); border-bottom: 1px solid var(--line); min-height: 56px; }
.topbar .title { flex: 1; min-width: 0; font-size: 20px; font-weight: 700; }
.topbar .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar img.logo { width: 82px; height: auto; flex: 0 0 auto; }
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: inline-block; }
.topbar.home { border-bottom: 0; padding-bottom: 6px; }
.iconbtn { border: 0; background: transparent; padding: 6px; border-radius: 50%; color: inherit; display: inline-flex; cursor: pointer; }
.iconbtn:active { background: var(--press); }

/* Pretraga u istom redu kao logo */
.searchbar { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; background: var(--input); border-radius: 22px; padding: 0 12px; height: 38px; color: var(--muted); }
.searchbar input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 15px; color: var(--text); }
.searchbar input::placeholder { color: var(--muted); }

/* ---- Avatar ---- */
.avatar { flex-shrink: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; overflow: hidden; background: #1B4FE0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---- Liste (razgovori, arhiva, blokirani) ---- */
.list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--list-bg); padding-bottom: 104px; }
.row { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 14px; cursor: pointer; }
.row::after { content: ""; position: absolute; left: 14px; right: 0; bottom: 0; height: 1px; background: var(--line-soft); }
.row:active { background: var(--press); }
.row .main { flex: 1; min-width: 0; }
.row .line1 { display: flex; align-items: baseline; gap: 8px; }
.row .name { flex: 1; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .time { font-size: 12px; color: var(--muted); }
.row.unread .time { color: var(--primary); font-weight: 600; }
.row .line2 { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.row .preview { flex: 1; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.unread .preview { color: var(--text); font-weight: 500; }
.row .host { font-size: 11px; color: var(--faint); }
.row .repeat { font-size: 11px; font-weight: 600; color: #b45309; }
.badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--primary); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 64px 24px; text-align: center; color: var(--muted); }
.notice { background: var(--warn-bg); color: var(--warn-text); font-size: 12.5px; padding: 6px 14px; text-align: center; }

/* ---- Razgovor ---- */
.messages { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 10px; background-color: var(--chat-bg); background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='170' height='170' viewBox='0 0 170 170' fill='none' stroke='%23888' stroke-opacity='.14' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 26h28a4 4 0 0 1 4 4v14a4 4 0 0 1-4 4H34l-9 7v-7h-5a4 4 0 0 1-4-4V30a4 4 0 0 1 4-4z'/%3E%3Ccircle cx='120' cy='30' r='10'/%3E%3Cpath d='M116 28v.01M124 28v.01M115.5 34c2.5 3.5 6.5 3.5 9 0'/%3E%3Cpath d='M88 100l4.2 8.5 9.3 1.3-6.7 6.6 1.6 9.3-8.4-4.4-8.4 4.4 1.6-9.3-6.7-6.6 9.3-1.3z'/%3E%3Cpath d='M28 128c-6.5-6.5-13-10.5-13-17a7.5 7.5 0 0 1 13-5 7.5 7.5 0 0 1 13 5c0 6.5-6.5 10.5-13 17z'/%3E%3Cpath d='M130 128l6 6 13-15'/%3E%3Ccircle cx='62' cy='70' r='3'/%3E%3Ccircle cx='150' cy='80' r='2'/%3E%3Cpath d='M100 20l3 3m-3 0l3-3M40 90l3 3m-3 0l3-3'/%3E%3C/svg%3E"); background-size: 170px 170px; display: flex; flex-direction: column; gap: 4px; }
.bubble { display: flow-root; max-width: 82%; padding: 6px 10px 5px; font-size: 15px; line-height: 1.4; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(0,0,0,.08); color: var(--text); }
.bubble.in { align-self: flex-start; background: var(--bubble-in); border-bottom-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); border-bottom-right-radius: 4px; }
.bubble.bot { background: var(--bubble-bot); }
.bubble .who { display: block; font-size: 11.5px; font-weight: 700; color: var(--teal); margin-bottom: 1px; }
.bubble .tick { display: inline-flex; vertical-align: -5px; margin-left: 7px; color: #b5bcc4; }
.bubble .tick .mud-icon-root { font-size: 17px; }
.bubble .tick.read { color: #53bdeb; }
.bubble .time { float: right; margin: 5px 0 -3px 10px; font-size: 11px; color: var(--muted); line-height: 1; }
.sys { align-self: center; font-size: 12px; color: var(--sys-text); background: var(--sys-bg); border-radius: 8px; padding: 4px 12px; margin: 6px 0; text-align: center; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.sale { align-self: center; max-width: 92%; font-size: 13px; font-weight: 700; color: #14532d; background: #dcfce7; border: 1px solid #4ade80; border-radius: 10px; padding: 8px 14px; margin: 8px 0; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.langtag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; font-size: 10px; font-weight: 700; background: rgba(99,102,241,.18); color: var(--mud-palette-primary, #6366f1); }
.day { align-self: center; font-size: 12px; color: var(--sys-text); background: var(--day-bg); border-radius: 8px; padding: 3px 12px; margin: 8px 0 4px; }
.typing { align-self: flex-start; display: flex; gap: 4px; padding: 11px 13px; background: var(--bubble-in); border-radius: 14px; border-bottom-left-radius: 4px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: #9ca3af; animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%,80%,100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--bg); }
.composer textarea { flex: 1; resize: none; border: 0; border-radius: 22px; padding: 10px 16px; font: inherit; font-size: 16px; line-height: 20px; max-height: 96px; outline: none; background: var(--surface); color: var(--text); overflow-y: hidden; scrollbar-width: none; }
.composer textarea::-webkit-scrollbar { display: none; }
.sendbtn { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sendbtn:disabled { opacity: .45; }
.readonly { display: flex; align-items: center; gap: 10px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }
.readonly .text { flex: 1; }

/* ---- Prijava ---- */
.login { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 32px 24px; background: var(--list-bg); }
.login .brand { text-align: center; margin-bottom: 28px; }
.login .brand img { width: 220px; max-width: 70%; height: auto; }
.login h1 { font-size: 22px; margin: 0 0 12px; text-align: center; }
.login .hint { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
/* MudBlazor polja imaju flex-grow: u koloni bi se razvukla i napravila velike razmake. */
.login .mud-input-control { flex: none; margin: 0; }
.login .mud-input-helper-text { min-height: 0; }
.login .mud-button-root { flex: none; }

/* ---- Podesavanja ---- */
.profile { flex: 1; overflow-y: auto; background: var(--bg); padding-bottom: 110px; }
.profile .hero { background: var(--surface); padding: 24px 16px 20px; text-align: center; border-bottom: 1px solid var(--line); }
.profile .card { background: var(--surface); margin: 12px 0 0; padding: 4px 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.profile .item { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.profile .item:last-child { border-bottom: 0; }
.profile .item .label { flex: 1; }
.profile .item .label small { display: block; color: var(--muted); font-size: 12.5px; }
.profile .section-title { padding: 16px 16px 6px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.segmented { display: flex; gap: 6px; background: var(--input); border-radius: 12px; padding: 4px; margin: 10px 0 12px; }
.segmented button { flex: 1; border: 0; background: transparent; color: var(--muted); border-radius: 9px; padding: 9px 4px; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ---- Donja traka (providna, plutajuca, kao kod WhatsApp-a na iPhone-u) ---- */
.tabbar { position: fixed; left: 14px; right: 14px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 500; display: flex; gap: 2px; padding: 6px; border-radius: 34px; background: var(--glass-fill); -webkit-backdrop-filter: blur(30px) saturate(2) brightness(1.06); backdrop-filter: blur(30px) saturate(2) brightness(1.06); border: 1px solid var(--glass-edge); box-shadow: 0 10px 34px rgba(0,0,0,.30), inset 0 1px 0 var(--glass-shine); }
.tabbar .tab { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 7px 4px 6px; border: 0; border-radius: 28px; background: transparent; color: var(--tab-text); font-size: 11px; font-weight: 600; cursor: pointer; }
.tabbar .tab.on { background: var(--tab-on); color: var(--tab-on-text); box-shadow: inset 0 1px 0 var(--glass-shine); }
.tabbar .tab .tabbadge { position: absolute; top: 3px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #16A34A; color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }

/* Ponuda za uključivanje obaveštenja (iznad liste razgovora): naslov, rečenica, pa dugmad ispod */
.pushcard { display: flex; align-items: flex-start; gap: 12px; margin: 8px 12px 4px; padding: 12px 14px; background: var(--primary-soft); border-radius: 14px; }
.pushcard .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.pushcard .body b { font-size: 14px; color: var(--text); }
.pushcard .btns { display: flex; gap: 8px; margin-top: 8px; }

/* Proizvodi iz prodavnice u poruci (karusel) */
.bubble .cards { display: flex; gap: 8px; overflow-x: auto; margin: 2px 0 4px; white-space: normal; }
.bubble .card { flex: 0 0 132px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); border-radius: 10px; overflow: hidden; text-decoration: none; color: var(--text); padding-bottom: 6px; }
.bubble .card img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; background: var(--input); }
.bubble .card .cn { font-size: 13px; font-weight: 600; padding: 4px 8px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bubble .card .cp { font-size: 13px; padding: 0 8px; color: var(--muted); }
.bubble .card .cb { display: block; text-decoration: none; margin: 4px 8px 0; text-align: center; font-size: 12px; font-weight: 600; padding: 6px; border-radius: 8px; background: #E5E7EB; color: #111111; }

/* Slanje proizvoda: dugme u polju za poruku i izbor proizvoda */
.attachbtn { width: 40px; height: 44px; border: 0; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.attachbtn:disabled { opacity: .45; }
.attachbtn.on { color: var(--primary); }
.attach-backdrop { position: fixed; inset: 0; z-index: 40; background: transparent; }
.attach-sheet { position: relative; z-index: 41; margin: 0 10px 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); overflow: hidden; }
.attach-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); font: inherit; font-size: 15px; text-align: left; -webkit-tap-highlight-color: transparent; }
.attach-item:last-child { border-bottom: 0; }
.attach-item:active { background: var(--primary-soft); }
.attach-item.quick { flex-direction: column; align-items: flex-start; gap: 2px; }
.attach-title { font-weight: 600; }
.attach-sub { font-size: 13px; color: var(--muted); display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-weight: 600; border-bottom: 1px solid var(--line); }
.attach-back { border: 0; background: transparent; color: var(--muted); display: inline-flex; padding: 4px; }
.attach-scroll { max-height: 42vh; overflow-y: auto; }
.pick-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.pick-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 2px; border-bottom: 1px solid var(--line); }
.pick-row:last-child { border-bottom: 0; }
.chk { width: 22px; height: 22px; margin: 0 9px 0 11px; border: 2px solid var(--primary); border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: #fff; box-sizing: border-box; }
.chk.on { background: var(--primary); }
.chk.off { border-color: var(--muted); }
.pick-row { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.pick-row.off { opacity: .45; cursor: default; }
.dlg-blur { backdrop-filter: blur(10px) !important; -webkit-backdrop-filter: blur(10px) !important; background-color: rgba(0, 0, 0, .35) !important; }
.pick-row.on { background: var(--primary-soft); }
.pick-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--input); flex-shrink: 0; display: block; }
.pick-empty { display: flex; align-items: center; justify-content: center; color: var(--muted); }
.pick-main { flex: 1; min-width: 0; }
.pick-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-sub { font-size: 12px; color: var(--muted); }
.pick-sub s { opacity: .6; margin-right: 6px; }

/* Napomena o roku cuvanja (arhiva) */
.retnote { display: flex; gap: 8px; align-items: flex-start; margin: 8px 12px; padding: 10px 12px; border-radius: 12px; font-size: 12.5px; line-height: 1.4; color: var(--muted); background: var(--input); }
.retnote .mud-icon-root { color: var(--primary); flex-shrink: 0; margin-top: 1px; }
.retnote b { color: var(--text); }

/* Klikabilni linkovi u porukama */
.bubble a { color: inherit; text-decoration: underline; word-break: break-all; }
.bubble a.ext-link::after { content: " ↗"; font-size: .85em; opacity: .7; text-decoration: none; display: inline-block; }

/* Lista usluga u poruci */
.bubble .svcs { display: flex; flex-direction: column; gap: 6px; margin: 2px 0 4px; white-space: normal; }
.bubble .svc { display: flex; gap: 8px; padding: 7px; background: var(--surface); border-radius: 12px; color: var(--text); }
.bubble .svc img, .bubble .svc-noimg { width: 52px; height: 52px; flex: 0 0 52px; border-radius: 9px; object-fit: cover; background: var(--input); }
.bubble .svc-noimg { display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.bubble .svc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bubble .svc-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.bubble .svc-name { font-size: 14px; font-weight: 600; }
.bubble .svc-price { font-size: 13px; font-weight: 700; white-space: nowrap; }
.bubble .svc-desc { font-size: 12px; color: var(--muted); line-height: 1.35; }
.bubble .svc-btn { align-self: flex-start; margin-top: 3px; font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 8px; background: #E5E7EB; color: #111111; text-decoration: none; }
.chk { font-size: 12px; font-weight: 700; }

/* Kockice za 6-cifreni kod (prijava, uključivanje dvofaktorske zaštite) */
.otp { display: flex; gap: 8px; justify-content: center; }
.otp-box {
    width: 44px; height: 52px; text-align: center; font-size: 22px; font-weight: 700;
    border: 1.5px solid var(--faint); border-radius: 10px;
    background: var(--surface); color: inherit;
    font-family: inherit; -webkit-appearance: none; appearance: none;
}
.otp-box:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.otp-box:disabled { opacity: .6; }

/* Zamucena pozadina iza svakog dijaloga (isti pristup kao ChatSeam.UI/wwwroot/app.css). */
.mud-overlay-scrim {
    background-color: rgba(15, 23, 42, 0.48) !important;
    backdrop-filter: blur(7px) !important;
    -webkit-backdrop-filter: blur(7px) !important;
}
