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

:root {
    --primary-color: #1a73e8;
    --primary-hover: #1557b0;
    --bg-primary: #131314;
    --bg-secondary: #1e1f20;
    --bg-tertiary: #282a2c;
    --bg-hover: #3c4043;
    --text-primary: #e3e3e3;
    --text-secondary: #9aa0a6;
    --text-muted: #6e7275;
    --border-color: #3c4043;
    --user-bubble: #1a73e8;
    --ai-bubble: #1e1f20;
    --success-color: #34a853;
    --warning-color: #fbbc04;
    --error-color: #ea4335;
    --sidebar-width: 280px;
}

body {
    font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar.hidden {
    transform: translateX(-100%);
    position: absolute;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.new-chat-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.new-chat-btn:hover {
    background: var(--bg-hover);
}

.new-chat-btn .icon {
    font-size: 18px;
}

/* Conversation List */
.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-bottom: 4px;
}

.conversation-item:hover {
    background: var(--bg-hover);
}

.conversation-item.active {
    background: var(--bg-tertiary);
}

.conversation-item .conv-icon {
    font-size: 18px;
}

.conversation-item .conv-title {
    flex: 1;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item .conv-delete {
    opacity: 0;
    padding: 4px 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.conversation-item:hover .conv-delete {
    opacity: 1;
}

.conversation-item .conv-delete:hover {
    background: var(--error-color);
    color: white;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.clear-all-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-all-btn:hover {
    background: var(--error-color);
    border-color: var(--error-color);
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.menu-toggle {
    display: none;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    border-radius: 8px;
}

.menu-toggle:hover {
    background: var(--bg-hover);
}

.header-title h1 {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
}

.header-title .subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

.header-actions {
    margin-left: auto;
}

/* Custom Select Dropdown */
.custom-select {
    position: relative;
    user-select: none;
    z-index: 200;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    white-space: nowrap;
    min-width: 210px;
}

.custom-select-trigger:hover,
.custom-select.open .custom-select-trigger {
    background: var(--bg-hover);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

.select-icon {
    font-size: 15px;
    line-height: 1;
    flex-shrink: 0;
}

.select-text {
    flex: 1;
}

.select-chevron {
    width: 15px;
    height: 15px;
    color: var(--text-secondary);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.custom-select.open .select-chevron {
    transform: rotate(180deg);
    color: var(--primary-color);
}

.custom-select-options {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 2px 10px rgba(0, 0, 0, 0.3);
    transform-origin: top right;
    transform: scale(0.94) translateY(-6px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.15s ease;
    padding: 6px;
}

.custom-select.open .custom-select-options {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

.select-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.select-option:hover {
    background: var(--bg-hover);
}

.select-option.selected {
    color: var(--primary-color);
    background: rgba(26, 115, 232, 0.12);
    font-weight: 600;
}

.select-option.selected::after {
    content: '✓';
    margin-left: auto;
    font-size: 13px;
    opacity: 0.8;
}

.option-icon {
    font-size: 15px;
    line-height: 1;
    flex-shrink: 0;
}

.option-label {
    flex: 1;
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.chat-messages {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    padding: 40px 20px;
}

.welcome-screen .welcome-icon {
    font-size: 64px;
    margin-bottom: 24px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.welcome-screen h2 {
    font-size: 28px;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.welcome-screen p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    max-width: 500px;
}

.quick-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
    flex-wrap: wrap;
    justify-content: center;
    .quick-action-btn {
        padding: 10px 18px;
        border-radius: 20px;
        background: var(--bg-tertiary);
        border: 1px solid var(--border-color);
        color: var(--text-primary);
        cursor: pointer;
        font-weight: 500;
    }

    .quick-action-btn:hover {
        background: var(--bg-hover);
    }

    .quick-action-btn.active {
        background: rgba(26, 115, 232, 0.12);
        color: var(--primary-color);
        border-color: rgba(26, 115, 232, 0.3);
        box-shadow: 0 4px 14px rgba(26,115,232,0.06);
    }
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.quick-tips {
    text-align: left;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px 24px;
    max-width: 450px;
}

.quick-tips p {
    margin-bottom: 12px;
    color: var(--text-primary);
}

.quick-tips ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.quick-tips li {
    padding: 8px 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.quick-tips li::before {
    content: "•";
    color: var(--primary-color);
    margin-right: 10px;
}

/* Message Styles */
.message {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
}

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

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--user-bubble);
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.message-content {
    max-width: 80%;
    min-width: 100px;
}

.message.user .message-content {
    background: var(--user-bubble);
    border-radius: 20px 20px 4px 20px;
    padding: 14px 18px;
}

.message.assistant .message-content {
    background: var(--ai-bubble);
    border: 1px solid var(--border-color);
    border-radius: 20px 20px 20px 4px;
    padding: 18px 22px;
}

.message-text {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
}

.message-text p {
    margin-bottom: 12px;
}

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

.message-text ul, .message-text ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-text li {
    margin-bottom: 6px;
}

.message-text code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Roboto Mono', monospace;
    font-size: 13px;
}

.message-text pre {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-text pre code {
    background: transparent;
    padding: 0;
}

.message-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
}

.message-text th, .message-text td {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.message-text th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.message-text strong {
    color: var(--primary-color);
    font-weight: 600;
}

.message-text h1, .message-text h2, .message-text h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.message-text h1 { font-size: 1.4rem; }
.message-text h2 { font-size: 1.2rem; }
.message-text h3 { font-size: 1.1rem; }

/* File Attachments in Message */
.message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.attachment-preview {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
}

.attachment-preview img {
    max-width: 200px;
    max-height: 150px;
    object-fit: cover;
    display: block;
    border-radius: 12px;
    transition: transform 0.2s ease;
}

.attachment-preview:hover img {
    transform: scale(1.02);
}

.attachment-preview.pdf {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.attachment-preview.pdf .pdf-icon {
    font-size: 24px;
}

.attachment-preview.pdf .pdf-name {
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Loading Message */
.message.loading .message-content {
    padding: 20px;
}

.typing-indicator {
    display: flex;
    gap: 6px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.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.4;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Input Area */
.input-area {
    padding: 16px 24px 24px;
    background: var(--bg-primary);
}

.file-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.file-preview-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.file-preview-item img {
    max-width: 100px;
    max-height: 80px;
    object-fit: cover;
    display: block;
}

.file-preview-item.pdf-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
}

.file-preview-item .pdf-icon {
    font-size: 24px;
}

.file-preview-item .file-name {
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview-item .remove-file {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-preview-item .remove-file:hover {
    background: var(--error-color);
}

/* Prompt Template Container */
.prompt-template-container {
    max-width: 900px;
    margin: 0 auto 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.prompt-template-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    cursor: pointer;
}

.prompt-template-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.toggle-prompt-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.toggle-prompt-btn:hover {
    background: var(--bg-hover);
}

.prompt-template-textarea {
    width: 100%;
    background: var(--bg-secondary);
    border: none;
    border-top: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.6;
    padding: 12px 16px;
    resize: vertical;
    min-height: 100px;
    max-height: 300px;
    outline: none;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.prompt-template-textarea::placeholder {
    color: var(--text-muted);
}

.prompt-template-container.collapsed .prompt-template-textarea {
    display: none;
}

.prompt-template-container.collapsed .toggle-prompt-btn {
    transform: rotate(-90deg);
}

.input-box {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    max-width: 900px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 28px;
    padding: 8px 16px;
    transition: border-color 0.2s ease;
}

.input-box:focus-within {
    border-color: var(--primary-color);
}

.input-actions-left, .input-actions-right {
    display: flex;
    align-items: center;
}

.attach-btn {
    padding: 10px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attach-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.input-wrapper {
    flex: 1;
}

.input-wrapper textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: 200px;
    padding: 8px 0;
}

.input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.send-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

.send-btn:not(:disabled):hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.send-icon {
    transform: rotate(-45deg);
}

.input-hint {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    cursor: pointer;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from {
        transform: scale(0.7);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 36px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: #bbb;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        z-index: 100;
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .menu-toggle {
        display: block;
    }
    
    .chat-header {
        padding: 12px 16px;
    }
    
    .header-title h1 {
        font-size: 16px;
    }
    
    .chat-messages {
        padding: 16px;
    }
    
    .message-content {
        max-width: 90%;
    }
    
    .input-area {
        padding: 12px 16px 20px;
    }
    
    .quick-actions {
        flex-direction: column;
    }
    
    .quick-action-btn {
        width: 100%;
    }
}

/* Error Message */
.error-message {
    background: var(--error-color);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    margin: 12px 0;
    font-size: 14px;
}
