/* ===============================
   RESET
================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: "Archivo", Tahoma, sans-serif;
    color: rgb(68, 69, 69);
    background: #ffffff;
    min-height: 100vh;
}

body {
    display: flex;
    flex-direction: column;
}

/* ===============================
   COLORS (MAKEEN)
================================ */
:root {
    --green-900: rgb(42, 71, 52);
    --green-600: rgb(88, 145, 91);
    --green-300: rgb(153, 191, 156);

    --cta-bg: rgb(195, 219, 118);
    --cta-text: rgb(68, 69, 69);

    --border-soft: #e6ece8;
}

/* ===============================
   PAGE LAYOUT
================================ */
.page {
    flex: 1;
    display: flex;
}

.hero {
    flex: 1;
    padding: 3rem 1.5rem 6rem;
    background-image: linear-gradient(
                        rgba(255, 255, 255, 0.8),
                        rgba(255, 255, 255, 0.8)
                        ),
                        url("/images/bg.jpg");;
    background-position: center;
    background-size: cover;
}

.hero-inner {
    max-width: 720px;
    margin: 0 auto;
    text-align: center;
}

/* ===============================
   BADGE
================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    background: rgba(153, 191, 156, 0.15);
    color: var(--green-900);
    font-weight: 400;
    font-size: 0.85rem;
    margin-bottom: 2.5rem;
}

.badge-icon {
    width: 16px;
    height: 16px;

    color: var(--green-900);

    flex-shrink: 0;
}

/* ===============================
   HEADINGS
================================ */
.hero h1 {
    font-size: clamp(1.6rem, 2rem, 2.6rem);
    font-weight: 800;
    line-height: 1.15;
    margin: 0 0 3rem;
    color: #000000;
}

.hero h1 span {
    display: block;
    color: var(--green-600);
    margin-top: 1rem;
}

.subtitle {
    font-size: 1.05rem;
    color: #6b6f6f;
    margin-bottom: 3rem;
}

/* ===============================
   CARD
================================ */
.card {
    background: #ffffff;
    border-radius: 1.25rem;
    padding: 2rem;
    box-shadow:
            0 20px 40px rgba(0, 0, 0, 0.08);
    text-align: left;
}

/* ===============================
   FORM
================================ */
label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
}

.editor {
    display: block;              /* 🔴 critical */
    width: 100%;

    min-height: 2.5rem;
    max-height: 6rem;

    padding: 0.9rem 1rem;
    margin-top: 0.4rem;

    border-radius: 0.6rem;
    border: 1px solid var(--border-soft);

    font-family: "Archivo", Tahoma, sans-serif;
    font-size: 0.95rem;
    font-weight: 400;
    line-height: 1.3;             /* 🔴 important */

    box-sizing: border-box;

    outline: none;
    overflow-y: auto;

    white-space: pre-wrap;
    word-break: break-word;
}

.editor:empty::before {
    content: "Ask me anything...";
    color: #999;
    pointer-events: none;
}

.editor:focus {
    border-color: var(--green-600);
    box-shadow: 0 0 0 3px rgba(88, 145, 91, 0.2);
}



/* ===============================
   BUTTON
================================ */
button {
    margin-top: 0.5rem;
    padding: 0.9rem 1rem;
    border-radius: 0.6rem;
    border: none;
    background: var(--green-600);
    color: white;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
}

button:hover {
    background: rgb(185, 209, 108);
}

/* ===============================
   MOBILE POLISH
================================ */
@media (max-width: 480px) {
    .hero {
        padding-top: 4rem;
    }

    .card {
        padding: 1.5rem;
    }
}



.chat-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Submit button stays as-is */

.chat-actions > button[type="submit"] {
    flex: 1;
    width: auto;       /* override global button rule */
}

/* Record button */
.record-btn {
    width: 3rem;
    height: 3rem;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 0.5rem; /* square with soft corners */
    border: 1px solid var(--green-600);
    background: transparent;

    font-size: 1.1rem;
    cursor: pointer;

    transition: background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.1s ease;
}

