/* ===== Global layout ===== */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
        sans-serif;
    background-color: #343541;
    color: #ececf1;
}

body {
    display: flex;
}

.app {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* ===== Sidebar (ChatGPT-like) ===== */

.sidebar {
    width: 260px;
    background-color: #202123;
    color: #ececf1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #2f3136;
}

.sidebar-header {
    padding: 12px 16px;
    border-bottom: 1px solid #2f3136;
}

.sidebar-title {
    font-weight: 600;
    font-size: 15px;
}

.sidebar-body {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;   /* 아이콘과 글씨 간격 */
}

.sidebar-icon {
    width: 20px;       /* 원하는 크기 */
    height: 20px;
}

.new-chat-btn {
    width: 100%;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid #565869;
    background: #202123;
    color: #ececf1;
    cursor: pointer;
    font-size: 14px;
    text-align: left;
}

.new-chat-btn:hover {
    background-color: #2a2b32;
}

.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid #2f3136;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-avatar {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background-color: #10a37f;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}

.sidebar-username {
    font-size: 13px;
    color: #d1d5db;
}

/* ===== Chat main area ===== */

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 100%;
}

.chat-header {
    padding: 12px 24px;
    border-bottom: 1px solid #2f3136;
    background-color: #343541;
}

.chat-header-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.chat-header-subtitle {
    font-size: 12px;
    color: #9ca3af;
}

/* ===== Chat window ===== */

.chat-window {
    flex: 1;
    padding: 16px 24px 80px;
    overflow-y: auto;
}

/* message rows */

.message-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
}

/* Avatars */

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.user-avatar {
    background-color: #10a37f;
    color: #ffffff;
}

.assistant-avatar {
    background-color: #5436da;
    color: #ffffff;
}

/* Message bubbles */

.message {
    max-width: min(750px, 100%);
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message.user {
    background-color: #10a37f;
    color: #ffffff;
    margin-left: auto;
    margin-right: 0;
}

.message.server {
    background-color: #444654;
    color: #ececf1;
}
.message > p{
    margin: 0;
}

/* Align user to the right (ChatGPT style) */

.message-row.user {
    justify-content: flex-end;
}

.message-row.user .avatar {
    order: 2;
}

.message-row.user .message {
    order: 1;
}

/* Thinking indicator */

.thinking-indicator {
    padding: 0 24px 12px;
}

.thinking-indicator.hidden {
    display: none;
}

.thinking-bubble {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* three dots animation */

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #d1d5db;
    display: inline-block;
    animation: blink 1.2s infinite ease-in-out;
}

.dot:nth-child(2) {
    animation-delay: 0.2s;
}

.dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes blink {
    0%,
    80%,
    100% {
        opacity: 0.3;
        transform: scale(1);
    }
    40% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* ===== Composer ===== */

.chat-composer {
    position: relative;
    padding: 12px 24px 20px;
    border-top: 1px solid #2f3136;
    background: linear-gradient(
        to top,
        rgba(52, 53, 65, 1),
        rgba(52, 53, 65, 0.95)
    );
}

.input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    background-color: #40414f;
    border-radius: 12px;
    border: 1px solid #565869;
    max-width: 900px;
    margin: 0 auto;
}

#chat-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    background: transparent;
    color: #ececf1;
    font-size: 14px;
    max-height: 150px;
    line-height: 1.5;
}

#chat-input::placeholder {
    color: #9ca3af;
}

.send-btn {
    border: none;
    border-radius: 999px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #10a37f;
    color: #ffffff;
    cursor: pointer;
    font-size: 14px;
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.chat-hint {
    margin-top: 6px;
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
}

/* ===== Toast ===== */

.toast {
    position: fixed;
    bottom: 16px;
    right: 16px;
    background-color: #1f2933;
    color: #f9fafb;
    padding: 10px 14px;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    font-size: 13px;
    z-index: 9999;
    opacity: 0;
    animation: toast-in 0.25s forwards, toast-out 0.25s 2.6s forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateY(8px);
    }
}

/* small helper for changed state (stateUpdate) */

.changed {
    animation: flash 0.5s;
}

@keyframes flash {
    from {
        background-color: rgba(16, 163, 127, 0.2);
    }
    to {
        background-color: transparent;
    }
}

/* Scrollbar styling */

.chat-window::-webkit-scrollbar {
    width: 8px;
}

.chat-window::-webkit-scrollbar-track {
    background: #343541;
}

.chat-window::-webkit-scrollbar-thumb {
    background: #565869;
    border-radius: 4px;
}
