/* ==========================================================================
   AI Chat Window Styles
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties
   -------------------------------------------------------------------------- */
:root {
    --chat-primary: #0078d4; /* Azure blue */
    --chat-primary-hover: #106ebe;
    --chat-bubble-user: #0078d4;
    --chat-bubble-user-text: #ffffff;
    --chat-bubble-assistant: #f0f0f0;
    --chat-bubble-assistant-text: #1a1a1a;
    --chat-bubble-error: #fef2f2;
    --chat-bubble-error-text: #dc2626;
    --chat-header-bg: #ffffff;
    --chat-body-bg: #fafafa;
    --chat-input-bg: #ffffff;
    --chat-border: #e5e5e5;
    --chat-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --chat-fab-size: 50px;
    --chat-window-width: 400px;
    --chat-window-height: 560px;
    --chat-min-width: 320px;
    --chat-min-height: 400px;
    --chat-max-width: 90vw;
    --chat-max-height: 90vh;
    --chat-transition-duration: 0.3s;
}

/* --------------------------------------------------------------------------
   FAB Button (Floating Action Button) - positioned to the right of back-to-top
   -------------------------------------------------------------------------- */
.chat-fab {
    position: fixed;
    bottom: 30px; /* Same level as back-to-top button */
    right: 30px; /* Rightmost position */
    width: var(--chat-fab-size);
    height: var(--chat-fab-size);
    border-radius: 50%;
    border: none;
    background: var(--chat-primary);
    color: #ffffff;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: var(--chat-shadow);
    z-index: 1040; /* Below Bootstrap modals (1050-1055) but above back-to-top */
    transition: background-color var(--chat-transition-duration) ease,
                transform var(--chat-transition-duration) ease,
                box-shadow var(--chat-transition-duration) ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-fab:hover {
    background: var(--chat-primary-hover);
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}

.chat-fab:focus {
    outline: 2px solid var(--chat-primary);
    outline-offset: 2px;
}

.chat-fab:active {
    transform: scale(0.98);
}

/* FAB hidden state when chat is open */
.chat-fab.is-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

/* --------------------------------------------------------------------------
   Chat Window
   -------------------------------------------------------------------------- */
.chat-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: var(--chat-window-width);
    height: var(--chat-window-height);
    max-height: calc(100vh - 40px);
    background: var(--chat-body-bg);
    border-radius: 16px;
    box-shadow: var(--chat-shadow);
    z-index: 1045; /* Below Bootstrap modals (1050-1055) but above FAB */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity var(--chat-transition-duration) ease,
                transform var(--chat-transition-duration) ease;
    pointer-events: none;
}

.chat-window.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.chat-window[hidden] {
    display: none;
}

/* --------------------------------------------------------------------------
   Resize Handles
   -------------------------------------------------------------------------- */
.chat-resize-handle {
    position: absolute;
    z-index: 10;
    background: transparent;
}

/* Edge handles */
.chat-resize-n {
    top: -4px;
    left: 16px;
    right: 16px;
    height: 8px;
    cursor: n-resize;
}

.chat-resize-s {
    bottom: -4px;
    left: 16px;
    right: 16px;
    height: 8px;
    cursor: s-resize;
}

.chat-resize-e {
    right: -4px;
    top: 16px;
    bottom: 16px;
    width: 8px;
    cursor: e-resize;
}

.chat-resize-w {
    left: -4px;
    top: 16px;
    bottom: 16px;
    width: 8px;
    cursor: w-resize;
}

/* Corner handles (larger hit area for easier targeting) */
.chat-resize-ne {
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    cursor: ne-resize;
}

.chat-resize-se {
    bottom: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    cursor: se-resize;
}

.chat-resize-sw {
    bottom: -4px;
    left: -4px;
    width: 16px;
    height: 16px;
    cursor: sw-resize;
}

.chat-resize-nw {
    top: -4px;
    left: -4px;
    width: 16px;
    height: 16px;
    cursor: nw-resize;
}

/* Hide resize handles when resizing to prevent flicker */
.chat-window.is-resizing .chat-resize-handle {
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   Fullscreen Mode
   -------------------------------------------------------------------------- */
.chat-window.is-fullscreen {
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    border-radius: 0;
    transition: none; /* Instant transition for fullscreen */
}

.chat-window.is-fullscreen .chat-resize-handle {
    display: none;
}

/* --------------------------------------------------------------------------
   Chat Header
   -------------------------------------------------------------------------- */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--chat-header-bg);
    border-bottom: 1px solid var(--chat-border);
    flex-shrink: 0;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.chat-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-header-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.chat-header-btn:hover {
    background: #f0f0f0;
    color: #1a1a1a;
}

