/* =========================================================
   LCRO Chatbot Widget -- "Ate Civ" / "Kuya Civ"
   All brand colors / sizes come from CSS variables set inline
   by includes/chatbot_widget.php (chatbot_settings table).
   ========================================================= */

:root {
    --lcro-primary:       #0d6efd;
    --lcro-primary-dark:  #0b5ed7;
    --lcro-user-bubble:   #0d6efd;
    --lcro-emphasis:      #0b5ed7;
    --lcro-launcher-size: 60px;
    --lcro-panel-width:   380px;
    --lcro-panel-height:  560px;
}

/* Reset any inherited text-transform / letter-spacing from
   dashboard styles so the chatbot renders naturally. */
.lcro-chat-launcher,
.lcro-chat-panel,
.lcro-chat-panel * {
    text-transform: none !important;
    letter-spacing: normal !important;
    font-variant: normal !important;
}

.lcro-chat-launcher {
    position: fixed;
    bottom: 22px;
    right: 22px;
    width: var(--lcro-launcher-size);
    height: var(--lcro-launcher-size);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--lcro-primary), var(--lcro-primary-dark));
    color: #fff;
    border: none;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 26px;
    transition: transform 0.2s, box-shadow 0.2s;
    padding: 0;
}
.lcro-chat-launcher:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
}
.lcro-chat-launcher .lcro-launcher-img {
    width: 78%;
    height: 78%;
    object-fit: contain;
    border-radius: 50%;
}
.lcro-chat-launcher .badge-dot {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 10px;
    height: 10px;
    background: #28a745;
    border: 2px solid #fff;
    border-radius: 50%;
}

/* Panel */
.lcro-chat-panel {
    position: fixed;
    bottom: 22px;
    right: 22px;
    width: var(--lcro-panel-width);
    max-width: calc(100vw - 32px);
    height: var(--lcro-panel-height);
    max-height: calc(100vh - 40px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 10051;
    font-family: 'Segoe UI', Arial, sans-serif;
}
.lcro-chat-panel.open { display: flex; }

/* Header */
.lcro-chat-header {
    background: linear-gradient(135deg, var(--lcro-primary), var(--lcro-primary-dark));
    color: #fff;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.lcro-chat-header .avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #fff;
    color: var(--lcro-primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    overflow: hidden;
    flex-shrink: 0;
}
.lcro-chat-header .avatar .lcro-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.lcro-chat-header .title {
    flex: 1;
    line-height: 1.2;
}
.lcro-chat-header .title .name {
    font-weight: 700;
    font-size: 15px;
}
.lcro-chat-header .title .sub {
    font-size: 11px;
    opacity: 0.85;
}
.lcro-chat-header .btn-head {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    opacity: 0.85;
}
.lcro-chat-header .btn-head:hover { opacity: 1; }

/* Messages */
.lcro-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    background: #f5f7fb;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.lcro-msg {
    max-width: 85%;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.45;
    word-wrap: break-word;
}
.lcro-msg.user { white-space: pre-wrap; }
.lcro-msg.user {
    align-self: flex-end;
    background: var(--lcro-user-bubble);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.lcro-msg.assistant {
    align-self: flex-start;
    background: #fff;
    color: #212529;
    border: 1px solid #e3e6ec;
    border-bottom-left-radius: 4px;
}
.lcro-msg .meta {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 3px;
}
.lcro-msg.assistant strong { font-weight: 700; color: var(--lcro-emphasis); }
.lcro-msg.assistant em     { font-style: italic; }
.lcro-msg.assistant code   {
    background: #f1f3f5;
    padding: 1px 5px;
    border-radius: 4px;
    font-family: Consolas, monospace;
    font-size: 12.5px;
}
.lcro-msg.assistant ul,
.lcro-msg.assistant ol {
    margin: 6px 0 4px 0;
    padding-left: 20px;
}
.lcro-msg.assistant li { margin: 2px 0; }
.lcro-msg.assistant a  { color: var(--lcro-primary); text-decoration: underline; }
.lcro-msg.assistant a:hover { color: var(--lcro-primary-dark); }

/* Streaming cursor */
.lcro-msg.assistant .cursor {
    display: inline-block;
    width: 7px;
    height: 14px;
    background: var(--lcro-primary);
    margin-left: 2px;
    vertical-align: middle;
    animation: lcro-blink 0.9s steps(2, start) infinite;
    border-radius: 1px;
}
@keyframes lcro-blink { to { visibility: hidden; } }

/* Typing indicator */
.lcro-typing {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e3e6ec;
    border-radius: 14px;
    padding: 10px 14px;
    display: none;
}
.lcro-typing.show { display: inline-flex; gap: 4px; align-items: center; }
.lcro-typing span {
    width: 6px; height: 6px;
    background: #888;
    border-radius: 50%;
    animation: lcro-bounce 1.2s infinite;
}
.lcro-typing span:nth-child(2) { animation-delay: 0.15s; }
.lcro-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes lcro-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%            { transform: translateY(-4px); opacity: 1; }
}

/* Quick actions */
.lcro-quick {
    padding: 8px 10px;
    background: #fff;
    border-top: 1px solid #e3e6ec;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.lcro-quick button {
    border: 1px solid var(--lcro-primary);
    background: #eaf2ff;
    color: var(--lcro-primary);
    border-radius: 14px;
    padding: 4px 10px;
    font-size: 11.5px;
    cursor: pointer;
    transition: background 0.15s;
}
.lcro-quick button:hover { background: #d6e5ff; }

/* Input */
.lcro-chat-input {
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #e3e6ec;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.lcro-chat-input textarea {
    flex: 1;
    resize: none;
    border: 1px solid #ced4da;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 13.5px;
    font-family: inherit;
    max-height: 100px;
    outline: none;
    transition: border-color 0.15s;
}
.lcro-chat-input textarea:focus { border-color: var(--lcro-primary); }
.lcro-chat-input button {
    background: var(--lcro-primary);
    color: #fff;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.15s;
}
.lcro-chat-input button:disabled { opacity: 0.5; cursor: not-allowed; }
.lcro-chat-input button:hover:not(:disabled) { background: var(--lcro-primary-dark); }

/* Footer */
.lcro-chat-foot {
    padding: 6px 10px;
    font-size: 10px;
    color: #888;
    text-align: center;
    background: #fff;
    border-top: 1px solid #f0f0f0;
}

/* Mobile */
@media (max-width: 520px) {
    .lcro-chat-panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}
