/* style.css - Стили SFRmatrix (Mobile Responsive) */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: #0f0f0f;
    color: #ffffff;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: rgba(20, 20, 20, 0.5);
    backdrop-filter: blur(20px);
    border-right: 1px solid #2a2a2a;
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 1000;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 3px;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 8px;
}

.logo {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1001;
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.menu-toggle:hover {
    background: #3a3a3a;
}

.menu-toggle .menu-icon {
    color: #fff;
    font-size: 24px;
    display: block;
    line-height: 1;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Model Selector */
.model-selector {
    position: relative;
}

.model-btn {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    color: #fff;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.model-btn:hover {
    background: #333;
}

.model-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.model-arrow {
    font-size: 10px;
    transition: transform 0.2s;
}

.model-btn.open .model-arrow {
    transform: rotate(180deg);
}

.model-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    min-width: 180px;
    display: none;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.model-dropdown.active {
    display: block;
}

.model-option {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.model-option:hover {
    background: #333;
}

.model-option:first-child {
    border-radius: 8px 8px 0 0;
}

.model-option:last-child {
    border-radius: 0 0 8px 8px;
}

.model-option.selected {
    background: #1a5a3a;
}

.model-name {
    font-weight: 500;
}

.model-desc {
    font-size: 11px;
    color: #888;
}

/* Mode Selector */
.mode-selector {
    margin-bottom: 12px;
}

.mode-selector label {
    display: block;
    font-size: 11px;
    color: #888;
    margin-bottom: 6px;
    padding: 0 8px;
}

.mode-select {
    width: 100%;
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    color: #fff;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.mode-select:hover {
    background-color: #2a2a2a;
    border-color: #4a4a4a;
}

.mode-select:focus {
    outline: none;
    border-color: #4a9a6a;
}

/* Custom Prompt Settings */
.custom-prompt-settings {
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    animation: slideDown 0.3s ease;
}

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

.prompt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.prompt-header label {
    font-size: 11px;
    color: #888;
    margin: 0;
}

.prompt-save-btn {
    background: transparent;
    border: 1px solid #3a3a3a;
    color: #888;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.prompt-save-btn:hover {
    background: #2a8a5a;
    border-color: #2a8a5a;
    color: #fff;
}

.custom-prompt-input {
    width: 100%;
    background: #0f0f0f;
    border: 1px solid #3a3a3a;
    color: #fff;
    padding: 8px;
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    margin-bottom: 8px;
}

.custom-prompt-input:focus {
    outline: none;
    border-color: #4a9a6a;
}

.custom-prompt-input::placeholder {
    color: #666;
}

/* Saved Prompts */
.saved-prompts {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
}

.saved-prompts::-webkit-scrollbar {
    width: 4px;
}

.saved-prompts::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 2px;
}

.saved-prompt-item {
    background: #0f0f0f;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    padding: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.saved-prompt-item:hover {
    background: #2a2a2a;
    border-color: #4a4a4a;
}

.saved-prompt-item.active {
    background: #1a5a3a;
    border-color: #2a8a5a;
}

.saved-prompt-text {
    flex: 1;
    font-size: 11px;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.delete-prompt-btn {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    transition: color 0.2s;
}

.delete-prompt-btn:hover {
    color: #ff4444;
}

/* Multi-AI Toggle */
.multi-ai-toggle {
    padding: 10px;
    margin-bottom: 12px;
    background: transparent;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.multi-ai-toggle:hover:not(.disabled) {
    background: #1a1a1a;
}

.multi-ai-toggle.active {
    background: #1a5a3a;
    border-color: #2a8a5a;
}

.multi-ai-toggle.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: transparent;
}

.toggle-switch {
    width: 36px;
    height: 20px;
    background: #3a3a3a;
    border-radius: 10px;
    position: relative;
    transition: background 0.3s;
    flex-shrink: 0;
}

.multi-ai-toggle.active .toggle-switch {
    background: #4a9a6a;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: left 0.3s;
}

.multi-ai-toggle.active .toggle-switch::after {
    left: 18px;
}

.toggle-label {
    font-size: 12px;
    color: #fff;
    flex: 1;
}

/* Buttons */
.new-chat-btn {
    width: 100%;
    background: transparent;
    border: 1px solid #3a3a3a;
    color: #fff;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    margin-bottom: 12px;
    transition: all 0.2s;
    min-height: 44px;
}

.new-chat-btn:hover {
    background: #2a2a2a;
}

/* Search */
.search-box {
    width: 100%;
    background: transparent;
    border: 1px solid #3a3a3a;
    color: #fff;
    padding: 10px;
    border-radius: 8px;
    font-size: 11px;
    margin-bottom: 10px;
    min-height: 44px;
}

.search-box::placeholder {
    color: #666;
}

/* Chats List */
.chats-header {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    margin-bottom: 8px;
}

.chats-header span {
    font-size: 11px;
    color: #888;
}

.clear-btn {
    cursor: pointer;
    transition: color 0.2s;
    padding: 4px 8px;
}

.clear-btn:hover {
    color: #fff;
}

.chats-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
}

.chats-list::-webkit-scrollbar {
    width: 6px;
}

.chats-list::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 3px;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px;
    margin-bottom: 2px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
    position: relative;
    min-height: 44px;
}

.chat-item:hover {
    background: #1a1a1a;
}

.chat-item.active {
    background: #1a1a1a;
}

.chat-item-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.delete-chat-btn {
    display: none;
    color: #666;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 12px;
    transition: color 0.2s;
}

.chat-item:hover .delete-chat-btn {
    display: block;
}

.delete-chat-btn:hover {
    color: #ff4444;
}

/* Auth Container */
.auth-container {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #2a2a2a;
}

.auth-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-btn {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #3a3a3a;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    min-height: 44px;
}

.auth-btn:hover {
    background: #2a2a2a;
}

.login-btn {
    border-color: #4a9a6a;
}

.register-btn {
    background: #2a8a5a;
    border-color: #2a8a5a;
}

.profile-btn {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #3a3a3a;
    background: #1a1a1a;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    min-height: 44px;
}

.profile-avatar {
    font-size: 20px;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0f0f0f;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 4px;
}

.welcome-message {
    margin: auto;
    text-align: center;
    color: #888;
    font-size: 20px;
}

/* Messages */
.message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease-in;
}

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

