/**
 * Otter Input Bar Styles
 * Standalone CSS for the reusable input bar component
 * Include this file on any page where you use the OtterInputBar
 */

/* Container and wrapper */
.otter-input-bar-wrapper {
    max-width: 600px;
    position: relative;
    margin: 0 auto;
    /* Ensure modal can escape */
    transform: none !important;
    overflow: visible !important;
}

.otter-chat-form-wrapper {
    width: 100%;
    position: relative;
    overflow: visible !important;
}

/* Main form container */
.otter-chat-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.75rem;
    padding: 0.5rem;
    box-shadow: 0 8px 32px 0 rgba(45, 125, 125, 0.15);
    transition: all 0.2s;
}

[data-theme="dark"] .otter-chat-form {
    background: rgba(36, 36, 36, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.otter-chat-form:focus-within {
    border-color: var(--accent-primary, #2d7d7d);
    box-shadow: 0 0 0 3px rgba(45, 125, 125, 0.1);
}

/* Input field */
.otter-chat-input {
    flex: 1;
    background: none;
    border: none;
    padding: 0.75rem 1rem 0.75rem 1.5rem;
    font-size: 1rem;
    color: var(--text-primary, #1a1a1a);
    outline: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    cursor: pointer;
}

.otter-chat-input::placeholder {
    color: var(--text-tertiary, #9ca3af);
}

/* Attach button */
.otter-attach-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border-radius: 0.5rem;
}

.otter-attach-btn:hover {
    color: var(--accent-primary, #2d7d7d);
    background: rgba(45, 125, 125, 0.1);
}

.otter-attach-btn:active {
    transform: scale(0.95);
}

/* Submit button */
.otter-chat-submit {
    background: var(--accent-primary, #2d7d7d);
    border: none;
    border-radius: 0.5rem;
    padding: 0.75rem 1.25rem;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
    font-weight: 500;
    overflow: hidden;
}

.otter-chat-submit::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(255, 107, 107, 0.2) 100%);
    transition: opacity 0.2s;
    opacity: 0;
}

.otter-chat-submit:hover::after {
    opacity: 1;
}

.otter-chat-submit:hover {
    transform: scale(1.05);
}

.otter-chat-submit:active {
    transform: scale(0.95);
}

/* File preview styles */
.otter-file-preview-container {
    margin-bottom: 0.75rem;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.5rem;
    padding: 0.75rem;
    box-shadow: 0 4px 16px 0 rgba(45, 125, 125, 0.1);
}

[data-theme="dark"] .otter-file-preview-container {
    background: rgba(36, 36, 36, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.otter-file-preview-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.otter-file-icon {
    font-size: 1.25rem;
}

.otter-file-name {
    flex: 1;
    color: var(--text-primary, #1a1a1a);
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.otter-remove-file-btn {
    background: none;
    border: none;
    color: var(--text-secondary, #6b7280);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
    transition: color 0.2s;
}

.otter-remove-file-btn:hover {
    color: var(--accent-danger, #ef4444);
}

/* Otter assistant styles */
.otter-assistant {
    position: absolute;
    left: -30px;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    cursor: pointer;
    transition: transform 0.3s ease;
    z-index: 10;
}

.otter-assistant:hover {
    transform: translateY(-50%) scale(1.1);
}

.otter-assistant img {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.otter-bubble {
    position: absolute;
    bottom: 65px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: white;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    white-space: nowrap;
    max-width: 250px;
}

[data-theme="dark"] .otter-bubble {
    background: var(--surface, #242424);
    color: var(--text-primary);
}

.otter-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
}

[data-theme="dark"] .otter-bubble::after {
    border-top-color: var(--surface, #242424);
}

.otter-bubble.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.otter-bubble-text {
    margin: 0;
    color: var(--text-primary, #1a1a1a);
    font-size: 0.9rem;
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .otter-mobile-text-popup {
        position: fixed;
        height: -webkit-fill-available;
    }

    .otter-modal-container {
        max-height: -webkit-fill-available;
    }
}

/* Mobile responsive styles for modal */
@media (max-width: 768px) {
    .otter-mobile-text-popup {
        padding: 20px !important;
        position: fixed !important;
        inset: 0 !important;
        align-items: center !important;
    }

    .otter-modal-container {
        width: 90vw !important;
        height: auto !important;
        max-height: 80vh !important;
        border-radius: 20px !important;
        margin: 0 !important;
    }

    .otter-mobile-textarea {
        min-height: 250px;
        padding: 1.5rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .otter-modal-file-preview {
        margin: 0.75rem 1rem;
        padding: 0.75rem 1rem;
    }

    .otter-modal-file-icon {
        font-size: 1.25rem;
    }

    .otter-modal-file-name {
        font-size: 0.9rem;
    }

    .otter-modal-header h3 {
        font-size: 1.25rem;
    }

    .otter-mobile-popup-actions {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .otter-mobile-action-left,
    .otter-mobile-action-buttons {
        width: 100%;
    }

    .otter-mobile-action-buttons {
        justify-content: space-between;
    }

    .otter-mobile-attach-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Mobile responsive styles for input bar */
@media (max-width: 768px) {
    .otter-input-bar-wrapper {
        margin: 2rem 1rem;
    }

    .otter-assistant {
        display: none;
    }

    .otter-chat-input {
        font-size: 0.9rem;
        padding: 0.6rem 0.8rem;
    }

    .otter-chat-submit {
        padding: 0.6rem 1rem;
    }

    .otter-attach-btn {
        padding: 0.4rem;
    }

    .otter-file-preview-container {
        margin-bottom: 0.5rem;
        padding: 0.5rem;
    }

    .otter-file-icon {
        font-size: 1rem;
    }

    .otter-file-name {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .otter-input-bar-wrapper {
        margin: 1.5rem 0.75rem;
    }

    .otter-chat-form {
        padding: 0.4rem;
        gap: 0.3rem;
    }

    .otter-chat-input {
        padding: 0.5rem 0.6rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .otter-chat-submit {
        padding: 0.5rem 0.8rem;
    }

    .otter-attach-btn svg,
    .otter-chat-submit svg {
        width: 18px;
        height: 18px;
    }
}

/* Animation for typewriter effect */
@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.otter-chat-input.typing-cursor::after {
    content: '|';
    animation: blink 1s infinite;
    color: var(--text-tertiary, #9ca3af);
}

/* Focus styles for accessibility */
.otter-chat-input:focus,
.otter-attach-btn:focus,
.otter-chat-submit:focus,
.otter-remove-file-btn:focus {
    outline: 2px solid var(--accent-primary, #2d7d7d);
    outline-offset: 2px;
}

/* Disabled state */
.otter-chat-form.disabled {
    opacity: 0.6;
    pointer-events: none;
}

/* Loading state */
.otter-chat-submit.loading {
    position: relative;
    color: transparent;
}

.otter-chat-submit.loading::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
    to { transform: rotate(360deg); }
}

/* Expansion modal - fullscreen overlay for both desktop and mobile */
.otter-mobile-text-popup {
    /* Force fullscreen positioning - override everything */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    min-width: 100vw !important;
    min-height: 100vh !important;

    /* Styling */
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);

    /* Z-index and display */
    z-index: 999999 !important;
    display: none;
    align-items: center;
    justify-content: center;

    /* Reset any inherited constraints */
    padding: 20px;
    margin: 0 !important;
    transform: none !important;
    clip-path: none !important;
    contain: none !important;
    isolation: auto !important;

    /* Touch handling */
    -webkit-overflow-scrolling: touch;
    touch-action: none;
}

.otter-mobile-text-popup[style*="display: block"] {
    display: flex !important;
}

/* Modal container */
.otter-modal-container {
    background: linear-gradient(135deg, #1a4d4d 0%, #2d7d7d 100%);
    border: 2px solid rgba(74, 153, 153, 0.4);
    border-radius: 20px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4),
                0 0 0 1px rgba(74, 153, 153, 0.2) inset;
    width: min(90vw, 900px);
    height: auto;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    -webkit-overflow-scrolling: touch;
    transition: all 0.3s ease;
}

[data-theme="dark"] .otter-modal-container {
    background: linear-gradient(135deg, #1a4d4d 0%, #2d7d7d 100%);
    border-color: rgba(74, 153, 153, 0.5);
}

/* Drag and drop active state */
.otter-modal-container.otter-drag-active {
    box-shadow: 0 0 0 3px var(--accent-primary, #2d7d7d);
    background: rgba(45, 125, 125, 0.02);
}

.otter-modal-container.otter-drag-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 3px dashed var(--accent-primary, #2d7d7d);
    border-radius: 20px;
    pointer-events: none;
    z-index: 9;
}

.otter-modal-container.otter-drag-active::after {
    content: '📁 Drop files here to attach';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    color: var(--accent-primary, #2d7d7d);
    font-weight: 600;
    pointer-events: none;
    z-index: 10;
    background: white;
    padding: 1rem 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(45, 125, 125, 0.2);
}

[data-theme="dark"] .otter-modal-container.otter-drag-active::after {
    background: #242424;
}

/* Modal header */
.otter-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.15);
}

.otter-modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: #ffffff;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .otter-modal-header h3 {
    color: #ffffff;
}

.otter-modal-close {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 2rem;
    line-height: 1;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

.otter-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.4);
}

/* Modal file preview */
.otter-modal-file-preview {
    margin: 1rem 2rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    display: none;
    animation: slideDown 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

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

[data-theme="dark"] .otter-modal-file-preview {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.otter-modal-file-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.otter-modal-file-icon {
    font-size: 1.5rem;
}

.otter-modal-file-name {
    flex: 1;
    color: #ffffff;
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

[data-theme="dark"] .otter-modal-file-name {
    color: #ffffff;
}

.otter-modal-remove-file {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.5rem;
    transition: all 0.2s;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.otter-modal-remove-file:hover {
    background: rgba(255, 107, 107, 0.2);
    color: #ff8b8b;
    border-color: rgba(255, 107, 107, 0.4);
}

/* Textarea */
.otter-mobile-textarea {
    width: 100%;
    min-height: 200px;
    height: auto;
    border: none;
    padding: 2rem;
    font-size: 1.25rem;
    line-height: 1.7;
    color: #ffffff;
    resize: none;
    font-family: inherit;
    background: rgba(0, 0, 0, 0.1);
    outline: none;
    -webkit-appearance: none;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
}

[data-theme="dark"] .otter-mobile-textarea {
    color: #ffffff;
}

.otter-mobile-textarea::placeholder {
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.1rem;
}

/* Actions bar */
.otter-mobile-popup-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: rgba(0, 0, 0, 0.2);
    border-top: 2px solid rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .otter-mobile-popup-actions {
    background: rgba(0, 0, 0, 0.2);
}

.otter-mobile-action-buttons {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.otter-mobile-action-left {
    display: flex;
    align-items: center;
}

.otter-mobile-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    padding: 10px 24px;
    border-radius: 8px;
    transition: all 0.2s;
    font-weight: 500;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-appearance: none;
}

.otter-mobile-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.otter-mobile-attach-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 10px 20px;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 1rem;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-appearance: none;
}

.otter-mobile-attach-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    color: #ffffff;
}

.otter-mobile-attach-btn span {
    font-weight: 500;
}

.otter-mobile-send-btn {
    background: linear-gradient(135deg, #4A9999 0%, #5fb3b3 100%);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 10px 32px;
    border-radius: 8px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-appearance: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.otter-mobile-send-btn:hover {
    background: linear-gradient(135deg, #5fb3b3 0%, #6fc9c9 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.otter-mobile-send-btn svg {
    width: 18px;
    height: 18px;
}

/* Custom styling variants */
.otter-input-bar-wrapper.compact .otter-chat-form {
    padding: 0.3rem;
    border-radius: 0.5rem;
}

.otter-input-bar-wrapper.compact .otter-chat-input {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

.otter-input-bar-wrapper.compact .otter-chat-submit {
    padding: 0.5rem 0.75rem;
}

.otter-input-bar-wrapper.large .otter-chat-form {
    padding: 0.75rem;
    border-radius: 1rem;
}

.otter-input-bar-wrapper.large .otter-chat-input {
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
}

.otter-input-bar-wrapper.large .otter-chat-submit {
    padding: 1rem 1.5rem;
}