/* =================================================================
 * UNIFIED FLOATING INPUT COMPONENT
 * ================================================================= */

/* --- Main Input Container --- */
.floating-input-container {
    position: fixed;
    bottom: var(--input-bottom-offset, 56px);
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    max-width: var(--input-container-max-width);
    background-color: transparent;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    z-index: var(--z-input-container);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transition: all var(--anim-normal) var(--easing-standard);
    opacity: 1;
    visibility: visible;
}

/* --- Centered Input State (No Messages) --- */
.floating-input-container.centered {
    bottom: 50%;
    transform: translateX(-50%) translateY(50%);
}

/* --- Welcome Mode (Centered) --- */
.floating-input-container.welcome-mode {
    bottom: 50%;
    transform: translateX(-50%) translateY(50%);
    transition: all var(--anim-normal) var(--easing-standard);
}

/* --- Chat Mode (Bottom Positioned) --- */
.floating-input-container.chat-mode {
    bottom: var(--input-bottom-offset, 56px);
    transform: translateX(-50%);
    transition: all var(--anim-normal) var(--easing-standard);
}

/* --- Attachment Strip --- */
.attachment-strip {
    display: flex;
    flex-direction: row;
    gap: 6px;
    padding: 10px 12px 8px;
    border-radius: 26px 26px 0 0;
    border: none;
    border-bottom: none;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    opacity: 0;
    visibility: hidden;
    max-height: 0;
    overflow: hidden;
    transition: opacity var(--anim-fast) var(--easing-standard),
        max-height var(--anim-fast) var(--easing-standard),
        padding var(--anim-fast) var(--easing-standard),
        visibility 0s linear var(--anim-fast);
}

.attachment-strip.hidden {
    opacity: 0;
    visibility: hidden;
    max-height: 0;
    padding: 0 12px;
}

.attachment-strip:not(.hidden) {
    opacity: 1;
    visibility: visible;
    max-height: 200px;
    padding: 10px 12px 8px;
}

.attachments-scroll {
    display: flex;
    flex-direction: row;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px;
    width: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-wrap: nowrap;
}

.attachments-scroll::-webkit-scrollbar {
    display: none;
}

.file-preview-chip {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 84px;
    max-width: 84px;
    height: 98px;
    border-radius: 12px;
    background: var(--elevated-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.file-preview-chip:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.file-preview-chip .file-thumbnail {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    overflow: hidden;
}

.file-preview-chip .file-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-preview-chip .file-thumbnail .file-icon {
    font-size: 2rem;
    color: var(--text-secondary);
}

.file-preview-chip .file-name {
    position: absolute;
    bottom: 4px;
    left: 4px;
    right: 4px;
    padding: 2px 4px;
    font-size: 0.6rem;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
    background: transparent;
}

.file-preview-chip.image-file .file-name {
    display: none;
}

.file-preview-chip .remove-file-btn {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    cursor: pointer;
    font-size: 0.7rem;
    transition: background 0.2s ease, transform 0.2s ease;
}

.file-preview-chip .remove-file-btn:hover {
    background: rgba(239, 68, 68, 0.9);
    transform: scale(1.1);
}

.file-preview-chip .file-actions {
    display: none;
}

.file-preview-chip .preview-file-btn {
    display: none;
}

.file-preview-chip .file-status {
    display: none;
}

.file-preview-chip.uploading {
    opacity: 0.7;
}

.file-preview-chip.uploading .file-status {
    background: rgba(107, 114, 128, 0.9);
}

.file-preview-chip.failed {
    border-color: var(--error-500);
}

.file-preview-chip.failed .file-status {
    background: rgba(239, 68, 68, 0.9);
}

.file-preview-chip .success-icon {
    color: var(--success-500);
}

.file-preview-chip .error-icon {
    color: var(--error-500);
}

.file-processing-indicator {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    background: rgba(255, 193, 7, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: #1a1a1a;
}

.dark-mode .file-processing-indicator {
    background: rgba(255, 193, 7, 0.95);
    color: #1a1a1a;
}

.input-field {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 4px;
    border-radius: 24px;
    background: transparent;
    border: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    transition: border-color var(--anim-fast) var(--easing-standard);
    min-height: 52px;
    contain: layout;
}

/* Ensure proper flex order for input field elements */
.input-field #attach-file-btn {
    order: 0;
}

.input-field .floating-input {
    order: 1;
    flex: 1;
}

.input-field #voice-input-btn {
    order: 2;
}

.input-field #send-message {
    order: 3;
}

