* {
    box-sizing: border-box;
}

:root {
    --bg-utama: #f9f9f9;
    --bg-card: #ffffff;
    --teks-utama: #222222;
    --chat-user: #e3f2fd;
    --chat-tulkiyem: #f0f4c3;
    --border-color: #ddd;
}

[data-theme="dark"] {
    --bg-utama: #121212;
    --bg-card: #1e1e1e;
    --teks-utama: #e0e0e0;
    --chat-user: #1565c0;
    --chat-tulkiyem: #33691e;
    --border-color: #444;
}

body {
    font-family: Arial, sans-serif;
    background-color: var(--bg-utama);
    color: var(--teks-utama);
    transition: background-color 0.3s, color 0.3s;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.chat-box,
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
}

.btn-mode {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--teks-utama);
    cursor: pointer;
    font-weight: bold;
}

.chat-container {
     background: #18181B;
    position: fixed;
    top: 0;
    width: 100%;
    max-width: 900px;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 12px;
    border-radius: 0;
    box-shadow: none;
    z-index: 99999;
}

.chat-header {
    position: sticky;
    top: 0;
    background-color: #000;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    border-bottom: 1px solid #392507;
    border-radius: 25px;
}

/* WADAH INFO (Foto + Teks) */
.header-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex: 1;
}

.profile-pic {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #4CAF50;
    flex-shrink: 0;
}

/* WADAH TEKS */
.header-text {
    flex: 1;
    min-width: 0;
}

.header-text h2 {
    margin: 0;
    font-size: 1rem;
    color: #ffc107;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-text p {
    margin: 3px 0 0 0;
    font-size: 0.90rem;
    color: #ffffff;
    text-align: left;
    white-space: normal;
    line-height: 1.2;
}

/* TOMBOL RESIK CHAT */
#btn-clear {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 50px;
    font-size: 0.65rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
    flex-shrink: 0;
    margin-right: 10px
}

#btn-clear:hover {
    background-color: #bb2d3b;
}

/* AREA CHAT */
.chat-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border: 1px solid #ccc;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 5px;
    background-color: #1E1E2E;
}

.pesan {
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 8px;
    line-height: 1.4;
    max-width: 85%;
    white-space: normal;
}

.pesan.bot {
    background-color: #000;
    color: #E2E8F0;
    border-left: 4px solid #ffc107;
    align-self: flex-start;
    text-align: left;
    padding-top: 5px;
}

.dot {
  display: inline-block;
  animation: wave 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
  animation-delay: 0s;
}

.dot:nth-child(2) {
  animation-delay: 0.2s;
}

.dot:nth-child(3) {
  animation-delay: 0.4s;
}

.dot:nth-child(3) {
  animation-delay: 0.6s;
}

@keyframes wave {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  40% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.pesan.user {
    background-color: #061a4b;
    color: #f2efef;
    border-right: 4px solid #c19c09;
    text-align: left;
    margin-left: auto;
    white-space: pre-line;
}

.pesan pre {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre;
    background-color: #000;
    padding: 12px;
    border-radius: 6px;
    box-sizing: border-box;
}

.pesan code {
    font-family: 'Courier New', Courier, monospace;
    max-width: 100%;
}

/* AREA INPUT */
.input-box {
    display: flex;
    gap: 10px;
    align-items: center;
}

#user-input {
    flex: 1;
    resize: none;
    min-height: 40px;
    max-height: 100px;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.4;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-sizing: border-box;
    outline: none;
    overflow-y: auto;
}

#send-btn {
    padding: 10px 20px;
    background-color: #d1b902;
    color: black;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

#send-btn:hover {
    background-color: #eeeb15;
}

#mic-btn {
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: 0.3s;
    flex-shrink: 0;
}

#mic-btn:hover {
    background-color: #e0e0e0;
}

#mic-btn.listening {
    background-color: #ff4d4d;
    color: white;
    border-color: #d32f2f;
    animation: pulse 1s infinite;
}

.btn-muni {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    margin-left: 8px;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s;
}

.btn-muni:hover {
    opacity: 1;
    transform: scale(1.2);
}

#theme-toggle {
    margin-top: 5px;
    margin-bottom: 12px;
    width: 100%;
}

.disclaimer-text {
    font-size: 0.75rem;
    color: #a0aec0;
    text-align: center;
    margin-top: 6px;
    margin-bottom: 8px;
    font-style: italic;
    animation: kedipAlus 7s infinite;
}

@keyframes kedipAlus {
    0%, 70% {
        opacity: 1;
        visibility: visible;
    }
    75%, 95% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

@media screen and (max-width: 768px) {
    html,
    body {
        overflow-x: hidden !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .chat-container {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        padding: 12px !important;
        box-sizing: border-box !important;
    }

    .chat-header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        gap: 6px !important;
        box-sizing: border-box !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
        flex-shrink: 0 !important;
    }

    .header-info {
        display: flex !important;
        align-items: center !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        overflow: hidden !important;
    }

    .header-text {
        min-width: 0 !important;
        overflow: hidden !important;
        margin-top: 5px;
        margin-bottom: 5px;
    }

    .header-text h2,
    .header-text p,
    .header-text p em {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: unset !important;
    }

    #btn-clear {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
    }

    #userInput {
        font-size: 18px;
    }

    #chat-box {
        flex: 1 !important;
        overflow-y: auto !important;
    }

    .btn-mode,
    .input-box,
    .disclaimer-text,
    .tombol-bali-wadah {
        flex-shrink: 0 !important;
    }
}
