body {
    padding: 50px;
    font:
        14px "Lucida Grande",
        Helvetica,
        Arial,
        sans-serif;
}

a {
    color: #00b7ff;
}
:root {
    --brand: #f56600;
    --brand-dark: #dd5c00;
    --brand-soft: #fff1e8;
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #20242b;
    --muted: #737b87;
    --border: #e7e9ed;
    --green: #16834b;
    --shadow: 0 12px 40px rgba(24, 32, 45, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 24px;
    display: grid;
    place-items: center;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.app {
    width: min(100%, 920px);
    height: min(900px, calc(100vh - 48px));
    min-height: 560px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.logo {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 13px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 21px;
    font-weight: 800;
}

h1 {
    margin: 0;
    font-size: 16px;
    letter-spacing: -0.2px;
}

.subtitle {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #aab1bb;
}

.dot.online {
    background: var(--green);
}

button,
input,
textarea {
    font: inherit;
}
button {
    cursor: pointer;
}

.secondary {
    border: 1px solid var(--border);
    background: white;
    color: #414854;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 12px;
    font-weight: 600;
}

.secondary:hover {
    background: #f8f9fb;
}

.settings {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 12px 22px;
    background: #fcfcfd;
    border-bottom: 1px solid var(--border);
}

.settings label {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 11px;
}

.settings input {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    color: var(--text);
    background: white;
    font-size: 12px;
}

.settings input:focus,
textarea:focus {
    border-color: #ffb17d;
    box-shadow: 0 0 0 3px rgba(245, 102, 0, 0.08);
}

.settings button {
    align-self: end;
    height: 36px;
}

.chat {
    flex: 1;
    overflow-y: auto;
    padding: 24px clamp(16px, 5vw, 52px);
    scroll-behavior: smooth;
}

.welcome {
    max-width: 580px;
    margin: 8vh auto 30px;
    text-align: center;
}

.welcome-icon {
    width: 58px;
    height: 58px;
    margin: 0 auto 16px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 27px;
}

.welcome h2 {
    margin: 0 0 8px;
    font-size: 23px;
    letter-spacing: -0.6px;
}

.welcome p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.65;
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 22px;
}

.suggestion {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: white;
    padding: 9px 13px;
    color: #555e69;
    font-size: 12px;
}

.suggestion:hover {
    border-color: #ffc49f;
    color: var(--brand-dark);
    background: #fffaf6;
}

.message-row {
    display: flex;
    gap: 10px;
    margin: 0 0 20px;
    align-items: flex-start;
}

.message-row.user {
    justify-content: flex-end;
}

.avatar {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 13px;
    font-weight: 800;
}

.user .avatar {
    order: 2;
    background: #edf0f4;
    color: #5b6470;
}

.bubble {
    max-width: min(78%, 650px);
    padding: 12px 15px;
    border-radius: 15px;
    background: #f3f4f6;
    font-size: 14px;
    line-height: 1.65;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.user .bubble {
    background: var(--brand);
    color: white;
    border-bottom-right-radius: 5px;
}

.assistant .bubble {
    border-bottom-left-radius: 5px;
}

.assistant .bubble a {
    color: var(--brand-dark);
}

/* ANIMASI BERPIKIR AI */

.assistant .bubble.thinking-bubble {
    padding: 13px 16px;
    min-width: 235px;
    background: #fff8f3;
    border: 1px solid #ffe4d3;
    white-space: normal;
}

.thinking-content {
    display: flex;
    align-items: center;
    gap: 11px;
}

.thinking-icon {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    position: relative;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--brand);
    color: white;
}

.thinking-spark {
    font-size: 21px;
    animation: thinkingSpark 1.5s ease-in-out infinite;
}

.thinking-orbit {
    position: absolute;
    inset: -4px;
    border: 2px solid var(--brand);
    border-right-color: transparent;
    border-radius: 50%;
    animation: thinkingRotate 2s linear infinite;
}

.thinking-info {
    min-width: 0;
}

.thinking-title {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #3e3029;
    font-size: 12px;
    font-weight: 700;
}

.thinking-dots {
    display: inline-flex;
    gap: 3px;
}

.thinking-dots i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--brand);
    animation: thinkingBounce 0.7s ease-in-out infinite alternate;
}

.thinking-dots i:nth-child(2) {
    animation-delay: 0.2s;
}
.thinking-dots i:nth-child(3) {
    animation-delay: 0.4s;
}

