/* =========================================================
   YOUR APP — SUBTLE CUSTOM LAYOUT
   ========================================================= */

.chat-container {
    width: 94%;
    max-width: 1400px;
}

/* Give the conversation a slightly more focused width */
.chat-window {
    max-width: 820px;
}

/* Keep composer aligned with conversation */
.chat-input {
    max-width: 820px;
}

/* Slightly more compact conversation spacing */
.msg {
    margin-bottom: 24px;
}

.msg-bubble {
    max-width: 78%;
}


/* ---------------------------------------------------------
   Give the top bar a little more breathing room
   --------------------------------------------------------- */

.chat-header {
    padding-left: 24px;
    padding-right: 24px;
}


/* ---------------------------------------------------------
   Your assistant messages feel more like "responses"
   rather than chat bubbles.
   --------------------------------------------------------- */

.msg.bot .msg-bubble {
    padding-left: 0;
    padding-right: 0;
}


/* User messages remain visually distinct */
.msg.user .msg-bubble {
    padding: 10px 15px;
}


/* ---------------------------------------------------------
   Forms/pages retain the same overall geometry
   --------------------------------------------------------- */

.gate-container,
.login-page,
.container {
    width: 94%;
    max-width: 1100px;
}


/* =========================================================
   GLOBAL
   ========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: #ffffff;
    color: #111111;
    line-height: 1.5;
}

a {
    color: #111111;
}

button,
input,
textarea,
select {
    font: inherit;
}


/* =========================================================
   STANDARD SITE WIDTH
   Everything sits inside the same 90% page width.
   ========================================================= */

.container,
.gate-container {
    width: 90%;
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
}


/* =========================================================
   LOGIN / REGISTER / FORGOT PASSWORD
   ========================================================= */

.gate-container {
    min-height: 100vh;

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

    padding: 40px 0;
}

.gate-box {
    width: 100%;
    max-width: 420px;

    margin: 0 auto;
    padding: 32px;

    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
}

.gate-box h2 {
    margin: 0 0 8px;
    font-size: 24px;
    line-height: 1.25;
    color: #111111;
}

.gate-box .muted {
    margin: 0 0 24px;
}

.gate-box label {
    display: block;
    margin: 16px 0 6px;

    font-size: 14px;
    font-weight: 600;
    color: #222222;
}

.gate-box input[type="text"],
.gate-box input[type="password"],
.gate-box input[type="email"],
.gate-box input[type="file"],
.gate-box select {
    width: 100%;
}

.gate-box input[type="file"] {
    padding: 8px;
}

.gate-box .btn-primary {
    width: 100%;
    margin-top: 24px;
}

.gate-box .hint {
    text-align: center;
}


/* =========================================================
   HONEYPOT
   ========================================================= */

.hp-field {
    position: absolute !important;
    left: -9999px !important;

    width: 1px !important;
    height: 1px !important;

    opacity: 0 !important;
}


/* =========================================================
   FORM ELEMENTS
   ========================================================= */

input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
textarea,
select {
    width: 100%;

    padding: 10px 12px;

    border: 1px solid #d9d9d9;
    border-radius: 8px;

    background: #ffffff;
    color: #111111;

    outline: none;
}

input:focus,
textarea:focus,
select:focus {
    border-color: #999999;
}

textarea {
    resize: vertical;
}


/* =========================================================
   BUTTONS
   ========================================================= */

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 44px;

    padding: 10px 18px;

    border: 1px solid #111111;
    border-radius: 8px;

    background: #111111;
    color: #ffffff;

    font-weight: 600;
    cursor: pointer;
}

.btn-primary:hover {
    background: #333333;
}


/* =========================================================
   TEXT
   ========================================================= */

.muted {
    color: #666666;
    font-size: 14px;
}

.error {
    color: #b42318;
    font-weight: 600;
}

.success {
    color: #067647;
    font-weight: 600;
}

.hint {
    color: #777777;
    font-size: 12px;
    margin-top: 14px;
}


/* =========================================================
   LANGUAGE SWITCHER
   ========================================================= */

.lang-switcher {
    position: absolute;
    top: 20px;
    right: 20px;
}

.gate-box {
    position: relative;
}

.gate-box .lang-switcher select {
    width: auto;
    padding: 5px 8px;
    font-size: 12px;
}


/* =========================================================
   CHAT
   ========================================================= */

.chat-container {
    width: 90%;
    height: 100vh;

    margin: 0 auto;

    display: flex;
    flex-direction: column;

    overflow: hidden;
}


/* -------------------------
   Chat header
   ------------------------- */

.chat-header {
    flex: 0 0 60px;

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

    padding: 0 20px;

    border-bottom: 1px solid #e5e5e5;

    background: #ffffff;
    color: #111111;
}

