/* ─── Farm Chat Widget ──────────────────────────────────────────────────────── */
/* Colors are injected as CSS custom properties from the settings page.         */

:root {
    --fcb-primary:      #298a20;
    --fcb-primary-dark: #1f6b17;
}

body.send-msg-open {
    overflow: hidden;
}

/* ── Trigger button ────────────────────────────────────────────────────────── */

#fcb-trigger {
    color: #fff;
    text-align: center;
    border: 3px solid var(--fcb-primary);
    border-radius: 4px;
    background-color: var(--fcb-primary);
    padding: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    transition: color 0.2s ease, background-color 0.2s ease;
    position: fixed;
    right: 5px;
    bottom: 5px;
    height: 40px;
    width: 120px;
    z-index: 100000000;
    cursor: pointer;
}

#fcb-trigger:hover {
    color: var(--fcb-primary);
    background-color: #fff;
    box-shadow: none;
}

#fcb-trigger span {
    font-size: 15px;
    font-family: Open-Sans, Verdana, Geneva, sans-serif;
    font-weight: bold;
    text-transform: uppercase;
}

/* ── Panel ─────────────────────────────────────────────────────────────────── */

#send-msg {
    opacity: 0;
    position: fixed;
    visibility: hidden;
    width: 400px;
    box-sizing: border-box;
    transition: all .5s ease-in-out;
    z-index: 1000000000;
    border-radius: 0;
    display: flex;
    flex-direction: column;
}

#send-msg.fcb-open {
    opacity: 1;
    bottom: 70px;
    right: 20px;
    visibility: visible;
}

/* ── Close button ──────────────────────────────────────────────────────────── */

#send-msg .fcb-header {
    z-index: 21;
    position: relative;
    bottom: -20px;
    left: -10px;
}

#send-msg .fcb-header-close {
    text-align: center;
    background-color: #fff;
    font-size: 17px;
    font-weight: bold;
    width: 34px;
    height: 34px;
    border: 2px solid #bab6b6;
    border-radius: 50%;
    display: table-cell;
    vertical-align: middle;
}

#send-msg .fcb-header-close:hover {
    border: 2px solid #000;
}

#send-msg .fcb-header-close:hover .fcb-close {
    color: #000 !important;
    text-decoration: none !important;
}

#send-msg .fcb-close {
    color: #bab6b6;
    text-decoration: none !important;
    font-family: Arial;
    font-size: 16px;
}

#send-msg .fcb-close:hover {
    color: #000;
    text-decoration: none !important;
}

button.close-send-msg {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-decoration: none;
}

/* ── Title bar ─────────────────────────────────────────────────────────────── */

.send-msg-title {
    font-weight: bold;
    font-size: 16px;
    text-align: center;
    padding: 10px 0;
    color: #fff;
    background: var(--fcb-primary);
    box-shadow: inset 0 3px 15px rgba(255, 255, 255, 0.2), 0 5px 13px 0 rgba(67, 74, 76, 0.12);
    position: relative;
    z-index: 20;
    flex-shrink: 0;
}

/* ── Messages area ─────────────────────────────────────────────────────────── */

#fcb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 15px;
    background: #f8f8f8;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 380px;
    min-height: 150px;
    scrollbar-width: thin;
    scrollbar-color: #666 #CFD8DC;
}

#fcb-messages::-webkit-scrollbar       { width: 6px; }
#fcb-messages::-webkit-scrollbar-track { background: #CFD8DC; }
#fcb-messages::-webkit-scrollbar-thumb { background-color: #666; border-radius: 6px; }

/* ── Chat bubbles ──────────────────────────────────────────────────────────── */

.fcb-bubble {
    max-width: 85%;
    word-wrap: break-word;
    animation: fcb-fadein 0.2s ease;
}

