/* ═══════════════════════════════════════════════════════
   Shared assistant chat styles
   Used by both AssistantChatWindow (float widget) and
   AssistantChatPanel (embedded page component)
   ═══════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════
   Floating widget (AssistantChatWindow)
   ══════════════════════════════════════════════════════ */

/* ── Floating widget shell ── */
.assistant-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

/* ── Slide-up panel ── */
.assistant-chat-panel {
    display: none;
    flex-direction: column;
    width: 380px;
    height: 560px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.assistant-chat-panel--open {
    display: flex;
    animation: chat-panel-open 0.22s ease forwards;
}

@keyframes chat-panel-open {
    from { opacity: 0; transform: scale(0.96) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Toggle button ── */
.assistant-toggle-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease;
    flex-shrink: 0;
    padding: 0;
    overflow: visible;
}

.assistant-toggle-btn:hover {
    transform: scale(1.08);
}

.assistant-toggle-btn:hover img {
    animation-play-state: paused;
}

.assistant-toggle-btn i {
    line-height: 1;
    background: #FF7536;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(255, 117, 54, 0.45);
}

@keyframes octo-float {
    0%   { transform: translateY(0); }
    50%  { transform: translateY(-5px); }
    100% { transform: translateY(0); }
}

.assistant-toggle-btn img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    display: block;
    animation: octo-float 2.4s ease-in-out infinite;
}

/* ── Resize handle ── */
.assistant-resize-handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 18px;
    height: 18px;
    cursor: nw-resize;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s;
}

.assistant-resize-handle::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 10px;
    height: 10px;
    border-top: 2px solid #A3A3A3;
    border-left: 2px solid #A3A3A3;
    border-radius: 2px 0 0 0;
}

.assistant-chat-panel--open:hover .assistant-resize-handle {
    opacity: 1;
}

/* ── Reset size button ── */
.reset-size-btn {
    color: #A3A3A3;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    user-select: none;
}

.reset-size-btn:hover {
    color: #FF7536;
    background: rgba(255, 117, 54, 0.08);
}

/* ── Google Drive toggle button in status bar ── */
.gdrive-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: #888;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    position: relative;
}

.gdrive-toggle:hover {
    color: #1a73e8;
    background: #e8f0fe;
}

.gdrive-toggle--active {
    color: #1a73e8;
    background: #e8f0fe;
}

.gdrive-toggle i {
    font-size: 14px;
}

.gdrive-toggle__badge {
    background: #1a73e8;
    color: #fff;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    padding: 0 5px;
    min-width: 16px;
    text-align: center;
    line-height: 16px;
}

/* ── Google Drive panel overlay ── */
.gdrive-panel-container {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #FAF8FA;
    z-index: 20;
    border-radius: 16px;
    flex-direction: column;
    overflow: hidden;
}

.gdrive-panel-container--open {
    display: flex;
    animation: gdrive-panel-open 0.2s ease forwards;
}

@keyframes gdrive-panel-open {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.gdrive-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
    font-weight: 600;
    font-size: 14px;
    color: #1a73e8;
    flex-shrink: 0;
}

.gdrive-panel-header i {
    font-size: 18px;
}

.gdrive-panel-header span {
    flex: 1;
}

.gdrive-panel-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
}

.gdrive-panel-close:hover {
    color: #d93025;
    background: #fce8e6;
}

.gdrive-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.gdrive-panel-body::-webkit-scrollbar {
    width: 3px;
}

.gdrive-panel-body::-webkit-scrollbar-thumb {
    background: #1a73e8;
    border-radius: 3px;
}

/* ── Drive attached strip variant ── */
.chat__attached-strip--drive {
    background: #e8f0fe;
    color: #1a73e8;
}

/* ── Error bubble ── */
.assistant-error {
    color: #c0392b;
    font-size: 12px;
}

/* ── Disconnected / empty state ── */
.assistant-disconnected-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 8px;
    padding: 20px 0;
}

.assistant-disconnected-img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    opacity: 0.9;
}

.assistant-disconnected-label {
    font-size: 13px;
    color: #999;
    font-weight: 500;
}

