/* Iris embed widget — GLOBAL stylesheet (this app does not load the Blazor
   scoped-CSS bundle, so the widget styles must live here and be linked from
   App.razor). position:fixed + z-index are marked !important so the launcher
   and panel always overlay the page rather than rendering as a stretched
   flex child of the layout's .page container. */

/* Floating launcher */
.iris-fab {
    position: fixed !important;
    bottom: 20px;
    right: 20px;
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border: none;
    border-radius: 28px;
    background: #3B393F;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
    cursor: pointer;
    width: auto;
    height: auto;
}

.iris-fab:hover { background: #4a484f; }
.iris-fab-label { font-size: 14px; }

/* Panel */
.iris-panel {
    position: fixed !important;
    bottom: 20px;
    right: 20px;
    left: auto;
    top: auto;
    z-index: 1100;
    width: 420px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .3);
    overflow: hidden;
    font-size: 14px;
}

/* Drag-over cue: an inset accent ring shown while an image is dragged over the panel
   (toggled by iris-attach.js). Subtle — doesn't shift layout. */
.iris-panel.iris-drop-active {
    outline: 2px dashed #2563eb;
    outline-offset: -6px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .3), inset 0 0 0 9999px rgba(37, 99, 235, .06);
}

.iris-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: linear-gradient(135deg, #1f3a5f 0%, #0f2841 100%);
    color: #fff;
    cursor: move;
    touch-action: none; /* let touch-drag work instead of scrolling */
    user-select: none;
}

/* Title block: green status dot + a two-line "Iris" / tagline column. */
.iris-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.iris-status-dot {
    flex: none;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #22c55e;
}
.iris-title-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.iris-title-text strong { font-size: 14px; font-weight: 700; }
.iris-title-text small { font-size: 11px; opacity: .8; }

.iris-icon-btn {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    line-height: 1;
}

.iris-icon-btn:hover { background: rgba(0, 0, 0, .08); }
.iris-header .iris-icon-btn:hover { background: rgba(255, 255, 255, .15); }

/* Conversation */
.iris-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7f7f8;
}

.iris-msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.4;
}