.chat-header .header-left {
    display: flex;
    align-items: center;
    gap: 8px;

    font-size: 17px;
    font-weight: 600;
}

.chat-header .header-avatar {
    width: 28px;
    height: 28px;

    border-radius: 50%;
    object-fit: cover;
}

.chat-header .header-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.chat-header .reset-link {
    color: #555555;
    text-decoration: none;
    font-size: 13px;
    white-space: nowrap;
}

.chat-header .reset-link:hover {
    color: #111111;
}

.lang-switcher-header {
    width: auto;

    padding: 4px 7px;

    border: 1px solid #dddddd;
    border-radius: 6px;

    background: #ffffff;
    color: #111111;

    font-size: 12px;
}


/* -------------------------
   Chat messages
   ------------------------- */

.chat-window {
    flex: 1;

    width: 100%;
    max-width: 900px;

    margin: 0 auto;

    padding: 32px 20px;

    overflow-y: auto;

    display: flex;
    flex-direction: column;
    gap: 4px;
}

.msg {
    width: 100%;
    max-width: 100%;

    display: flex;
    flex-direction: column;

    margin-bottom: 20px;
}

.msg.user {
    align-items: flex-end;
}

.msg.bot {
    align-items: flex-start;
}

.msg-bubble {
    max-width: 75%;

    padding: 10px 14px;

    border-radius: 12px;

    line-height: 1.5;
    font-size: 14px;
}

.msg.user .msg-bubble {
    background: #f1f1f1;
    color: #111111;

    border-bottom-right-radius: 3px;
}

.msg.bot .msg-bubble {
    background: transparent;
    color: #111111;

    border-bottom-left-radius: 3px;
}

.msg.bot.error .msg-bubble {
    color: #b42318;
}

.msg.bot.system-note .msg-bubble {
    background: transparent;
    color: #777777;

    font-size: 12px;
    font-style: italic;

    padding: 4px 14px;
}


/* -------------------------
   Markdown
   ------------------------- */

.msg-bubble p {
    margin: 0 0 8px;
}

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

.msg-bubble ul,
.msg-bubble ol {
    margin: 4px 0;
    padding-left: 20px;
}

.msg-bubble code {
    background: #f1f1f1;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 13px;
}

.msg-bubble pre {
    background: #f5f5f5;
    color: #111111;

    padding: 10px;

    border-radius: 8px;

    overflow-x: auto;
}

.msg-bubble pre code {
    background: none;
    padding: 0;
}


/* -------------------------
   Message metadata
   ------------------------- */

.msg-meta {
    display: flex;
    align-items: center;
    gap: 10px;

    margin: 4px 4px 8px;
}

.source-badge {
    font-size: 11px;
    color: #666666;

    background: #f5f5f5;

    padding: 2px 8px;
    border-radius: 10px;
}

.feedback button {
    background: none;
    border: none;

    cursor: pointer;

    font-size: 13px;

    opacity: 0.5;

    padding: 2px 4px;
}

.feedback button:hover {
    opacity: 1;
}

.feedback.sent button {
    pointer-events: none;
}

.feedback.sent button[data-rating="1"] {
    opacity: 1;
}


/* -------------------------
   Typing indicator
   ------------------------- */

.msg-bubble.typing {
    display: flex;
    gap: 4px;

    padding: 14px;
}

.msg-bubble.typing span {
    width: 6px;
    height: 6px;

    border-radius: 50%;

    background: #888888;

    animation: typing-bounce 1.2s infinite;
}

.msg-bubble.typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.msg-bubble.typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typing-bounce {
    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}


/* -------------------------
   Chat composer
   ------------------------- */

.chat-input {
    flex: 0 0 auto;

    width: 100%;
    max-width: 900px;

    margin: 0 auto;

    padding: 12px 20px 20px;

    display: flex;
    align-items: center;
}

.chat-input input {
    flex: 1;

    min-width: 0;
    height: 48px;

    padding: 0 14px;

    border: 1px solid #d9d9d9;
    border-radius: 8px;

    outline: none;
}

.chat-input button[type="submit"] {
    height: 48px;

    padding: 0 18px;

    border: 1px solid #111111;
    border-radius: 8px;

    background: #111111;
    color: #ffffff;

    cursor: pointer;
    font-weight: 600;
}

#human-btn {
    height: 48px;

    background: none;
    border: none;

    cursor: pointer;
}


/* =========================================================
   ADMIN / DASHBOARD
   ========================================================= */

.navbar {
    width: 100%;

    min-height: 60px;

    padding: 0 5%;

    display: flex;
    align-items: center;

    gap: 18px;

    border-bottom: 1px solid #e5e5e5;

    background: #ffffff;
}

.navbar .brand {
    color: #111111;
    font-weight: 700;
    margin-right: auto;
}

.navbar a {
    color: #555555;
    text-decoration: none;
    font-size: 14px;
}