.chat-header-btn:focus {
    outline: 2px solid var(--chat-primary);
    outline-offset: 1px;
}

/* --------------------------------------------------------------------------
   Chat Messages Container
   -------------------------------------------------------------------------- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Custom scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #d1d1d1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #b0b0b0;
}

/* --------------------------------------------------------------------------
   Message Bubbles
   -------------------------------------------------------------------------- */
.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: messageSlideIn var(--chat-transition-duration) ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* User messages (right-aligned, blue) */
.chat-message.user {
    align-self: flex-end;
}

.chat-message.user .chat-bubble {
    background: var(--chat-bubble-user);
    color: var(--chat-bubble-user-text);
    border-radius: 16px 16px 4px 16px;
}

/* Assistant messages (left-aligned, grey) */
.chat-message.assistant {
    align-self: flex-start;
}

.chat-message.assistant .chat-bubble {
    background: var(--chat-bubble-assistant);
    color: var(--chat-bubble-assistant-text);
    border-radius: 16px 16px 16px 4px;
}

/* Error messages - styled like assistant but with subtle warning indicator */
.chat-message.error {
    justify-content: flex-start; /* Align left like assistant */
}

.chat-message.error .chat-bubble {
    background: var(--chat-bubble-assistant);
    color: var(--chat-bubble-assistant-text);
    border-radius: 16px 16px 16px 4px; /* Same as assistant */
    border-left: 3px solid #f59e0b; /* Subtle amber/orange left border */
}

.chat-message.error .message-content::before {
    content: "\f06a"; /* FontAwesome exclamation-circle */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    color: #f59e0b;
    margin-right: 8px;
}

/* Bubble content */
.chat-bubble {
    padding: 10px 14px;
    font-size: 0.9375rem;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Message content wrapper */
.message-content {
    white-space: pre-wrap;
}

/* --------------------------------------------------------------------------
   Markdown Styles for Assistant Messages
   -------------------------------------------------------------------------- */
.chat-message.assistant .message-content {
    white-space: normal;
}

/* Paragraphs */
.chat-message.assistant .message-content p {
    margin: 0 0 0.75em 0;
}

.chat-message.assistant .message-content p:last-child {
    margin-bottom: 0;
}

/* Headers */
.chat-message.assistant .message-content h1,
.chat-message.assistant .message-content h2,
.chat-message.assistant .message-content h3,
.chat-message.assistant .message-content h4,
.chat-message.assistant .message-content h5,
.chat-message.assistant .message-content h6 {
    margin: 0.75em 0 0.5em 0;
    font-weight: 600;
    line-height: 1.3;
}

.chat-message.assistant .message-content h1:first-child,
.chat-message.assistant .message-content h2:first-child,
.chat-message.assistant .message-content h3:first-child {
    margin-top: 0;
}

.chat-message.assistant .message-content h1 { font-size: 1.25em; }
.chat-message.assistant .message-content h2 { font-size: 1.15em; }
.chat-message.assistant .message-content h3 { font-size: 1.05em; }
.chat-message.assistant .message-content h4,
.chat-message.assistant .message-content h5,
.chat-message.assistant .message-content h6 { font-size: 1em; }

/* Links */
.chat-message.assistant .message-content a {
    color: #0078d4;
    text-decoration: underline;
}

.chat-message.assistant .message-content a:hover {
    color: #106ebe;
}

/* Lists */
.chat-message.assistant .message-content ul,
.chat-message.assistant .message-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.chat-message.assistant .message-content li {
    margin: 0.25em 0;
}

/* Inline code */
.chat-message.assistant .message-content code {
    background: rgba(0, 0, 0, 0.08);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.875em;
}

/* Code blocks */
.chat-message.assistant .message-content pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.75em 0;
    font-size: 0.8125rem;
    line-height: 1.5;
}

.chat-message.assistant .message-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

/* Blockquotes */
.chat-message.assistant .message-content blockquote {
    border-left: 3px solid #0078d4;
    margin: 0.75em 0;
    padding: 0.5em 0 0.5em 1em;
    color: #555;
    background: rgba(0, 120, 212, 0.05);
    border-radius: 0 4px 4px 0;
}

.chat-message.assistant .message-content blockquote p {
    margin: 0;
}

/* Horizontal rule */
.chat-message.assistant .message-content hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 1em 0;
}

/* Tables */
.chat-message.assistant .message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75em 0;
    font-size: 0.875em;
}