.iris-assistant { align-self: flex-start; background: #fff; border: 1px solid #e5e5e5; }
.iris-user { align-self: flex-end; background: #3B393F; color: #fff; }
.iris-error { align-self: stretch; background: #fde8e8; color: #9b1c1c; border: 1px solid #f8b4b4; }

/* Drafts */
.iris-drafts { display: flex; flex-direction: column; gap: 8px; }
.iris-drafts-head { font-size: 12px; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: .03em; }

.iris-draft {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-left: 3px solid #9ca3af;
    border-radius: 8px;
    padding: 8px 10px;
}

.iris-draft.is-incident { border-left-color: #dc2626; }
.iris-draft.is-request { border-left-color: #2563eb; }

.iris-draft-top { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.iris-draft-del { margin-left: auto; color: #9ca3af; }
.iris-draft-del:hover { color: #dc2626; }

.iris-chip {
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    background: #eef2ff;
    color: #3730a3;
    text-transform: capitalize;
}

.iris-chip-urgency { background: #fef3c7; color: #92400e; }
.iris-draft-title { font-weight: 600; }
.iris-draft-body { color: #4b5563; margin-top: 2px; }
.iris-draft-missing { margin-top: 4px; font-size: 12px; color: #b45309; }
.iris-draft-linked { margin-top: 4px; font-size: 12px; color: #047857; font-weight: 600; }

/* Status + done */
.iris-status { color: #6b7280; font-style: italic; align-self: flex-start; }
.iris-dots { display: inline-flex; gap: 3px; }
.iris-dots i { width: 5px; height: 5px; border-radius: 50%; background: #9ca3af; animation: iris-blink 1.2s infinite both; }
.iris-dots i:nth-child(2) { animation-delay: .2s; }
.iris-dots i:nth-child(3) { animation-delay: .4s; }

@keyframes iris-blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

.iris-done {
    align-self: stretch;
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    padding: 10px 12px;
    border-radius: 8px;
    font-weight: 600;
}

/* Submit */
.iris-submit {
    margin: 0 14px 8px;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: #047857;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.iris-submit:hover { background: #065f46; }
.iris-submit:disabled { opacity: .6; cursor: default; }

/* Input row */
.iris-input {
    display: flex;
    align-items: flex-end;   /* keep the icons + send bottom-aligned as the textarea grows */
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid #e5e5e5;
    background: #fff;
}

.iris-text {
    flex: 1;
    box-sizing: border-box;
    border: 1px solid #d1d5db;
    border-radius: 18px;
    padding: 8px 14px;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    resize: none;
    /* Word-wraps and auto-grows with the message (Chromium 123+ field-sizing); the
       rows="1" baseline + max-height internal scroll is the fallback elsewhere. */
    field-sizing: content;
    min-height: 38px;
    max-height: 120px;
    overflow-y: auto;
}

.iris-text:focus { border-color: #3B393F; }

/* Send — a light rounded-square action button (soft blue with an indigo paper-plane). */
.iris-send {
    width: 38px;
    height: 38px;
    box-sizing: border-box;
    border-radius: 10px;
    border: none;
    color: #4f46e5;
    background: #c7d2fe;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    transition: background-color .12s;
}

.iris-send:hover { background: #b4c0fc; }
.iris-send:disabled { opacity: .5; cursor: default; }

/* Mic is a rounded-square icon-button like its image/doc/screenshot neighbours (see
   .iris-input .iris-icon-btn). While recording it turns red and gently pulses — the
   red background overrides the default light container so the active state is obvious. */
.iris-input .iris-icon-btn.iris-mic.listening { color: #dc2626; background: #fee2e2; animation: iris-pulse 1.2s ease-in-out infinite; }
.iris-input .iris-icon-btn.iris-mic.listening:hover { color: #dc2626; background: #fecaca; }

@keyframes iris-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }

/* Header actions (speaker toggle + close) */
.iris-header-actions { display: flex; align-items: center; gap: 2px; }
.iris-header .iris-icon-btn.active { background: rgba(255, 255, 255, .22); }

/* Footer wraps submit / new-chat / pending chips / input row */
.iris-footer { background: #fff; }

/* Draft edit-in-place */
.iris-draft-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.iris-link-btn { background: transparent; border: none; color: #2563eb; cursor: pointer; font-size: 12px; padding: 2px 4px; }
.iris-link-btn:hover { text-decoration: underline; }
.iris-edit-title, .iris-edit-body {
    width: 100%;
    margin: 4px 0 0;
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
}
.iris-edit-body { resize: vertical; }

/* Start a new conversation */
.iris-new-chat {
    margin: 0 14px 10px;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    color: #3B393F;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.iris-new-chat:hover { background: #f3f4f6; }

/* Pending attachments + vision images */
.iris-pending { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.iris-pending-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    background: #eef2ff;
    color: #3730a3;
    border-radius: 12px;
    padding: 3px 8px;
}
.iris-pending-img { background: #ecfeff; color: #155e75; }
.iris-pending-x { background: transparent; border: none; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }
.iris-chip-linked { background: #ecfdf5; color: #047857; }

/* Mic / image / document / screenshot affordances — one uniform set of rounded-square
   light icon-buttons so the input row reads as a consistent toolbar. */
.iris-input .iris-icon-btn {
    flex: none;
    box-sizing: border-box;
    width: 38px;
    height: 38px;
    padding: 0;              /* override the base .iris-icon-btn 4px so the glyph has the full box and doesn't overflow */
    border-radius: 10px;
    color: #475569;
    background: #f1f5f9;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;        /* belt-and-braces: keep any wide glyph contained instead of bleeding under the textarea */
    transition: background-color .12s, color .12s;
}
/* Constrain the Open Iconic glyph so wider icons (e.g. oi-aperture) fit centred in the
   box rather than overflowing the right edge (the cause of the clipped screenshot icon). */
.iris-input .iris-icon-btn .oi { font-size: 16px; line-height: 1; }
.iris-input .iris-icon-btn:hover { color: #475569; background: #e2e8f0; }
.iris-input .iris-icon-btn:disabled { opacity: .45; cursor: default; }
.iris-file-hidden { display: none; }

/* Resize grip — BOTTOM-RIGHT corner (guide §8.4). The panel is left/top anchored
   once positionPanel runs, so dragging this grip grows the panel naturally to the
   right and down. A diagonal-hatch affordance (matching the guide) makes the corner
   read as a draggable resize handle. touch-action:none so touch-drag resizes rather
   than scrolling. */
.iris-resize-grip {
    position: absolute;
    right: 1px;
    bottom: 1px;
    width: 18px;
    height: 18px;
    z-index: 5;
    cursor: nwse-resize;
    opacity: 0.5;
    touch-action: none;
    border-bottom-right-radius: 12px;
    background:
        linear-gradient(135deg, transparent 0 50%, #9CA3AF 50% 56%, transparent 56% 68%, #9CA3AF 68% 74%, transparent 74% 86%, #9CA3AF 86% 92%, transparent 92%);
}
.iris-resize-grip:hover { opacity: 0.9; }

/* While dragging or resizing (class toggled by iris-drag.js): suppress text
   selection and snap-transitions so the move/resize tracks the pointer cleanly. */
.iris-dragging { user-select: none; transition: none !important; }

/* Rendered GFM markdown (assistant replies + draft bodies). Tighten the default
   block margins so the content sits naturally inside a chat bubble. */
.iris-md { white-space: normal; }
.iris-md > :first-child { margin-top: 0; }
.iris-md > :last-child { margin-bottom: 0; }
.iris-md p { margin: 0 0 8px; }
.iris-md ul, .iris-md ol { margin: 0 0 8px; padding-left: 20px; }
.iris-md li { margin: 2px 0; }
.iris-md h1, .iris-md h2, .iris-md h3, .iris-md h4 { margin: 8px 0 4px; font-size: 1em; font-weight: 700; }
.iris-md a { color: #2563eb; text-decoration: underline; }
.iris-md code { background: rgba(0, 0, 0, .06); padding: 1px 4px; border-radius: 4px; font-size: .9em; }
.iris-md pre { background: rgba(0, 0, 0, .06); padding: 8px 10px; border-radius: 6px; overflow-x: auto; }
.iris-md pre code { background: transparent; padding: 0; }
.iris-md blockquote { margin: 0 0 8px; padding-left: 10px; border-left: 3px solid #d1d5db; color: #4b5563; }
.iris-md table { border-collapse: collapse; margin: 0 0 8px; font-size: .95em; }
.iris-md th, .iris-md td { border: 1px solid #e5e5e5; padding: 4px 8px; text-align: left; }

/* Mobile: take over the whole screen so the small panel doesn't get cramped.
   The drag/resize script (iris-drag.js) no-ops at this width, so inline geometry
   styles aren't applied to fight these rules. */
@media (max-width: 480px) {
    .iris-panel {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-width: 100vw !important;
        max-height: 100dvh !important;
        border-radius: 0;
    }

    /* No resize on phones — the panel is already full-screen. */
    .iris-resize-grip { display: none; }
}
