body,
html {
    height: 100%;
    margin: 0;
    font-family: 'Poppins', Arial, Helvetica, sans-serif;
    background: #17181e;
    color: #e9ecef;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    background: #17181e;
}

.sidebar {
    background: #20222a;
    color: #e9ecef;
    min-width: 260px;
    border-right: 1.5px solid #23242a;
    display: flex;
    flex-direction: column;
    padding: 0 0 10px 0;
    z-index: 10;
}

.sidebar-header {
    padding: 24px 0 12px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #20222a;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-container h1 {
    color: #72b7ff;
    font-size: 1.2em;
    margin: 0;
}

.new-chat-btn {
    background: #376cf2;
    color: #fff;
    border-radius: 8px;
    border: none;
    padding: 12px 0;
    margin: 18px 0 0 0;
    font-weight: 500;
    font-size: 1em;
    width: 90%;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.new-chat-btn:hover {
    background: #295ad4;
}

.settings {
    padding: 16px 14px 4px 14px;
    border-top: 1.5px solid #23242a;
}

.settings-item {
    margin-bottom: 12px;
}

.settings-item label {
    display: block;
    color: #adbed3;
    font-size: .96em;
    margin-bottom: 3px;
}

#server-input,
#model-select {
    background: #262932;
    color: #e9ecef;
    border: 1px solid #31333a;
    border-radius: 7px;
    font-size: 1em;
    width: calc(100% - 20px);
    padding: 8px 10px;
    margin-top: 2px;
    box-sizing: border-box;
}

#server-input:focus,
#model-select:focus {
    border-color: #72b7ff;
    outline: none;
}

#server-input[readonly] {
    background: #23242a;
    color: #a0a7b6;
    border: 1px solid #282a31;
    cursor: default;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px 0 14px;
    font-size: 0.97em;
    color: #bfc9de;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    margin-bottom: 8px;
    background: #262932;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    word-break: break-all;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item:hover {
    background-color: #31333a;
    transform: translateY(-1px);
}

.history-item.active {
    background-color: #376cf2;
    font-weight: 500;
}

.history-item i {
    color: #adbed3;
}

.history-item.active i {
    color: #fff;
}


.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

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

.footer {
    background: #17181e;
    color: #c6d4ef;
    border-top: 1.5px solid #23242a;
    font-size: 1em;
    text-align: center;
    padding: 10px 0 10px 0;
    flex-shrink: 0;
}

.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    background: rgba(17, 19, 26, 0.85);
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    border: 6px solid #3c4251;
    border-top: 6px solid #72b7ff;
    border-radius: 50%;
    width: 54px;
    height: 54px;
    animation: spin 1s linear infinite;
    margin-bottom: 22px;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

.loading-text {
    color: #bfc9de;
    font-size: 1.14em;
    text-align: center;
}

.chat-input-wrapper {
    background: #23242a;
    border-top: 1.5px solid #23242a;
    padding: 16px 10px 16px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: sticky;
    bottom: 0;
    width: 100%;
    box-sizing: border-box;
}

#chat-form {
    display: flex;
    width: 100%;
    margin-bottom: 15px;
}

.input-container {
    display: flex;
    align-items: flex-end;
    width: 100%;
    gap: 12px;
    background: #23242a;
    border-radius: 8px;
    border: 1.5px solid #376cf2;
    padding: 0;
}

#message-input {
    background: #23242a;
    color: #fff;
    border: none;
    border-radius: 8px;
    resize: none;
    font-size: 1em;
    min-height: 44px;
    max-height: 120px;
    padding: 12px 16px;
    outline: none;
    width: 100%;
    box-sizing: border-box;
    transition: border 0.18s;
    line-height: 1.5;
    flex-grow: 1;
}

#message-input:focus {
    background: #282a31;
}