.input-field.with-attachments {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top: none;
    border-radius: 0 0 26px 26px;
}

.floating-input-container.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) scale(0.95);
    transition: opacity var(--anim-fast) var(--easing-standard), transform var(--anim-fast) var(--easing-standard), visibility 0s var(--anim-fast);
}

/* --- Smooth transition between centered and bottom positions --- */
.floating-input-container:not(.centered) {
    transition: all var(--anim-normal) var(--easing-standard);
}

.floating-input-container.centered {
    transition: all var(--anim-normal) var(--easing-standard);
}

/* --- Text Input Area --- */
.floating-input {
    flex: 1;
    border: none;
    box-shadow: none;
    border-radius: 20px;
    padding: 10px 14px;
    resize: none;
    background-color: transparent;
    color: var(--text-color);
    font-family: inherit;
    max-height: var(--input-max-height);
    font-size: 0.95rem;
    min-height: 40px;
    transition: none;
    outline: none;
    line-height: 1.5;
    will-change: height;
}

.floating-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* --- Input Action Buttons (Desktop) --- */
.input-action-btn.circular-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    flex-shrink: 0;
    margin-bottom: 0;
    position: relative;
    overflow: hidden;
}

#attach-file-btn {
    background-color: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
}

#attach-file-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

#send-message {
    background: #ffffff;
    color: #1a1a1a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#send-message:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    background: #f5f5f5;
}

#send-message:active {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    background: #e8e8e8;
}

/* Send button loading state (plane → triangle) */
#send-message.sending {
    pointer-events: none;
    opacity: 0.8;
}

/* Triangle icon pointing upward - static, no animation */
#send-message.sending i.fa-play {
    transform: rotate(-90deg);
    /* Static triangle pointing up, no pulsing */
}

/* Light mode - dark button with white icon */
body:not(.dark-mode) #send-message {
    background: #1a1a1a;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

body:not(.dark-mode) #send-message:hover {
    background: #2e2e2e;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

body:not(.dark-mode) #send-message:active {
    background: #3a3a3a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* --- Input styling when files are attached --- */
.floating-input-container.has-files .floating-input {
    border-radius: 0;
}

.floating-input-container.has-files .attached-files-bar+.floating-input {
    border-top: none;
}

.floating-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: none;
}

/* --- Horizontal Context and Files Bar --- */
.context-files-bar {
    padding: 12px 16px 8px 16px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(var(--accent-color-rgb), 0.02);
    border-radius: 16px 16px 0 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--anim-normal) var(--easing-standard), padding var(--anim-normal) var(--easing-standard);
}

.context-files-bar:not(.hidden) {
    max-height: 200px;
}

.context-files-bar.hidden {
    padding: 0 16px;
    border-bottom: none;
}

.context-files-content {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* --- File Chips --- */
.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--window-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-color);
    transition: all var(--anim-fast) var(--easing-standard);
    cursor: pointer;
    max-width: 200px;
}

.file-chip:hover {
    border-color: var(--accent-color);
    background: var(--hover-bg);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.file-chip-icon {
    color: var(--accent-color);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.file-chip-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.file-chip-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--anim-fast) var(--easing-standard);
    font-size: 0.7rem;
    flex-shrink: 0;
}

.file-chip-remove:hover {
    background: #ef4444;
    color: white;
}