.record-btn:hover {
    background: rgba(0, 0, 0, 0.03);
}

/* Recording state */
.record-btn.recording, .record-btn.loading {
    background: #E0EAE0;
}

/* Subtle pulse while recording */
.record-btn.recording {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(71, 220, 38, 0.4); }
    70%  { box-shadow: 0 0 0 6px rgba(88, 145, 91, 0); }
    100% { box-shadow: 0 0 0 0 rgba(88, 145, 91, 0); }
}

/* Disabled state */
.record-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


/* ===============================
   HEADER
================================ */

/* ================================
   Header Layout
================================ */

.app-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 2rem;
    background: #ffffff;
    border-bottom: 1px solid #e6e8e6;
}

/* ================================
   Brand Block
================================ */

.brand {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

/* MAKEEN */
.brand-makeen {
    font-family: "Archivo", Tahoma, sans-serif;
    font-weight: 800;
    font-size: 1.4rem;
    letter-spacing: 0.08em;
    color: #0f1a13; /* very dark MAKEEN tone */
}

/* ENERGY */
.brand-energy {
    font-family: "Archivo", Tahoma, sans-serif;
    font-weight: 200;
    font-size: 0.85rem;
    margin-top: 0.1rem; /* 👈 controlled spacing */
    color: rgb(88, 145, 91); /* MAKEEN dark green */
}

/* ================================
   Divider + App Name
================================ */

.brand-divider {
    width: 1px;
    height: 28px;
    background: #d8dbd8;
}

.brand-app {
    font-family: "Archivo", Tahoma, sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.12em;
    color: #2c2f2e;
}


/* ================================
   Chat container
   ================================ */

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.5rem 1rem;
    background: #ffffff;
}

.chat-message {
    display: flex;
    width: 100%;
}

.chat-message.USER {
    justify-content: flex-end;
}

.chat-message.ASSISTANT {
    justify-content: flex-start;
}

/* ================================
   Chat bubble
   ================================ */

.chat-bubble {
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    line-height: 1.45;
    font-size: 0.95rem;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* ================================
   User bubble (MAKEEN accent)
   ================================ */

.chat-message.USER .chat-bubble {
    background-color: rgb(195, 219, 118); /* MAKEEN light green */
    color: rgb(68, 69, 69);
    border-bottom-right-radius: 0.25rem;
}

/* ================================
   AI bubble (neutral / clean)
   ================================ */

.chat-message.ASSISTANT .chat-bubble {
    background-color: rgb(245, 247, 246); /* subtle light gray */
    color: rgb(68, 69, 69);
    border-bottom-left-radius: 0.25rem;
}

/* ================================
   Paragraph reset inside bubble
   ================================ */

.chat-bubble p {
    margin: 0;
    white-space: pre-wrap;
}


#submitButton:disabled {
    background-color: gray;
    cursor: not-allowed;
}

#submitButton:disabled .htmx-indicator {
    display: inline-block;
    color: white;
    opacity: 1;
    visibility: visible;
}

.htmx-indicator {
    display: none;
}

#submitButton:disabled .label {
    display: none;
}

.dots::after {
    content: "";
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%   { content: ""; }
    25%  { content: "."; }
    50%  { content: ".."; }
    75%  { content: "..."; }
}

/* Message text */
.message-text {
    margin: 0;
    white-space: pre-wrap;
}

/* Sources container */
.sources {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 0.75rem;
}

/* Badge container */
.source-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

/* Individual badge */
.source-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background-color: rgba(44, 123, 229, 0.12);
    color: #2c7be5;
    font-weight: 500;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: default;
}

/* No hover affordance (informational only) */
.source-badge:hover {
    background-color: rgba(44, 123, 229, 0.12);
}

audio {
    display: none;
}

.last-answer-container {
    display: none;
}

.last-answer-container.show {
    display: flex;
    justify-content: center;
}

.show-last-answer {
    color: var(--green-600);
    background: none;
    border: none;
    font-weight: 400;
    font-size: 0.8rem;
}

.show-last-answer:hover {
    color: var(--green-900);
    background: none;
    border: none;
}
