/* =========================================================================
   NIZU Chat — iOS "Liquid Glass" (2026) skin
   -------------------------------------------------------------------------
   A non-destructive restyle of the Team Messenger widget (.rise-chat-wrapper)
   into a translucent, frosted-glass mobile-app aesthetic. Loaded AFTER
   app.all.css / custom-style.css so it overrides the base chat styles; it
   changes visuals only and keeps every existing class / JS hook intact.

   Structure it themes (unchanged markup):
     .rise-chat-wrapper  → floating glass panel
       .rise-chat-header → frosted top bar + control chips
       .rise-chat-body   → scrollable message area
         .chat-row.chat-me / .chat-other > .chat-msg  → glass bubbles
       .rise-chat-footer → floating glass composer (textarea + send/attach)
     .init-chat-icon     → glass launcher bubble
   ========================================================================= */

:root {
    /* Liquid-glass design tokens (light) */
    /* --- frosted "smoked glass": a faint cool tint so the pane reads as glass even over
       the white app (pure-white translucency is invisible over white), plus a deep blur.
       ROLLBACK to the airy white: --lg-panel-bg: rgba(255,255,255,0.62); blur(30px). */
    --lg-panel-bg:        rgba(226, 232, 241, 0.22);   /* near-clear glass — very see-through */
    --lg-panel-blur:      saturate(180%) blur(40px);   /* deep background blur keeps it frosted */
    --lg-bar-bg:          rgba(255, 255, 255, 0.55);
    --lg-hairline:        rgba(255, 255, 255, 0.55);
    --lg-edge-hi:         rgba(255, 255, 255, 0.65);   /* specular top highlight */
    --lg-panel-shadow:    0 20px 60px rgba(17, 24, 39, 0.22), 0 2px 10px rgba(17, 24, 39, 0.10);
    --lg-chip-bg:         rgba(255, 255, 255, 0.5);
    --lg-chip-brd:        rgba(255, 255, 255, 0.6);

    --lg-bubble-in-bg:    rgba(120, 120, 128, 0.14);
    --lg-bubble-in-text:  #1c1c1e;
    --lg-blue-1:          #3aa0ff;
    --lg-blue-2:          #0a84ff;
    --lg-blue-3:          #0a6cf0;

    --lg-text:            #1c1c1e;
    --lg-text-soft:       #6b7280;
    --lg-radius:          26px;
    --lg-field-bg:        rgba(255, 255, 255, 0.55);
    --lg-field-brd:       rgba(60, 60, 67, 0.14);
}

/* -------------------------------------------------------------------------
   Panel
   ------------------------------------------------------------------------- */
.rise-chat-wrapper:not(.rise-cart-wrapper) {
    background: var(--lg-panel-bg) !important;
    -webkit-backdrop-filter: var(--lg-panel-blur);
    backdrop-filter: var(--lg-panel-blur);
    border: 1px solid var(--lg-hairline);
    border-radius: var(--lg-radius);
    box-shadow: var(--lg-panel-shadow);
    overflow: hidden;                       /* clip children to the rounded panel */
    color: var(--lg-text);
}
.rise-chat-wrapper:not(.rise-cart-wrapper).full-screen {
    border-radius: 0;
    border: none;
}

/* -------------------------------------------------------------------------
   Header — frosted bar with a hairline and floating control chips
   ------------------------------------------------------------------------- */
.rise-chat-wrapper .rise-chat-header,
.rise-chat-wrapper .chat-topbar {
    background: var(--lg-bar-bg);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(60, 60, 67, 0.10) !important;
    box-shadow: inset 0 1px 0 var(--lg-edge-hi);
    height: 60px;
}
.chat-title {
    font-weight: 600;
    letter-spacing: 0.2px;
    color: var(--lg-text);
}
.chat-title .avatar img {
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

/* Control chips (back / more / close / full-screen) — circular glass buttons */
.rise-chat-wrapper .rise-chat-header .chat-topbar-btn,
.rise-chat-wrapper .chat-topbar .chat-topbar-btn {
    width: 34px;
    height: 34px;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--lg-chip-bg);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--lg-chip-brd);
    box-shadow: 0 2px 6px rgba(17, 24, 39, 0.10), inset 0 1px 0 var(--lg-edge-hi);
    color: var(--lg-text);
    opacity: 1;
    transition: transform 0.15s ease, background 0.15s ease;
}
.rise-chat-wrapper .rise-chat-header .chat-topbar-btn:hover,
.rise-chat-wrapper .chat-topbar .chat-topbar-btn:hover {
    transform: scale(1.06);
    background: rgba(255, 255, 255, 0.75);
    opacity: 1;
}
.rise-chat-wrapper .rise-chat-header .chat-topbar-btn.chat-back { left: 12px; }
.rise-chat-wrapper .rise-chat-header .chat-topbar-btn.chat-close { right: 12px; }
.rise-chat-wrapper .rise-chat-header .chat-topbar-btn.more-options { right: 54px; }
.rise-chat-wrapper .rise-chat-header .chat-topbar-btn svg { width: 18px; height: 18px; }
.rise-chat-wrapper .rise-chat-header .chat-topbar-btn i { font-size: 17px; line-height: 1; }

