/* Custom styles for Chat PWA */

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* PWA specific styles */
.pwa-install-prompt {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 1000;
}

.pwa-install-prompt.show {
    transform: translateY(0);
}

/* Message styles */
.message {
    max-width: 80%;
    word-wrap: break-word;
    animation: slideIn 0.3s ease-out;
}

.message.user {
    align-self: flex-end;
    margin-left: auto;
}

.message.assistant {
    align-self: flex-start;
    margin-right: auto;
}

.message-content {
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    position: relative;
}

.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message.assistant .message-content {
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 0.25rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 0.25rem;
}

.message.user .message-time {
    text-align: right;
}

.message.assistant .message-time {
    text-align: left;
}

/* File attachment styles */
.file-attachment {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    margin-top: 0.5rem;
}

.file-attachment .file-icon {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 0.25rem;
    margin-right: 0.75rem;
}

.file-attachment .file-info {
    flex: 1;
}

.file-attachment .file-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.file-attachment .file-size {
    font-size: 0.875rem;
    opacity: 0.8;
}

/* Media content styles */
.media-content {
    margin-top: 0.5rem;
    border-radius: 0.5rem;
    overflow: hidden;
}

.media-content img {
    max-width: 100%;
    height: auto;
    display: block;
}

.media-content video {
    max-width: 100%;
    height: auto;
    display: block;
}

.media-content audio {
    width: 100%;
}

/* HTML content rendering */
.html-content {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 0.5rem;
    border-left: 4px solid #667eea;
}

.html-content h1,
.html-content h2,
.html-content h3,
.html-content h4,
.html-content h5,
.html-content h6 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: #1f2937;
}

.html-content p {
    margin-bottom: 0.75rem;
}

.html-content ul,
.html-content ol {
    margin-bottom: 0.75rem;
    padding-left: 1.25rem;
}

.html-content pre {
    background: #f3f4f6;
    padding: 0.75rem;
    border-radius: 0.25rem;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
}

.html-content code {
    background: #f3f4f6;
    padding: 0.125rem 0.25rem;
    border-radius: 0.125rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
}

/* Voice recording animation */
@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.7;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.pulse {
    animation: pulse 1s infinite;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 1rem;
    border-bottom-left-radius: 0.25rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    margin-bottom: 1rem;
}

.typing-dots {
    display: flex;
    align-items: center;
}

.typing-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: #9ca3af;
    margin-right: 0.25rem;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {
    0%,
    80%,
    100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Slide in animation */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Connection status indicator */
.connection-status.connected {
    background-color: #10b981;
}

.connection-status.connecting {
    background-color: #f59e0b;
}

.connection-status.disconnected {
    background-color: #ef4444;
}

/* Mobile optimizations */
@media (max-width: 640px) {
    .message {
        max-width: 90%;
    }
    
    #messagesContainer {
        padding: 0.75rem;
    }
    
    .message-content {
        padding: 0.625rem 0.875rem;
    }
    
    .file-attachment {
        padding: 0.5rem;
    }
}

/* iOS specific styles */
@supports (-webkit-touch-callout: none) {
    body {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    input, textarea {
        -webkit-user-select: text;
        user-select: text;
    }
    
    /* Fix for iOS keyboard */
    .input-container {
        position: relative;
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Android specific styles */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    input[type="file"] {
        -webkit-appearance: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #111827;
        color: #f9fafb;
    }
    
    .message.assistant .message-content {
        background: #374151;
        color: #f9fafb;
        border-color: #4b5563;
    }
    
    #messagesContainer {
        background-color: #111827;
    }
    
    .html-content {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .typing-indicator {
        background: #374151;
    }
}