.chat-message.assistant .message-content th,
.chat-message.assistant .message-content td {
    border: 1px solid #ddd;
    padding: 6px 10px;
    text-align: left;
}

.chat-message.assistant .message-content th {
    background: rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

/* Bold and italic */
.chat-message.assistant .message-content strong {
    font-weight: 600;
}

.chat-message.assistant .message-content em {
    font-style: italic;
}

/* --------------------------------------------------------------------------
   Text Adventure Game Output (Frotz)
   Retro terminal aesthetic for interactive fiction
   -------------------------------------------------------------------------- */
.chat-message.assistant .message-content .game-output {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #00ff41; /* Classic green terminal text */
    font-family: 'VT323', 'Courier New', 'Lucida Console', Monaco, monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    padding: 16px 18px;
    border-radius: 8px;
    margin: 0.75em 0;
    border: 1px solid #0f3460;
    box-shadow: inset 0 0 20px rgba(0, 255, 65, 0.05),
                0 4px 12px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

/* Subtle scanline effect for retro feel */
.chat-message.assistant .message-content .game-output::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.1) 2px,
        rgba(0, 0, 0, 0.1) 4px
    );
    pointer-events: none;
}

/* Game output header/label */
.chat-message.assistant .message-content .game-output-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #4ade80;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 255, 65, 0.2);
    font-weight: 500;
}

.chat-message.assistant .message-content .game-output-header i {
    font-size: 0.8rem;
}

/* Game content area */
.chat-message.assistant .message-content .game-output-content {
    white-space: pre-wrap;
    position: relative;
    z-index: 1;
}

/* Room/location titles in game output */
.chat-message.assistant .message-content .game-location {
    color: #fbbf24; /* Amber/gold for locations */
    font-weight: bold;
    display: block;
    margin-bottom: 4px;
}

/* Input prompt indicator */
.chat-message.assistant .message-content .game-prompt {
    color: #60a5fa; /* Blue for prompts/commands */
    font-weight: bold;
}

/* Score/status line styling */
.chat-message.assistant .message-content .game-status {
    color: #a78bfa; /* Purple for game status */
    font-size: 0.8rem;
    opacity: 0.9;
}

/* Import VT323 retro font */
@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

/* --------------------------------------------------------------------------
   Image Thumbnails in Chat
   -------------------------------------------------------------------------- */
.chat-image-thumbnail {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    margin: 0.5em 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: block;
}

.chat-image-thumbnail:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* --------------------------------------------------------------------------
   Image Lightbox Overlay
   -------------------------------------------------------------------------- */
.chat-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: lightboxFadeIn 0.2s ease;
}

@keyframes lightboxFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.chat-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-lightbox-image {
    max-width: 100%;
    max-height: calc(100vh - 80px);
    object-fit: contain;
    border-radius: 4px;
    animation: lightboxZoomIn 0.2s ease;
}

@keyframes lightboxZoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Timestamp - displayed at bottom right of each message */
.chat-message-time {
    font-size: 0.6875rem;
    color: rgba(0, 0, 0, 0.45);
    margin-top: 6px;
    text-align: right;
}

.chat-message.user .chat-message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* --------------------------------------------------------------------------
   Typing Indicator
   -------------------------------------------------------------------------- */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 14px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #888;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* --------------------------------------------------------------------------
   Streaming Message Cursor
   -------------------------------------------------------------------------- */
.chat-message.streaming .streaming-cursor {
    display: inline;
    animation: streamingBlink 1s step-end infinite;
    color: var(--chat-primary);
    font-weight: bold;
}

@keyframes streamingBlink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

/* --------------------------------------------------------------------------
   Tool Badge (shown during tool invocation)
   -------------------------------------------------------------------------- */
.chat-tool-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    padding: 4px 10px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #e8f4fd 0%, #d0e8fa 100%);
    color: var(--chat-primary);
    border-radius: 12px;
    border: 1px solid rgba(0, 120, 212, 0.2);
    font-weight: 500;
}

.chat-tool-badge i {
    font-size: 0.7rem;
}

/* --------------------------------------------------------------------------
   Message Counter (progress toward compaction)
   -------------------------------------------------------------------------- */
.chat-message-counter {
    display: inline-flex;
    align-items: center;
    font-size: 0.6875rem;
    padding: 2px 8px;
    background: #f0f0f0;
    color: #666;
    border-radius: 10px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.chat-message-counter.low {
    background: #e8f5e9;
    color: #2e7d32;
}

.chat-message-counter.medium {
    background: #fff3e0;
    color: #e65100;
}

.chat-message-counter.high {
    background: #ffebee;
    color: #c62828;
}

/* --------------------------------------------------------------------------
   Summary Message (conversation compaction)
   -------------------------------------------------------------------------- */
.chat-message.summary {
    align-self: stretch;
    max-width: 100%;
}

.chat-message.summary .chat-bubble {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #495057;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    border-left: 3px solid var(--chat-primary);
}

.chat-message.summary .summary-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--chat-primary);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
}