.navbar a:hover {
    color: #111111;
}

.navbar a.logout {
    color: #b42318;
}


/* -------------------------
   Admin content
   ------------------------- */

.container {
    padding-top: 32px;
    padding-bottom: 32px;
}


/* -------------------------
   Cards
   ------------------------- */

.card {
    width: 100%;

    margin-bottom: 24px;
    padding: 24px;

    background: #ffffff;

    border: 1px solid #e5e5e5;
    border-radius: 10px;
}

.card h2 {
    margin: 0 0 20px;

    padding-bottom: 10px;

    border-bottom: 1px solid #eeeeee;

    font-size: 17px;
    color: #222222;
}


/* -------------------------
   Dashboard statistics
   ------------------------- */

.stat-grid {
    width: 100%;

    display: grid;
    grid-template-columns: repeat(4, 1fr);

    gap: 16px;

    margin-bottom: 24px;
}

.stat-card {
    padding: 18px;

    background: #ffffff;

    border: 1px solid #e5e5e5;
    border-radius: 10px;

    text-align: center;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: #111111;
}

.stat-label {
    margin-top: 4px;

    font-size: 12px;
    color: #777777;
}


/* -------------------------
   Admin forms
   ------------------------- */

.row {
    width: 100%;

    display: grid;
    grid-template-columns: repeat(3, 1fr);

    gap: 16px;
}


/* -------------------------
   Tables
   ------------------------- */

.table {
    width: 100%;

    border-collapse: collapse;

    background: #ffffff;
}

.table th,
.table td {
    padding: 10px 12px;

    border-bottom: 1px solid #eeeeee;

    font-size: 13px;

    text-align: left;
    vertical-align: top;
}

.table th {
    background: #f7f7f7;
    font-weight: 600;
}


/* =========================================================
   OLD LOGIN PAGE SUPPORT
   ========================================================= */

.login-page {
    width: 90%;
    max-width: 1100px;

    min-height: 100vh;

    margin: 0 auto;

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

.login-box {
    width: 100%;
    max-width: 420px;

    padding: 32px;

    background: #ffffff;

    border: 1px solid #e5e5e5;
    border-radius: 12px;
}

.login-box h2 {
    margin-top: 0;
}


/* =========================================================
   EMBED MODE
   ========================================================= */

body.embed-mode {
    width: 100%;
    height: 100%;
    background: transparent;
}

body.embed-mode .chat-container {
    width: 100%;
    height: 100vh;
    margin: 0;

    border-radius: 0;
}

body.embed-mode .gate-container {
    width: 100%;
    min-height: 100vh;
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 800px) {

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .row {
        grid-template-columns: 1fr;
    }

    .chat-container {
        width: 100%;
    }

    .chat-window,
    .chat-input {
        max-width: 100%;
    }
}


@media (max-width: 600px) {

    .gate-container {
        width: 100%;
        padding: 20px;
    }

    .gate-box {
        max-width: 100%;
        padding: 24px;
    }

    .container {
        width: 100%;
        padding: 20px;
    }

    .navbar {
        padding: 0 20px;
    }

    .chat-header {
        padding: 0 14px;
    }

    .chat-header .reset-link {
        font-size: 11px;
    }

    .chat-window {
        padding: 20px 14px;
    }

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

    .msg-bubble {
        max-width: 88%;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }
}


/*xxxx*/

.chat-container {
    width: 94%;
    max-width: 1400px;
}

.chat-window {
    max-width: 820px;
}

.chat-input {
    max-width: 820px;
}

.chat-header {
    padding-left: 24px;
    padding-right: 24px;
}

.msg {
    margin-bottom: 24px;
}

.msg-bubble {
    max-width: 78%;
}

/* Assistant responses are clean text */
.msg.bot .msg-bubble {
    padding-left: 0;
    padding-right: 0;
}

/* User messages remain visually grouped */
.msg.user .msg-bubble {
    padding: 10px 15px;
}

/* Keep the other pages aligned with the same overall site width */
.gate-container,
.login-page,
.container {
    width: 94%;
    max-width: 1100px;
}

.chat-input {
    position: relative;
}

.chat-input input {
    padding-right: 58px;
}

.chat-input button[type="submit"] {
    width: 36px;
    height: 36px;

    position: absolute;
    right: 26px;
    top: 50%;
    transform: translateY(-50%);

    padding: 0;
    margin: 0;

    border: none;
    border-radius: 50%;

    background: #111;
    color: #fff;

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

    cursor: pointer;

    font-size: 0;
}

.chat-input button[type="submit"]::before {
    content: "↑";

    font-size: 20px;
    font-weight: 500;
    line-height: 1;

    transform: translateY(-1px);
}

.chat-input button[type="submit"]:hover {
    background: #333;
}