.message.user {
    justify-content: flex-end;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    background: #2a2a2a;
}

.message.user .message-avatar {
    order: 2;
    background: #3a3a3a;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 70%;
}

.message.user .message-content {
    align-items: flex-end;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.user .message-bubble {
    background: #2a2a2a;
    color: #fff;
}

.message.assistant .message-bubble {
    background: #1a1a1a;
    color: #fff;
}

.message.loading .message-bubble {
    background: #1a1a1a;
    color: #888;
}

/* Message Images */
.message-image {
    max-width: 100%;
    border-radius: 12px;
    margin-bottom: 8px;
}

/* Image Preview */
.image-preview-container {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
}

.image-preview {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #3a3a3a;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-image {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.remove-image:hover {
    background: #ff4444;
}

/* Multi-AI Response */
.multi-ai-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.ai-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.ai-tab {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    min-height: 40px;
}

.ai-tab:hover {
    background: #333;
}

.ai-tab.active {
    background: #1a5a3a;
    border-color: #2a8a5a;
}

.ai-tab.loading {
    opacity: 0.6;
    cursor: wait;
}

.ai-tab-icon {
    font-size: 16px;
}

.ai-tab-name {
    font-weight: 500;
}

.ai-responses {
    position: relative;
}

.ai-response {
    display: none;
}

.ai-response.active {
    display: block;
}

/* Code Blocks */
.message-bubble pre {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 0;
    margin: 8px 0;
    overflow: hidden;
}

.code-header {
    background: #2a2a2a;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #3a3a3a;
}

.code-language {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
}

.copy-btn {
    background: transparent;
    border: 1px solid #3a3a3a;
    color: #888;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
    min-height: 32px;
}

.copy-btn:hover {
    background: #3a3a3a;
    color: #fff;
}

.copy-btn.copied {
    background: #1a5a3a;
    border-color: #2a8a5a;
    color: #fff;
}

.message-bubble pre code {
    display: block;
    padding: 12px;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.message-bubble p {
    margin: 6px 0;
}

.message-bubble p:first-child {
    margin-top: 0;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

/* Markdown форматирование */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3 {
    margin: 12px 0 6px 0;
    font-weight: 600;
    line-height: 1.3;
}

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

.message-bubble h1 {
    font-size: 18px;
    border-bottom: 1px solid #3a3a3a;
    padding-bottom: 6px;
    color: #fff;
}

.message-bubble h2 {
    font-size: 16px;
    color: #fff;
}

.message-bubble h3 {
    font-size: 15px;
    color: #eee;
}

.message-bubble strong {
    font-weight: 600;
    color: #fff;
}

.message-bubble em {
    font-style: italic;
    color: #ddd;
}

.message-bubble code {
    background: #2a2a2a;
    color: #4a9a6a;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
}

.message-bubble ul,
.message-bubble ol {
    margin: 6px 0;
    padding-left: 20px;
}

.message-bubble ul {
    list-style-type: disc;
}

.message-bubble ol {
    list-style-type: decimal;
}

.message-bubble li {
    margin: 2px 0;
    line-height: 1.5;
    padding-left: 4px;
}

.message-bubble ul li,
.message-bubble ol li {
    margin-bottom: 4px;
}

.message-bubble ul li:last-child,
.message-bubble ol li:last-child {
    margin-bottom: 0;
}

.message-bubble hr {
    border: none;
    border-top: 1px solid #3a3a3a;
    margin: 12px 0;
}

.message-bubble blockquote {
    border-left: 3px solid #4a9a6a;
    padding-left: 12px;
    margin: 8px 0;
    color: #aaa;
    font-style: italic;
}

/* Убираем лишние <br> внутри блочных элементов */
.message-bubble h1 br,
.message-bubble h2 br,
.message-bubble h3 br,
.message-bubble li br:last-child {
    display: none;
}

/* Уменьшаем отступы у параграфов рядом со списками */
.message-bubble p + ul,
.message-bubble p + ol {
    margin-top: 4px;
}

.message-bubble ul + p,
.message-bubble ol + p {
    margin-top: 8px;
}


/* Input Area */
.input-area {
    padding: 8px 16px 12px 16px;
    border-top: 1px solid #2a2a2a;
    background: #0f0f0f;
    position: relative;
}

.input-container {
    display: flex;
    gap: 8px;
    max-width: 900px;
    margin: 0 auto;
    align-items: flex-end;
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 24px;
    padding: 8px 8px 8px 16px;
    transition: border-color 0.2s;
}

.input-container:focus-within {
    border-color: #4a4a4a;
}

.input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-input {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 14px;
    resize: none;
    font-family: inherit;
    min-height: 24px;
    max-height: 200px;
    outline: none;
}

.message-input::placeholder {
    color: #666;
}

.input-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.attach-btn, .send-btn {
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.attach-btn {
    font-size: 0;
}

.attach-btn::before {
    content: '';
    width: 20px;
    height: 20px;
    display: block;
    background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.attach-btn:hover {
    background: #2a2a2a;
}

.attach-btn:hover::before {
    background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.send-btn {
    background: #fff;
    color: #000;
    font-size: 20px;
}

.send-btn:hover {
    background: #e0e0e0;
}

.send-btn:disabled {
    background: #3a3a3a;
    color: #666;
    cursor: not-allowed;
}

#imageInput {
    display: none;
}

/* Limits Display */
#limitsDisplay {
    padding: 8px 12px;
    background: rgba(42, 42, 42, 0.5);
    border-radius: 8px;
    margin: 8px 0;
    font-size: 11px;
    color: #fff;
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

@media screen and (max-width: 768px) {
    /* Show mobile menu toggle */
    .menu-toggle {
        display: flex;
    }
    
    /* Hide sidebar by default on mobile */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        width: 280px;
        max-width: 85vw;
        background: rgba(20, 20, 20, 0.98);
        z-index: 1001;
    }
    
    /* Show sidebar when open */
    .sidebar.open {
        transform: translateX(0);
    }
    
    /* Show overlay when sidebar is open */
    .sidebar-overlay.active {
        display: block;
    }
    
    /* Chat area takes full width */
    .chat-area {
        width: 100%;
    }
    
    /* Messages container padding - меньше отступов */
    .messages-container {
        padding: 65px 10px 8px 10px;
    }
    
    /* Welcome message higher up */
    .welcome-message {
        margin-top: 20vh;
    }
    
    /* Message content max width */
    .message-content {
        max-width: 85%;
    }
    
    /* Welcome message */
    .welcome-message {
        font-size: 18px;
        padding: 0 20px;
    }
    
    /* Input area - поднимаем максимально высоко */
    .input-area {
        padding: 6px 8px 8px 8px;
        position: sticky;
        bottom: 0;
    }
    
    .input-container {
        border-radius: 20px;
        padding: 4px 4px 4px 12px;
    }
    
    /* Message input */
    .message-input {
        font-size: 16px; /* Prevents zoom on iOS */
        max-height: 150px;
    }
    
    /* Buttons */
    .attach-btn, .send-btn {
        width: 40px;
        height: 40px;
    }
    
    /* Model dropdown */
    .model-dropdown {
        left: 0;
        right: auto;
        min-width: 200px;
        max-width: 90vw;
    }
    
    /* Multi-AI tabs scroll */
    .ai-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
    
    .ai-tabs::-webkit-scrollbar {
        height: 4px;
    }
    
    .ai-tabs::-webkit-scrollbar-thumb {
        background: #3a3a3a;
        border-radius: 2px;
    }
    
    .ai-tab {
        flex-shrink: 0;
    }
    
    /* Image preview */
    .image-preview {
        width: 70px;
        height: 70px;
    }
    
    /* Code blocks */
    .message-bubble pre code {
        font-size: 12px;
    }
    
    /* Logo */
    .logo {
        font-size: 18px;
    }
}

@media screen and (max-width: 480px) {
    /* Extra small screens */
    .messages-container {
        padding: 70px 8px 8px 8px;
        gap: 12px;
    }
    
    .message {
        gap: 8px;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
    
    .message-bubble {
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .message-content {
        max-width: 90%;
    }
    
    .welcome-message {
        font-size: 16px;
    }
    
    .input-area {
        padding: 8px;
    }
    
    .input-container {
        padding: 6px 6px 6px 12px;
    }
    
    .attach-btn, .send-btn {
        width: 36px;
        height: 36px;
    }
    
    .image-preview {
        width: 60px;
        height: 60px;
    }
    
    .menu-toggle {
        width: 40px;
        height: 40px;
        top: 12px;
        left: 12px;
    }
}

/* Landscape mode on mobile */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .messages-container {
        padding: 60px 12px 12px 12px;
    }
    
    .message-input {
        max-height: 100px;
    }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
    /* Increase tap targets for touch devices */
    .chat-item {
        min-height: 48px;
        padding: 14px 12px;
    }
    
    .new-chat-btn,
    .search-box,
    .auth-btn,
    .profile-btn {
        min-height: 48px;
    }
    
    .model-option {
        padding: 12px 14px;
    }
    
    .ai-tab {
        min-height: 44px;
    }
    
    /* Show delete button always on touch devices */
    .delete-chat-btn {
        display: block;
    }
}

/* Dark mode adjustments (if needed) */
@media (prefers-color-scheme: dark) {
    /* Already dark by default */
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    .sidebar {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
    
    .input-area {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
    
    .menu-toggle {
        left: max(16px, env(safe-area-inset-left));
        top: max(16px, env(safe-area-inset-top));
    }
    
    .messages-container {
        padding-top: max(65px, calc(65px + env(safe-area-inset-top)));
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
}
