/* AI Chat Pro v5 ─────────────────────────────────────────────── */

#acp-btn,
#acp-win,
#acp-win * {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: normal;
}

/* ── Floating button ─────────────────────────────────────────── */

#acp-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--acp-accent, #6366f1);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,0.28);
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    padding: 0;
    outline: none;
}
#acp-btn:hover { transform: scale(1.09); box-shadow: 0 6px 28px rgba(0,0,0,0.35); }
#acp-btn:focus { outline: 2px solid var(--acp-accent, #6366f1); outline-offset: 3px; }
#acp-btn svg   { width: 26px; height: 26px; fill: #fff; pointer-events: none; display: block; }
#acp-btn .acp-badge {
    position: absolute;
    top: 1px; right: 1px;
    width: 15px; height: 15px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
}
#acp-btn.has-new .acp-badge { display: block; }

/* ── Widget button effects ───────────────────────────────────── */

@keyframes acpPulse {
    0%,100% { transform: scale(1); }
    50%      { transform: scale(1.13); }
}
@keyframes acpBounceBtn {
    0%,100% { transform: translateY(0); }
    30%     { transform: translateY(-12px); }
    60%     { transform: translateY(-6px); }
}
@keyframes acpGlow {
    0%,100% { box-shadow: 0 4px 20px rgba(0,0,0,0.28); }
    50%     { box-shadow: 0 4px 32px var(--acp-accent,#6366f1), 0 0 22px var(--acp-accent,#6366f1); }
}
@keyframes acpShake {
    0%,100%           { transform: translateX(0); }
    15%,45%,75%       { transform: translateX(-5px); }
    30%,60%,90%       { transform: translateX(5px); }
}
@keyframes acpRing {
    0%,100%  { transform: rotate(0deg); }
    10%,30%  { transform: rotate(-14deg); }
    20%,40%  { transform: rotate(14deg); }
    50%      { transform: rotate(0deg); }
}

#acp-btn.effect-pulse  { animation: acpPulse     2s   ease-in-out infinite; }
#acp-btn.effect-bounce { animation: acpBounceBtn 1.8s ease-in-out infinite; }
#acp-btn.effect-glow   { animation: acpGlow      2.2s ease-in-out infinite; }
#acp-btn.effect-shake  { animation: acpShake     0.7s ease-in-out infinite; animation-delay: 2.5s; }
#acp-btn.effect-ring   { animation: acpRing      1s   ease-in-out infinite; animation-delay: 2s; }

/* ── Widget floating label ───────────────────────────────────── */

#acp-label {
    position: fixed;
    bottom: 38px;
    right: 100px;
    background: var(--acp-label-bg, #ffffff);
    color: var(--acp-label-color, #111111);
    padding: 9px 16px;
    border-radius: 22px;
    font-size: 13.5px;
    font-weight: 600;
    box-shadow: 0 4px 22px var(--acp-label-shadow, #6366f1);
    z-index: 2147483001;
    white-space: nowrap;
    cursor: pointer;
    display: flex;
    align-items: center;
    user-select: none;
    transition: opacity 0.25s;
}
#acp-label::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    border: 7px solid transparent;
    border-left-color: var(--acp-label-bg, #ffffff);
    border-right: none;
}
#acp-label:hover { opacity: 0.88; }

@keyframes acpLabelBounce {
    0%,100% { transform: translateY(0); }
    50%     { transform: translateY(-7px); }
}
@keyframes acpLabelFade {
    0%,100% { opacity: 0.65; }
    50%     { opacity: 1; }
}
@keyframes acpLabelSlide {
    0%      { opacity: 0; transform: translateX(18px); }
    12%     { opacity: 1; transform: translateX(0); }
    88%     { opacity: 1; transform: translateX(0); }
    100%    { opacity: 0; transform: translateX(18px); }
}

#acp-label.anim-bounce { animation: acpLabelBounce 2s ease-in-out infinite; }
#acp-label.anim-fade   { animation: acpLabelFade   2.4s ease-in-out infinite; }
#acp-label.anim-slide  { animation: acpLabelSlide  4s ease-in-out infinite; }

/* ── Chat window ─────────────────────────────────────────────── */

#acp-win {
    position: fixed;
    bottom: 96px; right: 28px;
    width: var(--acp-chat-width, 375px);
    max-height: var(--acp-chat-height, 600px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 60px rgba(0,0,0,0.18);
    z-index: 2147482999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(18px) scale(0.97);
    transition: opacity 0.22s ease, transform 0.22s ease;
}
#acp-win.open {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

/* ── Header ──────────────────────────────────────────────────── */

.acp-header {
    background: var(--acp-header-bg, #0f0f13);
    padding: 13px 16px;
    display: flex;
    align-items: center;
    gap: 11px;
    flex-shrink: 0;
}
.acp-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--acp-accent, #6366f1);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0; line-height: 1; user-select: none;
}
.acp-header-info { flex: 1; min-width: 0; }
.acp-header-info h4 {
    margin: 0 0 2px; padding: 0;
    color: #f5f5f5; font-size: 14px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.acp-header-info p { margin: 0; padding: 0; color: #22c55e; font-size: 11px; }
.acp-close {
    background: none; border: none; cursor: pointer; color: #9ca3af;
    font-size: 20px; line-height: 1; padding: 4px 6px; border-radius: 6px;
    transition: color 0.15s, background 0.15s; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.acp-close:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* ── Pre-chat form ───────────────────────────────────────────── */

.acp-form-wrap {
    flex: 1; overflow-y: auto; padding: 18px 18px 20px;
    background: #fafafa; display: flex; flex-direction: column;
}
.acp-form-wrap h3 { margin: 0 0 4px; padding: 0; font-size: 15px; font-weight: 700; color: #111; }
.acp-form-sub { margin: 0 0 16px; font-size: 13px; color: #6b7280; line-height: 1.5; }
.acp-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 11px; }
.acp-field label { font-size: 12.5px; font-weight: 600; color: #374151; }
.acp-field input,
.acp-field select {
    border: 1.5px solid #e5e7eb; border-radius: 9px; padding: 9px 12px;
    font-size: 13.5px; color: #111; background: #fff; outline: none;
    transition: border-color 0.15s; width: 100%;
    -webkit-appearance: none; appearance: none;
}
.acp-field input:focus,
.acp-field select:focus { border-color: var(--acp-accent, #6366f1); }
.acp-field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' stroke='%236b7280' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
    padding-right: 34px; cursor: pointer;
}
.acp-field-err { font-size: 11.5px; color: #ef4444; display: none; }
.acp-field.invalid .acp-field-err { display: block; }
.acp-field.invalid input,
.acp-field.invalid select { border-color: #ef4444; }

.acp-start-btn {
    margin-top: 6px; width: 100%; padding: 11px;
    background: var(--acp-accent, #6366f1); color: #fff;
    border: none; border-radius: 9px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: opacity 0.15s, transform 0.1s;
}
.acp-start-btn:hover   { opacity: 0.88; }
.acp-start-btn:active  { transform: scale(0.98); }
.acp-start-btn:disabled { opacity: 0.45; cursor: default; }

/* ── Chat area ───────────────────────────────────────────────── */

.acp-chat-wrap { flex: 1; display: none; flex-direction: column; overflow: hidden; min-height: 0; }
.acp-chat-wrap.active { display: flex; }

.acp-msgs {
    flex: 1; overflow-y: auto; padding: 14px 13px 10px;
    display: flex; flex-direction: column; gap: 10px;
    background: #f5f5f7; scroll-behavior: smooth;
}

/* ── Message bubbles ─────────────────────────────────────────── */

.acp-msg {
    max-width: 85%; border-radius: 14px; font-size: 13.5px;
    line-height: 1.55; word-break: break-word;
}
.acp-msg.bot {
    background: #fff; color: #111;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    align-self: flex-start; padding: 10px 13px;
}
.acp-msg.user {
    background: var(--acp-user-bubble, #6366f1); color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end; padding: 10px 13px;
}
.acp-msg.typing {
    background: #fff; border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    align-self: flex-start; padding: 13px 16px;
}

/* ── Markdown ────────────────────────────────────────────────── */

.acp-md { display: block; }
.acp-md p { margin: 0 0 8px; padding: 0; }
.acp-md p:last-child { margin-bottom: 0; }
.acp-md strong { font-weight: 700; }
.acp-md em     { font-style: italic; }
.acp-md code   { background: #f3f4f6; border-radius: 4px; padding: 1px 5px; font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.acp-md h3     { font-size: 14px; font-weight: 700; margin: 8px 0 4px; color: #111; }
.acp-md h4     { font-size: 13.5px; font-weight: 700; margin: 6px 0 3px; color: #111; }
.acp-md ul     { margin: 4px 0 6px; padding-left: 18px; list-style: disc; }
.acp-md ol     { margin: 4px 0 6px; padding-left: 18px; list-style: decimal; }
.acp-md li     { margin-bottom: 3px; }
.acp-md a      { color: var(--acp-accent, #6366f1); text-decoration: underline; }
.acp-md hr     { border: none; border-top: 1px solid #e5e7eb; margin: 8px 0; }

/* ── Typing dots ─────────────────────────────────────────────── */

.acp-dots { display: flex; gap: 4px; align-items: center; height: 14px; }
.acp-dots span {
    width: 7px; height: 7px; border-radius: 50%; background: #9ca3af;
    animation: acpBounce 1.1s infinite ease-in-out; display: inline-block;
}
.acp-dots span:nth-child(2) { animation-delay: 0.18s; }
.acp-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes acpBounce {
    0%,80%,100% { transform: translateY(0);    opacity: 0.45; }
    40%          { transform: translateY(-7px); opacity: 1; }
}

/* ── Action buttons (booking / whatsapp) ─────────────────────── */

.acp-actions {
    display: flex; flex-direction: column; gap: 7px;
    margin-top: 8px; max-width: 85%; align-self: flex-start;
}
.acp-action-btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 16px; font-size: 13px; font-weight: 600;
    text-decoration: none; cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    line-height: 1.4; width: 100%; justify-content: center;
}
.acp-action-btn:hover  { opacity: 0.88; }
.acp-action-btn:active { transform: scale(0.97); }

.acp-action-btn.booking {
    background: var(--acp-book-bg, #6366f1);
    color: var(--acp-book-color, #ffffff);
    border: var(--acp-book-border-w, 0px) solid var(--acp-book-border-color, #6366f1);
    border-radius: var(--acp-book-border-r, 10px);
    box-shadow: 0 2px 12px rgba(99,102,241,0.3);
}
.acp-action-btn.booking svg {
    width: var(--acp-book-icon-size, 16px);
    height: var(--acp-book-icon-size, 16px);
    fill: var(--acp-book-color, #ffffff);
    flex-shrink: 0;
}

.acp-action-btn.whatsapp {
    background: var(--acp-wa-bg, #25d366);
    color: var(--acp-wa-color, #ffffff);
    border: var(--acp-wa-border-w, 0px) solid var(--acp-wa-border-color, #25d366);
    border-radius: var(--acp-wa-border-r, 10px);
    box-shadow: 0 2px 12px rgba(37,211,102,0.3);
}
.acp-action-btn.whatsapp svg {
    width: var(--acp-wa-icon-size, 16px);
    height: var(--acp-wa-icon-size, 16px);
    fill: var(--acp-wa-color, #ffffff);
    flex-shrink: 0;
}

/* ── File attachment badge ───────────────────────────────────── */

.acp-file-badge {
    display: flex; align-items: center; gap: 6px;
    background: #f3f4f6; border: 1.5px solid #e5e7eb; border-radius: 8px;
    padding: 5px 10px; font-size: 12px; color: #374151;
    flex-shrink: 0; max-width: 200px; overflow: hidden;
}
.acp-file-badge svg { width: 14px; height: 14px; fill: #6b7280; flex-shrink: 0; }
.acp-file-badge span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.acp-file-badge-x {
    background: none; border: none; cursor: pointer; color: #9ca3af;
    font-size: 15px; line-height: 1; padding: 0; flex-shrink: 0;
    transition: color 0.15s; display: flex; align-items: center;
}
.acp-file-badge-x:hover { color: #ef4444; }

/* ── Input row ───────────────────────────────────────────────── */

.acp-input-wrap { border-top: 1px solid #ebebeb; background: #fff; flex-shrink: 0; }
.acp-attachment-row { padding: 6px 12px 0; display: none; }
.acp-attachment-row.visible { display: flex; }

.acp-input-row {
    padding: 7px 10px 9px;
    display: flex; align-items: center; gap: 4px;
}

/* Text input — takes all available space */
.acp-input-row input[type="text"] {
    flex: 1; min-width: 0;
    border: 1.5px solid var(--acp-input-border, #e5e7eb);
    border-radius: 22px;
    padding: 8px 14px;
    font-size: 13.5px;
    color: var(--acp-input-text, #111);
    background: var(--acp-input-bg, #f5f5f7);
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}
.acp-input-row input[type="text"]:focus {
    border-color: var(--acp-accent, #6366f1);
    background: #fff;
}

/* Tool buttons — minimum footprint, no border by default */
#acp-win .acp-tool-btn,
#acp-win .acp-tool-btn:focus,
#acp-win .acp-tool-btn:active {
    width: 30px !important; height: 30px !important;
    border-radius: var(--acp-tool-border-r, 50%) !important;
    border: var(--acp-tool-border-w, 0px) solid var(--acp-tool-border-color, transparent) !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    cursor: pointer !important;
    display: flex !important; align-items: center !important; justify-content: center !important;
    flex-shrink: 0 !important;
    color: var(--acp-tool-icon, #9ca3af) !important;
    transition: background 0.15s, color 0.15s !important;
    padding: 0 !important;
    margin: 0 !important;
    text-decoration: none !important;
}
#acp-win .acp-tool-btn:hover {
    background: var(--acp-tool-hover, #f3f4f6) !important;
    color: #374151 !important;
}
#acp-win .acp-tool-btn svg {
    width: var(--acp-tool-icon-size, 16px) !important;
    height: var(--acp-tool-icon-size, 16px) !important;
    fill: currentColor !important;
    display: block !important;
    stroke: none !important;
}

/* Send button */
#acp-win .acp-send-btn,
#acp-win .acp-send-btn:focus,
#acp-win .acp-send-btn:active {
    width: 36px !important; height: 36px !important;
    border-radius: var(--acp-send-border-r, 50%) !important;
    background: var(--acp-send-bg, var(--acp-accent, #6366f1)) !important;
    border: var(--acp-send-border-w, 0px) solid var(--acp-send-border-color, transparent) !important;
    outline: none !important;
    box-shadow: none !important;
    cursor: pointer !important;
    display: flex !important; align-items: center !important; justify-content: center !important;
    flex-shrink: 0 !important;
    transition: opacity 0.15s !important;
    padding: 0 !important;
    margin: 0 !important;
    text-decoration: none !important;
}
#acp-win .acp-send-btn:hover    { opacity: 0.85 !important; }
#acp-win .acp-send-btn:disabled { opacity: 0.35 !important; cursor: default !important; }
#acp-win .acp-send-btn svg {
    width: var(--acp-send-icon-size, 17px) !important;
    height: var(--acp-send-icon-size, 17px) !important;
    fill: var(--acp-send-icon, #fff) !important;
    display: block !important;
    stroke: none !important;
}

/* ── Emoji picker ────────────────────────────────────────────── */

.acp-emoji-wrap { position: relative; flex-shrink: 0; }

.acp-emoji-picker {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    width: 284px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.14);
    padding: 10px;
    display: none;
    z-index: 10;
}
.acp-emoji-picker.open { display: block; }

.acp-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}
.acp-emoji-grid button {
    border: none; background: none; cursor: pointer;
    font-size: 20px; padding: 4px; border-radius: 6px;
    transition: background 0.1s; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
}
.acp-emoji-grid button:hover { background: #f3f4f6; }

/* ── Mobile ──────────────────────────────────────────────────── */

@media (max-width: 480px) {
    #acp-win {
        left: 8px; right: 8px;
        width: auto; bottom: 82px;
        max-height: calc(100dvh - 100px);
    }
    #acp-btn { right: 14px; bottom: 14px; }
    #acp-label { right: 84px; bottom: 34px; font-size: 12px; padding: 7px 12px; }
    .acp-emoji-picker { left: 0; right: auto; width: 260px; }
}
