/* Shared conversation components for the clinic and chief technician. */
.messages-layout{--chat-ink:#333;--chat-muted:#6b6b6b;--chat-line:#e9e9e9;--chat-surface:#f6f6f6}
.messages-layout .conversation .chat-bubbles{gap:12px;padding:24px;align-items:stretch}
.messages-layout .conversation .chat-bubbles .bubble{--bubble-text:#333;--bubble-muted:#6b6b6b;--bubble-rule:#e1e1e1;align-self:flex-start;width:fit-content;min-width:120px;max-width:min(82%,460px);margin:0;padding:12px 14px;border:1px solid transparent;border-radius:12px;background:var(--cd-night-soft,#f6f6f6)!important;box-shadow:none;color:var(--bubble-text)!important;font-size:13px;line-height:1.5}
.messages-layout .conversation .chat-bubbles .bubble.me{--bubble-text:#fafaf8;--bubble-muted:#c6c5c1;--bubble-rule:#5a5d5f;align-self:flex-end;margin-left:auto;background:#373a3d!important;color:var(--bubble-text)!important;border-color:transparent}
.messages-layout .conversation .bubble p{margin:0;white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.55}
.messages-layout .conversation .chat-bubbles .bubble time{margin-top:8px;font-size:10px;font-weight:400;line-height:1.3;color:var(--bubble-muted);text-align:right}
.messages-layout .conversation .chat-bubbles .bubble .message-author{color:var(--bubble-muted)}
.messages-layout .conversation .chat-bubbles .bubble p{color:var(--bubble-text)}
.messages-layout .conversation .clinic-message-order{display:flex;align-items:center;justify-content:space-between;gap:16px;margin:0 0 10px;padding:0 0 8px;border-bottom:1px solid var(--bubble-rule)}
.messages-layout .conversation .clinic-message-order :is(button,a[data-order]){display:inline-flex;align-items:center;gap:6px;min-width:0;margin:0;padding:0;border:0;border-radius:4px;background:transparent;color:var(--bubble-muted);font:inherit;font-size:11px;font-weight:600;line-height:1.4;cursor:pointer}
.messages-layout .conversation .clinic-message-order :is(button,a[data-order]):first-child{flex:1;text-align:left}
.messages-layout .conversation .clinic-message-order :is(button,a[data-order]):first-child span{overflow-wrap:anywhere}
.messages-layout .conversation .clinic-message-order button:last-child{flex:0 0 28px;min-height:28px;justify-content:center}
.messages-layout .conversation .clinic-message-order svg{flex-shrink:0}
.messages-layout .conversation .clinic-message-order :is(button,a[data-order]):hover{color:var(--bubble-text);background:#88888818}
.messages-layout .conversation .bubble .chat-attachment{display:grid;grid-template-columns:36px minmax(0,1fr);gap:10px;align-items:center;width:100%;max-width:340px;margin:0;padding:10px;border:1px solid var(--chat-line);border-radius:8px;background:var(--cd-night-paper,#fff);color:var(--chat-ink);box-shadow:none;text-align:left}
.messages-layout .conversation .bubble p+.chat-attachment{margin-top:10px}
.messages-layout .conversation .chat-bubbles .bubble .chat-attachment{background:var(--cd-night-paper,#fff);border-color:var(--cd-night-edge,#e9e9e9);color:var(--cd-night-ink,#333)}
.messages-layout .conversation .chat-bubbles .bubble.me .chat-attachment{background:#474a4d;border-color:#5a5d5f;color:#fafaf8}
.messages-layout .conversation .chat-bubbles .bubble .chat-attachment strong{color:inherit}
.messages-layout .conversation .chat-bubbles .bubble .chat-attachment small{color:var(--bubble-muted)}
.messages-layout .conversation .chat-bubbles .bubble.me .chat-file-icon{background:#585b5d}
.messages-layout .conversation .chat-bubbles .bubble.me .chat-file-icon::before{filter:brightness(0) invert(.88)}
.messages-layout .conversation .chat-attachment>span:not(.chat-file-icon){min-width:0}
.messages-layout .conversation .chat-attachment strong{display:block;font-size:12px;font-weight:600;line-height:1.4;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.messages-layout .conversation .chat-attachment small{display:block;margin-top:3px;font-size:10px;line-height:1.4;color:var(--chat-muted)}
.messages-layout .conversation .chat-attachment img,.messages-layout .conversation .chat-file-icon{width:36px;height:40px;border-radius:6px;object-fit:cover;background:var(--cd-night-soft,#f5f5f5)}
.messages-layout .conversation .chat-file-icon{display:grid;place-items:center;font-size:0}
.messages-layout .conversation .chat-file-icon::before{content:'';width:20px;height:24px;background:center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 28' fill='none' stroke='%23777777' stroke-width='1.5' stroke-linejoin='round'%3E%3Cpath d='M5 2h9l5 5v19H5zM14 2v6h5M8 14h8M8 18h8M8 22h5'/%3E%3C/svg%3E")}
.messages-layout .conversation .chat-date-divider{flex:0 0 auto;line-height:1.5;margin:4px auto;padding:4px 10px;border:0;background:transparent;color:var(--chat-muted);font-size:10px;font-weight:500}
.messages-layout .conversation .chat-compose-files{display:grid;grid-template-columns:36px minmax(0,1fr) 36px;align-items:center;gap:8px;height:auto;min-height:56px;margin:0 16px 16px;padding:8px;border:1px solid var(--chat-line);border-radius:12px;background:var(--cd-night-paper,#fff)}
.messages-layout .conversation .chat-compose-files>.clinic-chat-order-context{grid-column:1/-1;display:flex;align-items:center;gap:12px;padding:8px 10px;background:var(--chat-surface);border:0;border-radius:7px}
.messages-layout .conversation .clinic-chat-order-context>div{display:flex;align-items:baseline;flex-wrap:wrap;gap:2px 6px;min-width:0;flex:1}
.messages-layout .conversation .clinic-chat-order-context span{color:var(--chat-muted);font-size:11px;line-height:1.4}
.messages-layout .conversation .clinic-chat-order-context strong{font-size:12px;line-height:1.4;overflow-wrap:anywhere}
.messages-layout .conversation .clinic-chat-order-context small{flex-basis:100%;font-size:11px;line-height:1.4;color:var(--chat-muted)}
.messages-layout .conversation .clinic-chat-order-context>button{flex:0 0 28px;width:28px;min-height:28px;padding:0;border:0;background:transparent;color:var(--cd-night-secondary,#666)}
.messages-layout .conversation .chat-compose-files>input{width:100%;min-width:0;min-height:36px;padding:0 8px;border:0;background:transparent;color:var(--chat-ink);font-size:13px;line-height:1.4}
.messages-layout .conversation .chat-compose-files>input::placeholder{color:var(--cd-night-secondary,#737373);opacity:1}
.messages-layout .conversation .chat-compose-files>.chat-attach-button{display:flex;align-items:center;justify-content:center;width:36px;height:36px;margin:0;padding:0;border:0;border-radius:8px;background:transparent;font-size:0;line-height:0;cursor:pointer}
.messages-layout .conversation .chat-attach-button::before{content:'';width:19px;height:19px;background:center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666666' stroke-width='1.7' stroke-linecap='round'%3E%3Cpath d='m8 12 6-6a3 3 0 0 1 4 4l-8 8a5 5 0 0 1-7-7l9-9M6 14l8-8'/%3E%3C/svg%3E")}
.messages-layout .conversation .chat-compose-files>.send-btn{display:flex;align-items:center;justify-content:center;width:36px;height:36px;margin:0;padding:0;border:0;border-radius:9px;background:#333;color:#fff;font-size:0;line-height:0}
.messages-layout .conversation .chat-attach-button::before,.messages-layout .conversation .send-btn::before{display:block;flex-shrink:0}
.messages-layout .conversation .send-btn::before{content:'';width:18px;height:18px;background:center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21 3-7 18-4-7-7-4 18-7ZM10 14 21 3'/%3E%3C/svg%3E")}
.messages-layout .conversation .chat-compose-files>.send-btn:hover{background:#505050}
.messages-layout .conversation .chat-compose-files>.send-btn:disabled{opacity:.45;cursor:wait}
.messages-layout .conversation button:focus-visible{outline:2px solid #777;outline-offset:2px}
.messages-layout .conversation .chat-compose-files:focus-within{border-color:var(--cd-night-edge,#aaa)}
.messages-layout .conversation .chat-compose-files>input:focus-visible{outline:none}
@media(max-width:760px){.messages-layout .conversation .chat-bubbles{padding:16px;gap:10px}.messages-layout .conversation .chat-bubbles .bubble{max-width:92%}.messages-layout .conversation .chat-compose-files{grid-template-columns:44px minmax(0,1fr) 44px;margin:0 8px 8px;padding:6px;gap:4px}.messages-layout .conversation .chat-compose-files>input{font-size:16px;min-height:44px}.messages-layout .conversation .chat-compose-files>.chat-attach-button,.messages-layout .conversation .chat-compose-files>.send-btn{width:44px;height:44px}.messages-layout .conversation .clinic-chat-order-context>button{flex-basis:36px;width:36px;min-height:36px}.messages-layout .conversation .clinic-message-order button:last-child{flex-basis:36px;min-height:36px}}

/* Clinic messages occupy one viewport; only the conversation log scrolls. */
html:has(.clinic-messages-layout),body:has(.clinic-messages-layout){height:100%;overflow:hidden!important;overscroll-behavior:none}
#app:has(.clinic-messages-layout){height:100dvh;min-height:0!important;overflow:hidden!important}
.shell:has(.clinic-messages-layout){height:100dvh;min-height:0!important;overflow:hidden!important;padding-bottom:20px}
.shell:has(.clinic-messages-layout)>.topbar{flex:0 0 auto}
.shell:has(.clinic-messages-layout)>main.content{
  display:flex;flex-direction:column;flex:1 1 0;min-height:0;overflow:hidden;padding-bottom:0;
}
.shell:has(.clinic-messages-layout)>main.content>.page-title{flex:0 0 auto}
.shell:has(.clinic-messages-layout)>.portal-footer{display:none}
.shell main.content>.clinic-messages-layout{
  flex:1 1 0;height:auto;min-height:0;max-height:none;overflow:hidden;
}
.shell .clinic-messages-layout>.contacts{min-height:0;overflow:hidden}
.shell .clinic-messages-layout>.conversation{display:flex;flex-direction:column;height:100%;min-height:0;overflow:hidden}
.shell .clinic-messages-layout .conversation-head{position:static;flex:0 0 auto}
.shell .clinic-messages-layout .chat-bubbles{
  flex:1 1 0;height:auto;min-height:0;max-height:none;overflow-x:hidden;overflow-y:auto;
  overscroll-behavior-y:contain;-webkit-overflow-scrolling:touch;
}
.shell .clinic-messages-layout .chat-compose{position:static;flex:0 0 auto}
@media ((max-width:900px) or ((pointer:coarse) and (hover:none) and (orientation:landscape) and (max-height:560px))){
  .shell:has(.clinic-messages-layout){padding-bottom:calc(76px + env(safe-area-inset-bottom))}
  .shell:has(.clinic-messages-layout)>main.content>.page-title{display:none}
}
@media (max-height:560px) and (orientation:landscape){
  .shell:has(.clinic-messages-layout){padding-bottom:calc(60px + env(safe-area-inset-bottom))}
}

/* The order reference is a real link with a phone-sized tap area. */
.messages-layout .conversation .clinic-message-order a[data-order]{min-height:44px;align-self:stretch;text-decoration:none;touch-action:manipulation}