/* --- Upload Status Text Animation --- */
.upload-status-text {
    position: relative;
    display: inline-block;
    animation: textShimmer 2.5s ease-in-out infinite;
    background: linear-gradient(90deg,
            var(--accent-color) 0%,
            rgba(var(--accent-color-rgb), 0.7) 25%,
            var(--accent-color) 50%,
            rgba(var(--accent-color-rgb), 0.7) 75%,
            var(--accent-color) 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* --- Glassmorphism Animations --- */
@keyframes glassmorphPulse {

    0%,
    100% {
        transform: scale(1);
        background: rgba(255, 255, 255, 0.15);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    }

    50% {
        transform: scale(1.05);
        background: rgba(255, 255, 255, 0.25);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    }
}

@keyframes glassmorphPulseDark {

    0%,
    100% {
        transform: scale(1);
        background: rgba(0, 0, 0, 0.25);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    }

    50% {
        transform: scale(1.05);
        background: rgba(0, 0, 0, 0.35);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    }
}

@keyframes textShimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* --- File Chip States with Glassmorphism --- */
.file-chip.uploading,
.file-chip.reading {
    position: relative;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    animation: glassmorphPulse 2s ease-in-out infinite;
}

.dark-mode .file-chip.uploading,
.dark-mode .file-chip.reading {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    animation: glassmorphPulseDark 2s ease-in-out infinite;
}

.file-chip.failed {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.file-chip.failed .file-chip-icon {
    color: #ef4444;
}

/* --- Session Chips (similar to file chips) --- */
.session-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--elevated-bg);
    border: 1px solid var(--accent-color);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-color);
    transition: all var(--anim-fast) var(--easing-standard);
    cursor: pointer;
    max-width: 250px;
}

.session-chip:hover {
    background: var(--accent-muted);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.session-chip-icon {
    color: var(--accent-color);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.session-chip-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    flex: 1;
}

.session-chip-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--anim-fast) var(--easing-standard);
    font-size: 0.7rem;
    flex-shrink: 0;
}

.session-chip-remove:hover {
    background: #ef4444;
    color: white;
}

/* --- Input Toolbar --- */
.input-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid var(--border-color);
}

.input-toolbar button,
.input-toolbar .toolbar-btn {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.input-toolbar button:hover,
.input-toolbar .toolbar-btn:hover {
    background: var(--hover-bg);
    color: var(--accent-color);
}

.input-toolbar button:focus-visible,
.input-toolbar .toolbar-btn:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}
/*
 --- Voice Input Button --- */
.voice-input-btn {
    background-color: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    position: relative;
}

.voice-input-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

/* Light mode voice button */
body:not(.dark-mode) .voice-input-btn {
    color: rgba(26, 26, 26, 0.6);
}

body:not(.dark-mode) .voice-input-btn:hover {
    background-color: rgba(26, 26, 26, 0.1);
    color: rgba(26, 26, 26, 0.9);
}

/* Voice button listening state */
.voice-input-btn.listening {
    background-color: var(--accent-color);
    color: var(--bg-color);
}

.voice-input-btn.listening:hover {
    background-color: var(--accent-hover);
}

/* Voice icon - visible when idle */
.voice-input-btn.idle .voice-icon {
    display: block;
}

.voice-input-btn.listening .voice-icon {
    display: none;
}

/* Waveform container - visible when listening */
.voice-input-btn.idle .waveform-container {
    display: none !important;
}

.voice-input-btn.listening .waveform-container {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 22px;
    width: 22px;
}

/* Waveform bars */
.waveform-bar {
    width: 2px;
    position: relative;
    height: 100%;
    --bar-scale: 0.35;
    will-change: transform, opacity;
}

.waveform-bar::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 100%;
    background-color: currentColor;
    border-radius: 999px;
    transform-origin: center;
    transform: translateY(-50%) scaleY(var(--bar-scale));
    transition: transform 0.12s ease, opacity 0.2s ease;
}

.voice-input-btn.listening .waveform-container.is-silent .waveform-bar::after {
    opacity: 0.35;
}