/* Model selector toggle */
.model-btn {
    padding: 3px 10px;
    border-radius: 12px;
    border: 1px solid var(--neutral-300, #d7d7d7);
    background: transparent;
    color: var(--neutral-500, #7a7a7a);
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    line-height: 1.4;
}
.model-btn:hover {
    border-color: var(--color-primary, #5d7f99);
    color: var(--color-primary, #5d7f99);
}
.model-btn--active {
    background: var(--color-primary, #5d7f99);
    border-color: var(--color-primary, #5d7f99);
    color: #fff;
}

/* Model selector dropdown (Notion-style) */
.model-selector {
    position: relative;
    display: inline-flex;
    align-items: center;
    z-index: 140;
}
.model-selector--header {
    margin-left: auto;
}
.model-selector--composer {
    margin-right: 2px;
}
.model-selector-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--neutral-600, #6b7280);
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.model-selector-trigger:hover {
    background: var(--neutral-100, #f3f4f6);
    color: var(--neutral-800, #1f2937);
}
.model-selector-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
}
.model-selector-chevron {
    font-size: 0.65rem;
    opacity: 0.8;
}
.model-selector-dropdown {
    position: absolute;
    right: 0;
    left: auto;
    top: 100%;
    margin-top: 6px;
    width: min(300px, calc(100vw - 24px));
    min-width: 200px;
    max-width: calc(100vw - 24px);
    padding: 6px 0;
    background: var(--neutral-0, #fff);
    border: 1px solid var(--neutral-200, #e5e7eb);
    border-radius: 14px;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.16);
    z-index: 100;
    display: none;
    max-height: 320px;
    overflow-y: auto;
    overflow-x: hidden;
    transform-origin: top right;
}
.model-selector--composer .model-selector-dropdown {
    top: auto !important;
    bottom: calc(100% + 8px) !important;
    margin-top: 0 !important;
    transform-origin: bottom right !important;
}
.model-selector.open .model-selector-dropdown {
    display: block;
}
.model-selector-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    font-size: 0.875rem;
    color: var(--neutral-800, #1f2937);
    cursor: pointer;
    transition: background 0.1s;
}
.model-selector-option:hover {
    background: var(--neutral-100, #f3f4f6);
}
.model-selector-option--active {
    background: var(--neutral-50, #f9fafb);
    color: var(--color-primary, #5d7f99);
}
.model-selector-option--active::after {
    content: "✓";
    font-size: 0.75rem;
    font-weight: 600;
}

.model-selector-option-icon {
    width: 17px;
    height: 17px;
    object-fit: contain;
    flex-shrink: 0;
}
.model-selector-option-text {
    display: block;
    flex: 1;
    min-width: 0;
}
.model-selector-option-label {
    font-weight: 500;
    white-space: nowrap;
}

.model-selector--disabled .model-selector-trigger {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.75rem 1rem;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

.chat-input-container {
    flex: 0 0 auto;
    position: sticky;
    bottom: 0;
    z-index: 5;
    border-top: 1px solid #e5e7eb;
    background: transparent;
    padding: 1.25rem 1.5rem;
}

.chat-input-container.drag-over {
    background: #eff6ff;
    outline: 2px dashed #3b82f6;
    outline-offset: -2px;
}

.selected-files {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0;
    min-height: 0;
    border-bottom: 1px solid #e5e7eb;
}

.selected-files:not([style*="display: none"]) {
    min-height: 2.5rem;
}

.file-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f3f4f6;
    border-radius: 0.5rem;
    font-size: 0.875rem;
}

.file-preview-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.file-preview-icon svg {
    width: 1.25em;
    height: 1.25em;
    color: #6b7280;
}

.file-name {
    color: #374151;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.remove-file {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.remove-file:hover {
    background: #e5e7eb;
    color: #111827;
}

.chat-input-container {
    padding: var(--space-4) var(--space-2) 0;
    border-top: 1px solid var(--neutral-200);
    background: #ffffff;
}

.chat-header-row {
    display: none;
}

.chat-header-spacer {
    display: none;
}

/* показуємо тільки під час recording */
#voiceWaveform.voice-waveform-full.recording {
    display: block;
    width: 100% !important;
}

.chat-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #ffffff;
    border: 1px solid #e6e6e6;
    border-radius: 14px;
    padding: 8px 10px;
    position: relative;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
    overflow: visible;
}

.chat-input-wrapper:focus-within {
    border-color: var(--neutral-800);
    box-shadow: var(--shadow-input-focus);
    transform: translateY(-1px);
}

.chat-input-wrapper .input-actions { flex: 0 0 auto; }

.chat-input-wrapper #voiceWaveform {
    width: 100%;
    height: 32px;
    display: none;
}

.chat-input-wrapper #voiceWaveform.recording {
    display: block !important;
}

.chat-input-wrapper:has(#voiceWaveform.recording).expanded { }

/* === contenteditable / textarea input styles === */
#chatInput.chat-input {
    width: 100%;
    min-width: 0;
    flex: none;
    outline: none;
    border: 0;
    background: transparent;
    min-height: 30px;
    max-height: none;
    overflow-y: hidden;
    box-sizing: border-box;
    scrollbar-gutter: stable;
    white-space: pre-wrap;
    word-break: break-all;
    overflow-wrap: anywhere;
    font-size: 14px;
    line-height: 1.4;
    padding: 2px 2px;
}

#chatInput.chat-input.is-multi-line {
    padding: 6px;
}

#chatInput.chat-input:empty::before {
    content: attr(data-placeholder);
    color: #9ca3af;
    pointer-events: none;
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-size: 1rem;
    line-height: 1.5;
    padding: 0.35rem 0;
    max-height: none;
    font-family: inherit;
    color: #0f172a;
    min-height: 28px;
}

.chat-input::placeholder {
    color: #9ca3af;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.composer-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 30px;
    gap: 8px;
}

.composer-left-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 0 0 auto;
}

.composer-right-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 0 0 auto;
}

.icon-button {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: transparent !important;
    color: #8a8a8a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    font-weight: 600;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease, background 0.2s ease;
    box-shadow: none;
    line-height: 0;
    padding: 0 !important;
}

.icon-button:hover {
    background: #f1f1f1 !important;
    color: #555 !important;
    box-shadow: none;
}

.icon-button:active {
    transform: scale(0.98);
}

.icon-button:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.attach-button {
    position: relative;
    overflow: hidden;
}

.attach-label {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.55rem;
    font-weight: 500;
    color: inherit;
    margin: 0;
}

.icon-button img {
    width: 15px;
    height: 15px;
    object-fit: contain;
    display: block;
}

.voice-button {
    width: 28px;
    height: 28px;
    position: relative;
    overflow: visible;
}

.voice-button img {
    position: relative;
    z-index: 2;
    transition: opacity 0.2s ease;
}

.voice-waveform {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.voice-button.recording .voice-waveform {
    opacity: 1;
}

.voice-button.recording img {
    opacity: 0.3;
}

.voice-waveform-full {
    display: none;
    flex: 1;
    height: 32px;
    border: none;
    background: transparent;
    margin: 0 0.75rem;
    width: 100%;
}

.voice-waveform-full.recording {
    display: block;
}

.voice-button.recording {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #b91c1c;
    box-shadow: 0 8px 18px rgba(239, 68, 68, 0.35);
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
    0%, 100% { background: #fee2e2; }
    50% { background: #fecaca; }
}

.send-button {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #f2f2f2 !important;
    color: #b9b9b9;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-shadow: none;
    flex-shrink: 0;
    padding: 0;
}

.send-button:hover:not(:disabled) {
    transform: none;
    box-shadow: none;
    background: #ececec !important;
}

.send-button:active:not(:disabled) {
    transform: translateY(0);
}

.send-button:disabled {
    background: #f2f2f2 !important;
    color: #c5c5c5;
    cursor: not-allowed;
    box-shadow: none;
}

.send-button:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.send-button.loading {
    position: relative;
}

.send-button.loading .wave-icon,
.send-button.loading .arrow-icon {
    opacity: 0;
}

.send-button.loading::after {
    content: '';
    width: 18px;
    height: 18px;
    border-radius: 20%;
    border: 3px solid rgba(17, 24, 39, 0.15);
    border-top-color: #111827;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.wave-icon {
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

.send-button .wave-icon span {
    width: 4px;
    height: 12px;
    background: #111827;
    border-radius: 2px;
    display: block;
    animation: wavePulse 1.1s ease-in-out infinite;
}

.wave-icon span:nth-child(2) {
    height: 18px;
    animation-delay: 0.12s;
}

.wave-icon span:nth-child(3) {
    height: 14px;
    animation-delay: 0.24s;
}

@keyframes wavePulse {
    0%, 100% { transform: scaleY(0.55); opacity: 0.9; }
    50% { transform: scaleY(1); opacity: 1; }
}

.arrow-icon {
    display: none;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #111827;
    transition: transform 0.2s ease;
}

.send-icon-svg {
    display: inherit;
    align-items: inherit;
    justify-content: inherit;
    width: 100%;
    height: 100%;
}

.send-icon-svg i {
    font-size: 13px;
    color: currentColor;
    display: block;
}

.stop-icon {
    font-size: 12px;
    color: #111827;
    display: none;
    font-weight: 600;
    user-select: none;
    transition: transform 0.2s ease;
}

.send-button:hover:not(:disabled) .arrow-icon,
.send-button:hover:not(:disabled) .stop-icon {
    transform: none;
}

.composer-tools-button span {
    font-size: 14px;
    line-height: 1;
}

.model-selector--composer {
    margin-right: 2px;
}

.model-selector-trigger {
    padding: 2px 7px;
    border-radius: 999px;
    color: #676767;
    font-size: 0.8rem;
    gap: 5px;
    white-space: nowrap;
}

.model-selector-trigger:hover {
    background: #f1f1f1;
    color: #4e4e4e;
}

.model-selector-icon {
    width: 14px;
    height: 14px;
}

.model-selector-chevron {
    font-size: 0.55rem;
    opacity: 0.65;
}

.recording-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    position: relative;
    z-index: 2;
}

.control-button {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: #0f172a;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
    padding: 0;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
}

.control-button:hover {
    background: #111b2f;
    transform: translateY(-1px);
}

.control-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
}

.control-button svg {
    stroke-width: 2.6;
    width: 15px;
    height: 15px;
    stroke: currentColor;
}

/* Responsive tweaks for input */
@media (max-width: 1024px) {
    .chat-input-container {
        padding: var(--space-3) var(--space-2);
        padding-bottom: max(var(--space-2), env(safe-area-inset-bottom));
    }
}

@media (max-width: 768px) and (pointer: coarse) {
    .chat-input-wrapper {
        padding: var(--space-3);
    }
    .chat-input-container {
        padding: var(--space-2);
        padding-bottom: max(var(--space-2), env(safe-area-inset-bottom));
    }
    #chatInput.chat-input,
    .chat-input {
        min-height: 48px;
        padding-top: 8px;
        padding-bottom: 8px;
        font-size: 14px;
    }
    .icon-button,
    .send-button {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }
}