/* Inbox / tabs list rows */
.rise-chat-wrapper .message-row {
    border-bottom: 1px solid rgba(60, 60, 67, 0.08) !important;
    border-radius: 14px;
    transition: background 0.15s ease;
}
.rise-chat-wrapper .message-row:hover {
    background: rgba(120, 120, 128, 0.10) !important;
}

/* -------------------------------------------------------------------------
   Message area
   ------------------------------------------------------------------------- */
.rise-chat-body {
    background: transparent;
    scroll-behavior: smooth;
}
#js-chat-messages-container { padding: 6px 6px 4px; }

/* Slim, unobtrusive scrollbar */
.rise-chat-body::-webkit-scrollbar { width: 7px; }
.rise-chat-body::-webkit-scrollbar-thumb {
    background: rgba(60, 60, 67, 0.22);
    border-radius: 10px;
}
.rise-chat-body::-webkit-scrollbar-track { background: transparent; }

/* Date separator ("Today" / "1 July" / "31 December 2025") between day groups */
.rise-chat-wrapper .chat-date-separator {
    display: flex;
    justify-content: center;
    margin: 14px 0 8px;
}
.rise-chat-wrapper .chat-date-separator span {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: var(--lg-text-soft);
    background: var(--lg-chip-bg);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid var(--lg-chip-brd);
    padding: 3px 12px;
    border-radius: 12px;
    box-shadow: inset 0 1px 0 var(--lg-edge-hi);
}

/* Per-message time (hour:minute) under each bubble */
.rise-chat-wrapper .chat-time {
    font-size: 10.5px;
    line-height: 1;
    color: var(--lg-text-soft);
    margin: 2px 4px 3px;
    opacity: 0.85;
}
.rise-chat-wrapper .chat-me .chat-time { text-align: right; }
.rise-chat-wrapper .chat-other .chat-time { text-align: left; padding-left: 40px; }

/* -------------------------------------------------------------------------
   Bubbles — frosted glass, iMessage grouping preserved
   ------------------------------------------------------------------------- */
.chat-msg {
    padding: 9px 13px;
    line-height: 1.35;
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.18);
    transition: transform 0.12s ease;
}

/* Received — light frosted glass */
.chat-other .chat-msg {
    background: var(--lg-bubble-in-bg) !important;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    color: var(--lg-bubble-in-text) !important;
    border: 1px solid rgba(255, 255, 255, 0.35);
}
.chat-other .avatar img { border-radius: 50%; }