/* ── Chat container (inner shell) ── */
.assistant-chat-container {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    background: #FAF8FA;
    border-radius: 16px;
    padding: 16px;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* ── Markdown content inside assistant bubbles ── */
.assistant-markdown {
    font-size: 14px;
    line-height: 1.6;
    color: #2B3036;
}

.assistant-markdown p {
    margin: 0 0 6px 0;
}

.assistant-markdown > p:last-child,
.assistant-markdown p:last-of-type {
    margin-bottom: 0;
}

.assistant-markdown strong { font-weight: 600; }
.assistant-markdown em     { font-style: italic; }

.assistant-markdown ul,
.assistant-markdown ol {
    margin: 6px 0 8px 0;
    padding-left: 20px;
}

.assistant-markdown li {
    margin-bottom: 4px;
}

.assistant-markdown h1,
.assistant-markdown h2,
.assistant-markdown h3,
.assistant-markdown h4 {
    font-weight: 600;
    margin: 10px 0 6px 0;
    line-height: 1.3;
}

.assistant-markdown h1 { font-size: 18px; }
.assistant-markdown h2 { font-size: 16px; }
.assistant-markdown h3 { font-size: 15px; }

.assistant-markdown code {
    background: rgba(0,0,0,0.06);
    border-radius: 4px;
    padding: 1px 5px;
    font-family: monospace;
    font-size: 13px;
}

.assistant-markdown pre {
    background: rgba(0,0,0,0.06);
    border-radius: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    margin: 8px 0;
}

.assistant-markdown pre code {
    background: none;
    padding: 0;
    font-size: 13px;
}

.assistant-markdown blockquote {
    border-left: 3px solid #FF7536;
    margin: 8px 0;
    padding: 4px 12px;
    color: #666;
}

.assistant-markdown a {
    color: #FF7536;
    text-decoration: underline;
}

.assistant-markdown hr {
    border: none;
    border-top: 1px solid #EDEDF5;
    margin: 10px 0;
}

/* ── Messages area ── */
.assistant-messages-area {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 10px;
    margin-bottom: 4px;
}

.assistant-messages-area::-webkit-scrollbar       { width: 3px; }
.assistant-messages-area::-webkit-scrollbar-track { background: #fff; }
.assistant-messages-area::-webkit-scrollbar-thumb { background: #FF7536; border-radius: 3px; }

/* ── Message bubbles ── */
.message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
}

.message-text {
    border-radius: 16px;
    padding: 6px 4px;
    max-width: 100%;
    width: 100%;
    display: block;
    font-weight: 400;
    font-size: 14px;
    line-height: 150%;
    color: #2B3036;
    word-break: break-word;
    box-sizing: border-box;
}

.message-time {
    font-weight: 600;
    font-size: 10px;
    line-height: 14px;
    letter-spacing: 0.02em;
    color: #A3A3A3;
    padding: 4px 6px;
}

.message-right {
    align-items: flex-end;
}

.message-right .message-text {
    color: #fff;
    background: #FF7536;
    max-width: 72%;
    width: auto;
    display: inline-block;
    padding: 10px 16px;
    box-shadow: 0px 4px 12px rgba(255, 117, 54, 0.25);
}

/* ── Typing indicator ── */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    height: 20px;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    background: #A3A3A3;
    border-radius: 50%;
    animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40%            { transform: scale(1);   opacity: 1; }
}

/* ── Status bar ── */
.assistant-status-bar {
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.status { display: flex; align-items: center; gap: 5px; }
.status.connected    { color: #3cb371; }
.status.connecting   { color: #FF7536; }
.status.disconnected { color: #A3A3A3; }

.assistant-disconnected-state .reconnect-link {
    margin-left: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}

.assistant-disconnected-state .reconnect-link:hover {
    opacity: 0.75;
}

.reconnect-link {
    color: #FF7536;
    cursor: pointer;
    text-decoration: underline;
    margin-left: 6px;
}

.new-chat-link {
    color: #7B68EE;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.new-chat-link:hover {
    text-decoration: underline;
}

/* ── Input area ── */
.chat__input__container {
    background: #FFFFFF;
    box-shadow: 0px 2px 4px rgba(237, 237, 245, 0.5);
    border-radius: 7px;
    display: flex;
    flex-direction: column;
    padding: 8px 8px;
    gap: 4px;
}

.chat__attached-strip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 6px;
    background: #e8f0fe;
    color: #1a73e8;
    font-size: 12px;
    font-weight: 500;
    animation: strip-slide-in 0.18s ease forwards;
}

@keyframes strip-slide-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat__attached-strip i {
    font-size: 14px;
    flex-shrink: 0;
}

.chat__input {
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    font-size: 14px;
    background: transparent;
}

.send__message__button {
    width: 33px;
    height: 33px;
    background: var(--color-orange, #FF7536);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.send__message__button i {
    margin-top: 3px;
}

.send__message__button.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ── Save prompt button ── */
.msg-save-prompt-btn {
    cursor: pointer;
    color: #C0C0C0;
    font-size: 12px;
    margin-left: 4px;
    vertical-align: middle;
    transition: color 0.15s;
}

.msg-save-prompt-btn:hover  { color: #FF7536; }
.msg-save-prompt-btn--saved { color: #FF7536; }

/* ── Saved prompts panel ── */
.saved-prompts-panel {
    background: #FFFFFF;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.10);
    border: 1px solid #EDEDF5;
    overflow-y: auto;
    max-height: 180px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    animation: prompts-fade-in 0.15s ease;
}

@keyframes prompts-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.saved-prompts-empty {
    font-size: 12px;
    color: #A3A3A3;
    text-align: center;
    padding: 8px 0;
}

.saved-prompt-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.15s;
}

.saved-prompt-item:hover {
    background: rgba(255, 117, 54, 0.07);
}

.saved-prompt-text {
    flex: 1;
    font-size: 13px;
    color: #2B3036;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saved-prompt-delete {
    flex-shrink: 0;
    color: #C0C0C0;
    font-size: 14px;
    line-height: 1;
    padding: 2px 3px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.saved-prompt-delete:hover {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.08);
}

/* ── Saved prompts toggle in status bar ── */
.saved-prompts-toggle {
    color: #A3A3A3;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 14px;
    padding: 2px 5px;
    border-radius: 8px;
    transition: color 0.2s, background 0.2s;
    user-select: none;
    position: relative;
}

.saved-prompts-toggle:hover         { color: #FF7536; background: rgba(255,117,54,0.08); }
.saved-prompts-toggle--active       { color: #FF7536; background: rgba(255,117,54,0.10); }

.saved-prompts-badge {
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: #FF7536;
    border-radius: 8px;
    padding: 0 5px;
    line-height: 16px;
    min-width: 16px;
    text-align: center;
}

/* ── Thinking toggle ── */
.thinking-toggle {
    color: #A3A3A3;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 10px;
    transition: color 0.2s, background 0.2s;
    user-select: none;
}

.thinking-toggle:hover   { color: #7B68EE; background: rgba(123,104,238,0.08); }
.thinking-toggle--active { color: #7B68EE; background: rgba(123,104,238,0.12); font-weight: 600; }

/* ── Thinking block message bubble ── */
.message-thinking .message-text {
    background: rgba(123, 104, 238, 0.07);
    border: 1px solid rgba(123, 104, 238, 0.2);
    max-width: 90%;
    padding: 8px 12px;
}

.thinking-block__header {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: #7B68EE;
    user-select: none;
}

.thinking-block__header:hover { opacity: 0.8; }

.thinking-block__body {
    margin-top: 8px;
    font-size: 12px;
    color: #666;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
    border-top: 1px solid rgba(123, 104, 238, 0.2);
    padding-top: 8px;
}

/* ── Token usage badge ── */
.message-tokens {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: 6px;
    font-size: 10px;
    font-weight: 600;
    color: #A3A3A3;
    opacity: 0.8;
}

.message-tokens i {
    font-size: 11px;
}

/* ── Pending approval ── */
.pending-approval {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pending-approval__desc {
    font-size: 13px;
    color: #2B3036;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.pending-approval__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pending-approval__btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 8px;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
}

.pending-approval__btn:active {
    transform: scale(0.97);
}

.pending-approval__btn--confirm {
    background: #22c55e;
    color: #fff;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

.pending-approval__btn--confirm:hover {
    opacity: 0.88;
}

.pending-approval__btn--cancel {
    background: #f1f1f1;
    color: #555;
}

.pending-approval__btn--cancel:hover {
    background: #e5e5e5;
}

.pending-approval__resolved {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    color: #22c55e;
}

/* ── Chat input row layout ── */
.chat__input__row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 6px;
}

.chat__input__row .chat__input {
    flex: 1;
    min-width: 0;
}

.chat__input__row-spacer {
    flex: 1;
}

.chat__textarea-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── Attach (+) button ── */
.chat__attach-btn-wrap {
    position: relative;
    flex-shrink: 0;
}

.chat__attach-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid #ddd;
    background: transparent;
    cursor: pointer;
    color: #666;
    font-size: 1.2rem;
    transition: background 0.15s, color 0.15s;
}

.chat__attach-btn:hover {
    background: #FF753621;
    color: #ff6a00;
    border-color: #FF7536;
}

.chat__attach-btn:active {
    background: #FF7536;
    color: #fff;
    border-color: #FF7536;
}

/* ── Send + mode wrap ── */
.chat__send-wrap {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.chat__mode-btn-wrap {
    position: relative;
}

.chat__mode-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 7px 10px;
    border-radius: 20px;
    border: 1.5px solid #ddd;
    background: transparent;
    cursor: pointer;
    color: #555;
    font-size: 0.82rem;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    height: 34px;
}

.chat__mode-toggle:hover:not(:disabled) {
    background: #FF753621;
    color: #ff6a00;
    border-color: #FF7536;
}

.chat__mode-toggle:active:not(:disabled) {
    background: #FF7536;
    color: #fff;
    border-color: #FF7536;
}

.chat__mode-toggle:active:not(:disabled) i {
    color: #fff;
}

.chat__mode-toggle:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Widget-scoped overrides for attach + mode buttons ── */
.assistant-chat-widget .chat__attach-btn-wrap {
    position: relative;
    flex-shrink: 0;
}

.assistant-chat-widget .chat__attach-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid #ddd;
    background: transparent;
    cursor: pointer;
    color: #666;
    font-size: 1.2rem;
    transition: background 0.15s, color 0.15s;
}

.assistant-chat-widget .chat__attach-btn:hover {
    background: #FF753621;
    color: #ff6a00;
    border-color: #FF7536;
}

.assistant-chat-widget .chat__attach-btn:active {
    background: #FF7536;
    color: #fff;
    border-color: #FF7536;
}

.assistant-chat-widget .chat__mode-btn-wrap {
    position: relative;
}

.assistant-chat-widget .chat__mode-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 7px 10px;
    border-radius: 20px;
    border: 1.5px solid #ddd;
    background: transparent;
    cursor: pointer;
    color: #555;
    font-size: 0.82rem;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    height: 34px;
}

.assistant-chat-widget .chat__mode-toggle:hover:not(:disabled) {
    background: #FF753621;
    color: #ff6a00;
    border-color: #FF7536;
}

.assistant-chat-widget .chat__mode-toggle:active:not(:disabled) {
    background: #FF7536;
    color: #fff;
    border-color: #FF7536;
}

.assistant-chat-widget .chat__mode-toggle:active:not(:disabled) i {
    color: #fff;
}

.assistant-chat-widget .chat__mode-toggle:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Dropdown shared ── */
.chat__dropdown {
    position: absolute;
    bottom: calc(100% + 6px);
    min-width: 190px;
    background: #fff;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    z-index: 200;
    overflow: hidden;
}

.chat__dropdown--attach {
    left: 0;
}

.chat__dropdown--mode {
    right: 0;
}

.chat__dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 14px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.88rem;
    color: #333;
    text-align: left;
    transition: background 0.12s;
}

.chat__dropdown-item:hover {
    background: #FF753621;
    color: #ff6a00;
}

.chat__dropdown-item:hover i {
    color: #ff6a00;
}

.chat__dropdown-item:active {
    background: #FF7536;
    color: #fff;
}

.chat__dropdown-item:active i {
    color: #fff;
}

.chat__dropdown-item.active {
    color: #FF7536;
    font-weight: 600;
}

.chat__dropdown-item i {
    font-size: 1.1rem;
}

/* Mode dropdown items with description */
.chat__dropdown-item__info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.chat__dropdown-item__title {
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.2;
}

.chat__dropdown-item__desc {
    font-size: 0.72rem;
    color: var(--bs-secondary-color, #6c757d);
    line-height: 1.3;
    white-space: normal;
}