.chat-message.summary .message-content {
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: normal;
}

.chat-message.summary .message-content p {
    margin: 0 0 0.5em 0;
}

.chat-message.summary .message-content p:last-child {
    margin-bottom: 0;
}

.chat-message.summary .message-content ul,
.chat-message.summary .message-content ol {
    margin: 0.5em 0;
    padding-left: 1.25em;
}

.chat-message.summary .message-content li {
    margin: 0.25em 0;
}

/* --------------------------------------------------------------------------
   Loading State
   -------------------------------------------------------------------------- */
.chat-messages-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #888;
    gap: 12px;
}

.chat-messages-loading i {
    font-size: 1.5rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   Chat Input Area
   -------------------------------------------------------------------------- */
.chat-input-area {
    padding: 12px 16px;
    background: var(--chat-input-bg);
    border-top: 1px solid var(--chat-border);
    flex-shrink: 0;
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f5f5f5;
    border-radius: 24px;
    padding: 4px 4px 4px 16px;
    transition: box-shadow 0.2s ease;
}

.chat-input-wrapper:focus-within {
    box-shadow: 0 0 0 2px var(--chat-primary);
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.9375rem;
    line-height: 1.5;
    padding: 8px 0;
    color: #1a1a1a;
    min-width: 0;
}

.chat-input::placeholder {
    color: #888;
}

.chat-input:focus {
    outline: none;
}

.chat-input:disabled {
    color: #888;
    cursor: not-allowed;
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--chat-primary);
    color: #ffffff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    transition: background-color 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    background: var(--chat-primary-hover);
    transform: scale(1.05);
}

.chat-send-btn:focus {
    outline: 2px solid var(--chat-primary);
    outline-offset: 2px;
}

.chat-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Stop button state (during sending) - same color as send button */
.chat-send-btn.is-stopping {
    background: var(--chat-primary);
    cursor: pointer;
}

.chat-send-btn.is-stopping:hover {
    background: var(--chat-primary-hover);
    transform: scale(1.05);
}

/* Cancelled request indicator */
.chat-cancelled-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 12px;
    background: #f5f5f5;
    color: #666;
    font-size: 0.8125rem;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.chat-cancelled-indicator i {
    font-size: 0.875rem;
    color: #999;
}

/* --------------------------------------------------------------------------
   Responsive: Tablet (768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .chat-fab {
        bottom: 30px; /* Same level as back-to-top */
        right: 30px;
        width: 45px;
        height: 45px;
    }

    .chat-window {
        width: 350px;
        height: 500px;
        right: 16px;
        bottom: 16px;
    }
}

/* --------------------------------------------------------------------------
   Responsive: Mobile (576px)
   -------------------------------------------------------------------------- */
@media (max-width: 576px) {
    .chat-fab {
        bottom: 20px; /* Same level as back-to-top */
        right: 20px;
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }

    /* Hide resize handles on mobile (already fullscreen) */
    .chat-resize-handle {
        display: none;
    }

    /* Hide fullscreen button on mobile (already fullscreen) */
    #chat-fullscreen-btn {
        display: none;
    }

    .chat-header {
        padding: 16px;
    }

    .chat-messages {
        padding: 12px;
    }

    .chat-input-area {
        padding: 12px;
        /* Add safe area padding for mobile devices with notches */
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .chat-input-wrapper {
        padding: 6px 6px 6px 14px;
    }

    .chat-input {
        font-size: 1rem;
        padding: 10px 0;
    }

    .chat-send-btn {
        width: 40px;
        height: 40px;
    }
}

/* --------------------------------------------------------------------------
   Reduced Motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .chat-fab,
    .chat-window,
    .chat-message,
    .chat-header-btn,
    .chat-send-btn,
    .chat-input-wrapper {
        transition: none;
    }

    .chat-message {
        animation: none;
    }

    .typing-indicator span {
        animation: none;
        opacity: 1;
        transform: scale(1);
    }

    .chat-messages-loading i {
        animation: none;
    }
}

/* --------------------------------------------------------------------------
   Print Styles
   -------------------------------------------------------------------------- */
@media print {
    .chat-fab,
    .chat-window {
        display: none !important;
    }
}