/* Sent — glossy iOS-blue glass */
.chat-me .chat-msg {
    background: linear-gradient(180deg, var(--lg-blue-1) 0%, var(--lg-blue-2) 48%, var(--lg-blue-3) 100%) !important;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: 0 3px 12px rgba(10, 132, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.chat-me .chat-msg a { color: #fff; text-decoration: underline; }

/* Marvin / rich replies keep readable spacing inside the glass */
.chat-msg .marvin-md { display: block; }

/* -------------------------------------------------------------------------
   Composer — a floating frosted bar with a pill field + round send button
   ------------------------------------------------------------------------- */
.rise-chat-footer {
    background: var(--lg-bar-bg) !important;
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    backdrop-filter: saturate(180%) blur(24px);
    border-top: 1px solid rgba(60, 60, 67, 0.10) !important;
    box-shadow: inset 0 1px 0 var(--lg-edge-hi);
    border-radius: 0;
    padding: 0 !important;                 /* the form fills the footer edge-to-edge */
}
/* The reply form occupies the whole footer; only the form carries a 3px inset. */
.rise-chat-footer #chat-reply-form-dropzone {
    padding: 0;
    margin: 0;
    width: 100%;
}
.rise-chat-footer #chat-message-reply-form {
    margin: 0;
    padding: 3px;
    /* keep the mobile safe-area clear without dropping below the 3px minimum */
    padding-bottom: calc(3px + env(safe-area-inset-bottom, 0px));
}

/* Text field as a rounded translucent pill */
.rise-chat-footer .chat-message-textarea {
    background: var(--lg-field-bg);
    border: 1px solid var(--lg-field-brd);
    border-radius: 20px;
    box-shadow: inset 0 1px 2px rgba(17, 24, 39, 0.05);
    padding: 2px 6px;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}
.rise-chat-footer textarea {
    background: transparent !important;
    color: var(--lg-text) !important;
    padding: 10px 12px;
    height: 44px;
    font-size: 15px;
}
.rise-chat-footer textarea::placeholder { color: var(--lg-text-soft); }

/* Button row: attach + mic on the left, send on the right — all glass chips */
.rise-chat-footer .chat-button-section { padding: 6px 2px 0; }
.rise-chat-footer .chat-file-upload-icon .upload-file-button,
.rise-chat-footer .chat-button-section .upload-file-button,
.rise-chat-footer .record-start-btn,
.rise-chat-footer .record-end-btn {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
    background: var(--lg-chip-bg) !important;
    border: 1px solid var(--lg-chip-brd) !important;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: inset 0 1px 0 var(--lg-edge-hi);
    color: var(--lg-text) !important;
    transition: transform 0.15s ease;
}
.rise-chat-footer .chat-file-upload-icon .upload-file-button:hover,
.rise-chat-footer .record-start-btn:hover { transform: scale(1.06); }
.rise-chat-footer .upload-file-button i,
.rise-chat-footer .record-start-btn i,
.rise-chat-footer .record-end-btn i { font-size: 16px; line-height: 1; }
.rise-chat-footer .upload-file-button .hidden-xs { display: none; }  /* icon-only chip */

.rise-chat-footer .message-send-button {
    width: 40px;
    height: 40px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    border-radius: 50% !important;
    background: linear-gradient(180deg, var(--lg-blue-1), var(--lg-blue-3)) !important;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 4px 14px rgba(10, 132, 255, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.45) !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.rise-chat-footer .message-send-button:hover {
    transform: scale(1.07);
    box-shadow: 0 6px 18px rgba(10, 132, 255, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.5) !important;
}
.rise-chat-footer .message-send-button svg { width: 18px; height: 18px; color: #fff; }
.rise-chat-footer .message-send-button i { font-size: 17px; line-height: 1; color: #fff; }

/* Typing indicator / reply indicator subtle */
#js-chat-reply-indicator { padding: 0 12px; color: var(--lg-text-soft); }

/* -------------------------------------------------------------------------
   Launcher bubble
   ------------------------------------------------------------------------- */
.init-chat-icon {
    background: rgba(255, 255, 255, 0.6) !important;
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    border: 1px solid var(--lg-chip-brd);
    box-shadow: 0 10px 26px rgba(17, 24, 39, 0.22), inset 0 1px 0 var(--lg-edge-hi) !important;
    color: var(--lg-text);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.init-chat-icon:hover { transform: translateY(-2px) scale(1.04); }
.init-chat-icon.has-message {
    background: linear-gradient(180deg, #ff5f6d, #f5325c) !important;
    color: #fff !important;
    border-color: rgba(255, 255, 255, 0.4);
}

/* -------------------------------------------------------------------------
   Mobile — full-screen glass sheet with safe-area padding
   ------------------------------------------------------------------------- */
@media (max-width: 767px) {
    .rise-chat-wrapper:not(.rise-cart-wrapper) {
        border-radius: 0;
        border: none;
    }
    .rise-chat-wrapper .rise-chat-header,
    .rise-chat-wrapper .chat-topbar {
        padding-top: env(safe-area-inset-top, 0px);
        height: calc(60px + env(safe-area-inset-top, 0px));
    }
}

/* -------------------------------------------------------------------------
   Dark theme (body.color-1E202D) — dark liquid glass
   ------------------------------------------------------------------------- */
body.color-1E202D {
    --lg-panel-bg:       rgba(28, 32, 45, 0.26);   /* near-clear glass (ROLLBACK: 0.66) */
    --lg-bar-bg:         rgba(28, 32, 45, 0.6);
    --lg-hairline:       rgba(255, 255, 255, 0.12);
    --lg-edge-hi:        rgba(255, 255, 255, 0.14);
    --lg-panel-shadow:   0 24px 60px rgba(0, 0, 0, 0.55), 0 2px 10px rgba(0, 0, 0, 0.4);
    --lg-chip-bg:        rgba(255, 255, 255, 0.10);
    --lg-chip-brd:       rgba(255, 255, 255, 0.16);
    --lg-bubble-in-bg:   rgba(255, 255, 255, 0.10);
    --lg-bubble-in-text: #e9eaf0;
    --lg-text:           #e9eaf0;
    --lg-text-soft:      #9aa0b4;
    --lg-field-bg:       rgba(255, 255, 255, 0.08);
    --lg-field-brd:      rgba(255, 255, 255, 0.14);
}
body.color-1E202D .rise-chat-wrapper .rise-chat-header,
body.color-1E202D .rise-chat-wrapper .chat-topbar,
body.color-1E202D .rise-chat-footer {
    border-color: rgba(255, 255, 255, 0.08) !important;
}
body.color-1E202D .chat-other .chat-msg { border-color: rgba(255, 255, 255, 0.12); }
body.color-1E202D .init-chat-icon { background: rgba(40, 45, 60, 0.7) !important; }

/* -------------------------------------------------------------------------
   Motion preferences
   ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .rise-chat-wrapper,
    .init-chat-icon,
    .rise-chat-footer .message-send-button,
    .rise-chat-wrapper .chat-topbar-btn { transition: none !important; animation: none !important; }
}