.fcb-bubble p {
    margin: 0;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.5;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

.fcb-bubble--bot { align-self: flex-start; }

.fcb-bubble--bot p {
    background: #fff;
    color: #333;
    border-radius: 4px 16px 16px 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.fcb-bubble--user { align-self: flex-end; }

.fcb-bubble--user p {
    background: var(--fcb-primary);
    color: #fff;
    border-radius: 16px 4px 16px 16px;
}

/* ── Links inside bubbles ──────────────────────────────────────────────────── */

.fcb-bubble--bot p a {
    color: var(--fcb-primary);
    text-decoration: underline;
    text-decoration-style: dotted;
    word-break: break-all;
}

.fcb-bubble--bot p a:hover { text-decoration-style: solid; }

.fcb-bubble--user p a {
    color: #fff;
    text-decoration: underline;
    opacity: 0.9;
}

/* ── Typing indicator ──────────────────────────────────────────────────────── */

.fcb-typing {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    background: #fff;
    border-radius: 4px 16px 16px 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    align-self: flex-start;
    gap: 5px;
}

.fcb-typing span {
    width: 8px;
    height: 8px;
    background: #aaa;
    border-radius: 50%;
    display: inline-block;
    animation: fcb-bounce 1.2s infinite;
}

.fcb-typing span:nth-child(2) { animation-delay: 0.2s; }
.fcb-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes fcb-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-5px); }
}

@keyframes fcb-fadein {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Input area ────────────────────────────────────────────────────────────── */

.fcb-input-area {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    gap: 8px;
    flex-shrink: 0;
}

#fcb-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    outline: none;
    color: #333;
    background: #f8f8f8;
}

#fcb-input:focus    { border-color: var(--fcb-primary); background: #fff; }
#fcb-input:disabled { opacity: 0.6; }

#fcb-send {
    background: var(--fcb-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color 0.2s ease;
}

#fcb-send:hover    { background: var(--fcb-primary-dark); }
#fcb-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Footer bar ────────────────────────────────────────────────────────────── */

.fcb-footer-bar {
    text-align: center;
    padding: 5px 0 7px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.fcb-footer-bar button {
    background: none;
    border: none;
    color: var(--fcb-primary);
    font-size: 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    cursor: pointer;
    padding: 2px 8px;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.fcb-footer-bar button:hover { text-decoration-style: solid; }

/* ── Contact form view ─────────────────────────────────────────────────────── */

#fcb-contact-view {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.fcb-contact-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px 16px;
    background: #f8f8f8;
    scrollbar-width: thin;
    scrollbar-color: #666 #CFD8DC;
}

.fcb-contact-intro {
    margin: 0 0 12px;
    font-size: 13px;
    color: #555;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.4;
}

.fcb-field { margin-bottom: 8px; }

.fcb-field input,
.fcb-field textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    color: #333;
    background: #fff;
    outline: none;
    transition: border-color 0.2s ease;
}

.fcb-field input:focus,
.fcb-field textarea:focus { border-color: var(--fcb-primary); }

.fcb-field textarea { resize: vertical; min-height: 70px; }

#fcb-cf-status {
    min-height: 16px;
    margin: 6px 0;
    font-size: 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.4;
}

.fcb-cf-error   { color: #c0392b; }
.fcb-cf-success { color: #27ae60; font-weight: bold; }

.fcb-contact-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

#fcb-back-to-chat {
    background: none;
    border: none;
    color: #888;
    font-size: 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    cursor: pointer;
    padding: 4px 0;
    text-decoration: underline;
    text-decoration-style: dotted;
}

#fcb-back-to-chat:hover { color: #333; text-decoration-style: solid; }

#fcb-cf-submit {
    background: var(--fcb-primary);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 8px 20px;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#fcb-cf-submit:hover    { background: var(--fcb-primary-dark); }
#fcb-cf-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Overlay ───────────────────────────────────────────────────────────────── */

.fcb-overlay {
    display: none;
    background: rgba(0, 0, 0, .3);
    height: 100%;
    left: 0;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 999999999;
}

.fcb-overlay.fcb-open { display: block; }

/* ── Responsive ────────────────────────────────────────────────────────────── */

@media only screen and (min-width: 651px) and (max-width: 1024px) {
    #send-msg       { width: 350px !important; }
    #send-msg.fcb-open { margin-left: -175px !important; }
}

@media only screen and (max-width: 650px) {
    #send-msg          { width: 90%; min-width: 90%; }
    #send-msg.fcb-open { top: 5%; left: 5%; bottom: 5%; height: 90%; margin-left: unset !important; }
    #fcb-messages      { max-height: none; }
    #fcb-trigger       { height: 40px; width: 120px; }
}
