:root {
    --sidebar-bg: #f9f9fb;
    --main-bg: #ffffff;
    --text-primary: #121212;
    --text-muted: #8e8e93;
    --border-color: #e5e5ea;
    --accent-color: #000000;
    --input-bg: #f4f4f4;
    --hover-bg: #ecececc9;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: var(--font-family);
    color: var(--text-primary);
    background-color: var(--main-bg);
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    transition: width 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    white-space: nowrap;
    overflow-x: hidden;
}

.sidebar.collapsed {
    width: 0;
    border-right: none;
}

.sidebar-header {
    padding: 1rem 1rem 0;
}

.model-selection select {
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Chat History List */
.chat-history-item {
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: background-color 0.15s;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-item:hover {
    background-color: var(--hover-bg);
}

.chat-history-item.active {
    background-color: #e5e5ea;
    font-weight: 500;
}

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

.avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* Main Chat Area */
.main-chat {
    background-color: var(--main-bg);
    transition: background-color 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.main-chat.drag-over {
    background-color: rgba(0, 0, 0, 0.03);
    position: relative;
}

.main-chat.drag-over::after {
    content: "이미지를 여기에 놓으세요";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 20px 40px;
    border-radius: 50px;
    border: 2px dashed #ccc;
    font-weight: bold;
    color: #666;
    pointer-events: none;
    z-index: 1000;
}

.chat-header {
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    z-index: 10;
    position: sticky;
    top: 0;
}

.chat-messages {
    scroll-behavior: smooth;
    padding-bottom: 2rem !important;
}

.message-row {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px 0;
    display: flex;
    gap: 16px;
}

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

.user-avatar {
    background-color: #f4f4f4;
    color: #666;
}

.ai-avatar {
    background-color: #000;
    color: #fff;
}

.message-content {
    flex-grow: 1;
    overflow-x: hidden;
    line-height: 1.6;
    font-size: 1rem;
}

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

.message-content p {
    margin-bottom: 1rem;
}

.message-content pre {
    background-color: #1e1e1e;
    color: #d4d4d4;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.9rem;
}

/* Code Block Styles with Headers */
.code-container {
    margin: 1.5rem 0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border: 1px solid rgba(0,0,0,0.1);
}

.copy-code-btn {
    transition: all 0.2s ease;
    font-weight: 500;
}

.copy-code-btn:hover {
    color: #fff !important;
}

.copy-code-btn:active {
    transform: scale(0.95);
}

.message-content pre code {
    font-family: 'Fira Code', 'Cascadia Code', 'Source Code Pro', Consolas, monospace;
}

.message-content code:not(pre code) {
    background-color: rgba(175, 184, 193, 0.2);
    padding: 0.2em 0.4em;
    border-radius: 6px;
    font-size: 85%;
}

.welcome-screen h3 {
    letter-spacing: -0.5px;
}

.example-card {
    background-color: var(--main-bg);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.example-card:hover {
    background-color: var(--input-bg);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.example-card:active {
    transform: translateY(0);
}

/* Message Images */
.message-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.message-images img {
    max-width: 300px;
    max-height: 300px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

/* Input Area */
.chat-input-area {
    background-color: transparent;
    padding-bottom: 24px !important;
}

.input-container {
    background-color: var(--input-bg);
    border-radius: 1.5rem;
    padding: 4px 8px 4px 12px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    display: flex;
    align-items: center; /* 기본적으로 중앙 정렬 */
}

.input-container:focus-within {
    background-color: #ffffff;
    border-color: #d1d1d6;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05) !important;
}

#message-input {
    background-color: transparent;
    resize: none;
    max-height: 200px;
    padding: 10px 12px;
    margin: 0;
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.5;
    flex-grow: 1;
}

#message-input::placeholder {
    color: #999;
}

.attachment-btn {
    width: 38px;
    height: 38px;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
    flex-shrink: 0;
    border-radius: 50% !important;
    transition: background-color 0.2s;
    color: var(--text-muted) !important;
    border: none !important;
    background: transparent !important;
    line-height: 1 !important;
    cursor: pointer;
}

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

.attachment-btn i {
    font-size: 1.1rem;
    line-height: 1;
}

#send-btn {
    background-color: var(--accent-color);
    width: 34px;
    height: 34px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px; /* 간격 소폭 조정 */
    transition: background-color 0.2s, opacity 0.2s;
}

#send-btn:disabled {
    background-color: #e5e5ea;
    color: #aeaeb2 !important;
    cursor: not-allowed;
    opacity: 0.7;
}

#stop-generation-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inference-notice {
    font-size: 11px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        z-index: 1050;
        height: 100vh;
        box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    }
    
    .main-chat {
        width: 100vw;
    }

    .message-row {
        padding: 16px;
        gap: 12px;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .message-content {
        font-size: 0.95rem;
    }

    .message-content pre {
        padding: 12px;
        font-size: 0.85rem;
    }

    .chat-input-area {
        padding: 12px !important;
    }

    .chat-header {
        padding: 12px 16px !important;
    }
    
    .input-container {
        padding: 6px 12px;
    }
    
    .message-images img {
        max-width: 200px;
        max-height: 200px;
    }
}

/* ===== 설정 모달 - 일반 설정 탭 섹션 카드 스타일 ===== */
.settings-section {
    border: 1px solid #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.settings-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #8e8e93;
    padding: 10px 16px 8px;
    border-bottom: 1px solid #f1f3f5;
    background: #fafafa;
}

.settings-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f3f5;
    transition: background 0.15s;
}

.settings-row:hover {
    background: #fafbfc;
}

.settings-row-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.settings-row-body {
    flex: 1;
    min-width: 0;
}

.settings-row-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #1c1c1e;
    white-space: nowrap;
}

.settings-row-desc {
    font-size: 0.73rem;
    color: #8e8e93;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.settings-row-control {
    flex-shrink: 0;
}
