:root { --header-h: 60px; }
html, body { height: 100%; width: 100%; margin: 0; padding: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: auto; background-color: white; -webkit-tap-highlight-color: transparent; font-family: system-ui, -apple-system, sans-serif; }
@supports (-webkit-touch-callout: none) {
    body {
        height: -webkit-fill-available;
    }
}
body { display: flex; flex-direction: row; }
.hide-scrollbar::-webkit-scrollbar { width: 0px; height: 0px; }
.hide-scrollbar { scrollbar-width: none; }
.sidebar-transition { transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1); will-change: transform; }
#overlay { z-index: 100; }
#sidebar { z-index: 150; }
header { 
    z-index: 50;
    position: relative;
    width: 100%;
    height: var(--header-h);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transform: translateZ(0);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

#chatWindow {
    padding-top: 10px;
    margin-top: 0;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
.animate-msg { animation: slideUp 0.3s ease-out forwards; }
.safe-pb { padding-bottom: env(safe-area-inset-bottom); }

.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

#profilePopup {
    display: none;
    position: absolute;
    bottom: 70px;
    left: 10px;
    width: 220px;
    z-index: 9999;
    border-radius: 1.5rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

#logoutConfirm {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

#attachMenu {
    display: none;
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 200px;
    z-index: 60;
    border-radius: 1.2rem;
}

.action-icon {
    cursor: pointer;
    transition: color 0.2s;
    color: #9ca3af;
}
.action-icon:hover { color: #3b82f6; }

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #9ca3af;
    animation: typing 1.4s infinite;
}

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

@keyframes typing {
    0%, 60%, 100% { opacity: 0.5; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-10px); }
}

.chat-input-container {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    -webkit-tap-highlight-color: transparent;
}

textarea#chatInput {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    -webkit-appearance: none;
    background: transparent !important;
}

input:focus, textarea:focus, select:focus, button:focus {
    outline: none !important;
    box-shadow: none !important;
}

.image-preview {
    max-width: 300px;
    max-height: 300px;
    border-radius: 1rem;
    object-fit: cover;
    margin-top: 8px;
}

/* Attachment Preview Area */
#attachmentPreview {
    display: none;
    padding: 12px;
    width: 100%;
    position: relative;
}
.preview-item {
    position: relative;
    display: inline-block;
    width: 100px;
    height: 100px;
    border-radius: 16px;
    overflow: visible;
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 16px;
}
.preview-item .remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #1a1a1a;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    z-index: 10;
    border: 2px solid white;
}

/* AI Response Actions */
.msg-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    padding-right: 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.msg-actions:hover { opacity: 1; }
.action-btn {
    cursor: pointer;
    font-size: 13px;
    color: #666;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}
.action-btn:hover { color: #000; }
.action-btn i { font-size: 14px; }
.file-preview-icon {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f9f9f9;
    font-size: 24px;
    color: #666;
}
.file-preview-name {
    font-size: 8px;
    padding: 2px;
    text-align: center;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Model Selection Modal */
#modelModal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 400;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.model-modal-content {
    background: white;
    border-radius: 2rem;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 24px;
}

.model-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.model-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.model-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6b7280;
    transition: color 0.2s;
}

.model-modal-close:hover {
    color: #1f2937;
}

.models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.model-card {
    padding: 16px;
    border: 2px solid #e5e7eb;
    border-radius: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    background: white;
}

.model-card:hover {
    border-color: #000;
    background: #f9f9f9;
    transform: translateY(-2px);
}

.model-card.selected {
    border-color: #000;
    background: #000;
    color: white;
}

.model-card-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.model-card-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.model-card-desc {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.3;
}

.model-card.selected .model-card-desc {
    color: #d1d5db;
}

.model-modal-footer {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.model-modal-footer button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.model-modal-footer .btn-cancel {
    background: #f3f4f6;
    color: #1f2937;
}

.model-modal-footer .btn-cancel:hover {
    background: #e5e7eb;
}

.model-modal-footer .btn-confirm {
    background: #000;
    color: white;
}

.model-modal-footer .btn-confirm:hover {
    background: #1f2937;
}

/* New Attachment Menu Styles */
.new-attach-menu {
    position: absolute;
    bottom: 70px;
    left: 0;
    width: 280px;
    z-index: 200;
    border-radius: 2rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.attach-item {
    transition: all 0.2s;
}

.attach-item:active {
    transform: scale(0.98);
    background-color: #f3f4f6;
}

/* Floating Preview Styles */
#attachmentPreview {
    z-index: 50;
}

.floating-preview {
    position: relative;
    width: 120px;
    height: 120px;
    background: white;
    border-radius: 1.5rem;
    padding: 4px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    border: 1px solid rgba(0,0,0,0.05);
}

.floating-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 1.2rem;
    cursor: pointer;
}

.floating-preview .remove-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #f3f4f6;
    color: #000;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Image Viewer */
#imageViewer {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

#viewerImg {
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