.send-btn {
    background: #376cf2;
    border-radius: 8px;
    color: #fff;
    border: none;
    font-size: 1.45em;
    padding: 11px 15px 11px 15px;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

.send-btn:hover {
    background: #72b7ff;
    color: #23242a;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    width: 100%;
}

.action-btn {
    background: #262932;
    color: #adbed3;
    border: 1px solid #31333a;
    border-radius: 7px;
    padding: 10px 18px;
    font-size: 0.9em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.action-btn:hover {
    background-color: #31333a;
    color: #e9ecef;
}


.chat-message {
    max-width: 62vw;
    min-width: 160px;
    margin-bottom: 11px;
    padding: 0;
    font-size: 1em;
    border-radius: 15px;
    word-break: break-word;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    box-shadow: 0 2px 12px 0 #0e101680;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chat-message.user {
    align-self: flex-end;
    background: #2547ad;
    color: #fff;
    border-bottom-right-radius: 6px;
    border-top-right-radius: 18px;
    border-top-left-radius: 18px;
    border-bottom-left-radius: 18px;
    margin-right: 15px;
    margin-left: 48px;
    padding: 14px 20px 14px 20px;
}

.chat-message.ai {
    align-self: flex-start;
    background: #23242a;
    color: #e9ecef;
    border-bottom-left-radius: 6px;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    border-bottom-right-radius: 18px;
    margin-left: 15px;
    margin-right: 48px;
    padding: 14px 20px 14px 20px;
}

.copy-btn {
    background: #376cf2;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 3.5px 13px;
    font-size: .92em;
    cursor: pointer;
    transition: background 0.15s;
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 2;
}

.copy-btn:hover {
    background: #72b7ff;
    color: #23242a;
}

/* Markdown & Code */
pre {
    font-family: 'JetBrains Mono', 'Fira Mono', 'Fira Code', 'Menlo', 'Consolas', 'monospace';
    font-size: 0.85em;
    background: #1a1b22;
    color: #b7e0ff;
    border-radius: 8px;
    padding: 9px 14px;
    overflow-x: auto;
    margin-top: 7px;
    margin-bottom: 6px;
    line-height: 1.5;
    position: relative;
    white-space: pre-wrap !important;
    /* Pastikan ini diterapkan */
}

pre code {
    background: none !important;
    color: inherit !important;
    padding: 0 !important;
    font-size: 1em !important;
    border: none !important;
    display: block;
    white-space: pre-wrap !important;
    /* Pastikan ini diterapkan juga */
}

/* Inline code */
code {
    font-family: 'JetBrains Mono', 'Fira Mono', 'Fira Code', 'Menlo', 'Consolas', 'monospace';
    font-size: 0.85em;
    background: #262932;
    color: #72b7ff;
    border-radius: 4px;
    padding: 2px 5px;
    white-space: nowrap;
}


/* List and markdown tweaks */
ul,
ol {
    margin-left: 1.5em;
    margin-bottom: 10px;
    color: #adbed3;
    padding-left: 0;
}

li {
    margin-bottom: 5px;
}

h1,
h2,
h3 {
    color: #77b7f7;
    margin-top: 18px;
    margin-bottom: 7px;
    font-weight: 600;
}

b,
strong {
    color: #fff;
}

/* Scrollbar styling (for dark bg) */
::-webkit-scrollbar {
    width: 8px;
    background: #23242a;
}

::-webkit-scrollbar-thumb {
    background: #376cf2;
    border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
    background: #72b7ff;
}

/* RESPONSIVE */
@media (max-width: 900px) {

    .chat-message,
    .chat-message.user,
    .chat-message.ai {
        max-width: 94vw;
        font-size: 0.97em;
        margin-left: 10px;
        margin-right: 10px;
    }

    .chat-container {
        padding: 15px 10px 100px 10px;
    }

    .chat-input-wrapper {
        padding: 10px;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: unset;
        max-width: unset;
        height: auto;
        border-right: none;
        border-bottom: 1.5px solid #23242a;
        flex-direction: row;
        padding: 10px;
        justify-content: space-between;
        align-items: center;
        overflow-x: auto;
        white-space: nowrap;
    }

    .sidebar-header {
        padding: 0;
        flex-direction: row;
        width: auto;
        margin-right: 15px;
    }

    .logo-container h1 {
        font-size: 1.1em;
    }

    .new-chat-btn {
        width: auto;
        padding: 8px 12px;
        font-size: 0.9em;
        margin: 0;
    }

    .chat-history {
        display: none;
    }

    .settings {
        display: none;
    }

    .main-content {
        height: calc(100vh - 80px);
        padding: 0;
    }

    .chat-container {
        padding: 10px;
        padding-bottom: 140px;
    }

    .chat-input-wrapper {
        padding: 10px;
    }

    .action-buttons {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }

    .action-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 600px) {
    .sidebar {
        display: none;
    }

    .main-content {
        height: 100vh;
    }
}