.thinking-status {
    margin-top: 4px;
    color: #927d70;
    font-size: 11px;
    animation: thinkingFade 1.8s ease-in-out infinite;
}

.thinking-progress {
    height: 3px;
    margin-top: 10px;
    overflow: hidden;
    border-radius: 10px;
    background: #ffe5d4;
}

.thinking-progress span {
    display: block;
    width: 35%;
    height: 100%;
    border-radius: inherit;
    background: var(--brand);
    animation: thinkingProgress 1.7s ease-in-out infinite;
}

@keyframes thinkingRotate {
    to {
        transform: rotate(360deg);
    }
}

@keyframes thinkingSpark {
    50% {
        transform: scale(0.7) rotate(25deg);
        opacity: 0.6;
    }
}

@keyframes thinkingBounce {
    to {
        transform: translateY(-4px);
    }
}

@keyframes thinkingFade {
    50% {
        opacity: 0.45;
    }
}

@keyframes thinkingProgress {
    0% {
        transform: translateX(-110%);
    }
    100% {
        transform: translateX(300%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .thinking-bubble * {
        animation: none !important;
    }
}

.typing {
    color: var(--muted);
    font-size: 12px;
}

.composer-wrap {
    padding: 14px 22px 18px;
    border-top: 1px solid var(--border);
    background: white;
}

.composer {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    max-width: 820px;
    margin: auto;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: white;
}

textarea {
    flex: 1;
    min-height: 42px;
    max-height: 130px;
    resize: none;
    border: 0;
    outline: none;
    padding: 10px 8px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

textarea:focus {
    box-shadow: none;
}

.send {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border: 0;
    border-radius: 11px;
    background: var(--brand);
    color: white;
    font-size: 18px;
    font-weight: 700;
}

.send:hover {
    background: var(--brand-dark);
}
.send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.hint {
    max-width: 820px;
    margin: 8px auto 0;
    color: #969da7;
    font-size: 10px;
    text-align: center;
}

.error {
    margin: 0 0 16px;
    padding: 10px 12px;
    border: 1px solid #ffd4d4;
    border-radius: 10px;
    background: #fff5f5;
    color: #b42318;
    font-size: 12px;
}

@media (max-width: 640px) {
    body {
        padding: 0;
    }

    .app {
        width: 100%;
        height: 100dvh;
        min-height: 0;
        border: 0;
        border-radius: 0;
    }

    header {
        padding: 14px 15px;
    }
    .settings {
        padding: 10px 15px;
    }
    .status {
        display: none;
    }
    .chat {
        padding: 20px 14px;
    }

    .bubble {
        max-width: 86%;
        font-size: 13px;
    }

    .assistant .bubble.thinking-bubble {
        min-width: 220px;
    }

    .composer-wrap {
        padding: 10px 12px 14px;
    }
    .welcome {
        margin-top: 9vh;
    }
    .welcome h2 {
        font-size: 20px;
    }
}

/* ========================================
   MARKDOWN CHAT MESSAGE
======================================== */
.bubble {
    line-height: 1.5;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Paragraf tanpa jarak kosong berlebihan */
.bubble p {
    margin: 0 0 4px 0;
}

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

/* List rapat */
.bubble ul,
.bubble ol {
    margin: 3px 0;
    padding-left: 1.3em;
}

/* Jarak antar poin */
.bubble li {
    margin: 0 0 3px 0;
    padding: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Paragraf dalam list */
.bubble li p {
    margin: 0;
    padding: 0;
}

/* Heading */
.bubble h1,
.bubble h2,
.bubble h3,
.bubble h4 {
    margin: 7px 0 3px;
    line-height: 1.3;
}

/* Baris baru */
.bubble br {
    display: block;
    content: "";
    margin: 0;
}

/* Cegah enter ganda */
.bubble br + br {
    display: none;
}

/* Kode */
.bubble pre {
    margin: 5px 0;
    max-width: 100%;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    box-sizing: border-box;
}

.bubble pre code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.whatsapp-button-wrapper {
    margin: 12px 0;
}

.whatsapp-chat-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 18px;
    background: #25d366;
    color: white !important;
    border-radius: 10px;
    font-weight: 600;
    text-decoration: none !important;
}

.whatsapp-chat-button:hover {
    background: #1ebe5d;
}
