/* ==========================================================================
   1. SETTINGS PAGE UI (Dark Mode "Webheads" Layout)
   ========================================================================== */
:root {
    --wh-chat-brand-color: #d11616;
    --wh-chat-text-color: #ffffff;
}

.webheads-module-intro.ai-chat-intro {
    background: #fff;
    border: 1px solid #ccd0d4;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 25px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.ai-chat-intro h1 {
    margin: 0 0 10px 0;
    font-size: 22px;
}

.ai-badge {
    background: linear-gradient(45deg, var(--webheads-element-background-color), var(--webheads-color-primary));
    color: white !important;
    padding: 2px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    vertical-align: middle;
    margin-left: 10px;
    display: inline-block;
}

.ai-chat-intro p {
    font-size: 15px;
    color: #50575e;
    line-height: 1.5;
}

.ai-chat-intro strong {
    color: var(--webheads-color-primary);
}

.intro-badges {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

.intro-badges .badge {
    display: flex;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: #2c3338;
    background: #f0f0f1;
    padding: 4px 10px;
    border-radius: 15px;
}

.intro-badges .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    margin-right: 6px;
    color: var(--webheads-color-primary);
}

.webheads-settings-block { margin-bottom: 20px; background: var(--webheads-background-color); padding: 20px; border-radius: 8px; }
.webheads-settings-block.black label { color: white; }

.webheads-settings-block h3 {
    margin: 0 0 8px 0;
    font-size: 22px;
    display: flex;
    align-items: center;
    color: white;
}

.webheads-settings-block h3 .dashicons {
    font-size: 24px;
    height: 24px;
    margin-right: 10px;
    color: var(--webheads-color-primary);
}

.webheads-settings-block p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: white;
}

.webheads-settings-block strong {
    color: var(--webheads-color-primary);
}

.post-selection-chat fieldset { width: fit-content; margin-top: 20px; }
.post-selection-chat label { color: black; cursor: pointer; }
.ai-faq-settings h1 { padding: 0; margin-bottom: 20px; }
.post-selection-chat h2 { color: var(--webheads-color-primary); margin-top: 0; }

.post-selection-chat input[type=checkbox]:checked::before {
    content: url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M14.83%204.89l1.34.94-5.81%208.38H9.02L5.78%209.67l1.34-1.25%202.57%202.4z%27%20fill%3D%27%23d63638%27%2F%3E%3C%2Fsvg%3E");
}

.post-selection-chat input:focus, .post-selection-chat textarea:focus {
    border-color: #d63638;
    box-shadow: 0 0 0 1px #d63638;
}

.post-types { display: block; margin-bottom: 5px; }

.webheads-settings-block.white { 
    background: #fff;
    border: 1px solid #ccd0d4;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 25px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.webheads-settings-block.white h3, .webheads-settings-block.white p { color: #1d2327 !important; }
.webheads-settings-block.white th, .webheads-settings-block.white p { color: #50575e !important; }

.webheads-button { background: var(--webheads-color-primary) !important; color: white !important; border: none !important; margin-top: 15px !important; }
.webheads-button:hover { background: #d63638de !important; }
.webheads-button span { padding-top: 4px; }

/* ==========================================================================
   2. FRONTEND CHAT WIDGET UI
   ========================================================================== */
#webheads-chat-widget {
    position: fixed;
    bottom: 90px;
    right: 30px;
    width: 350px;
    height: 550px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    z-index: 99999;
    overflow: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#webheads-chat-widget.closed { transform: translateY(20px); opacity: 0; pointer-events: none; }

#webheads-chat-widget .chat-header {
    background: var(--wh-chat-brand-color, #d11616);
    color: var(--wh-chat-text-color, #ffffff);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

/* Default Logo Styling - Applied if no custom inline style is present */
#webheads-chat-widget .chat-header img,
.preview-header-logo {
    display: inline-block;
    max-width: 100%;
    object-fit: contain;
    vertical-align: middle;
    width: 25px;
    height: 25px;
}

.preview-header-logo.custom-size {
    object-fit: unset !important; 
}

.wh-chat-close { margin-left: 20px; font-size: 18px; cursor: pointer; }

#chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fafafa;
}

.msg { padding: 10px 14px; border-radius: 12px; max-width: 85%; font-size: 0.95rem; line-height: 1.4; }
.msg.bot { background: #e9ecef; align-self: flex-start; color: #2c3338; border-bottom-left-radius: 2px; }
.msg.user { background: var(--wh-chat-brand-color, #d11616); color: white; align-self: flex-end; border-bottom-right-radius: 2px; }

.chat-footer { border-top: 1px solid #eee; background: #fff; }
#wh-chat-input, #preview-input { width: 100%; padding: 15px 20px; border: none; outline: none; box-sizing: border-box; background: white; }

.chat-footer .speak-human {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: #25D366;
    color: white;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
}

#chat-toggle-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--wh-chat-brand-color, #d11616);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 15px rgba(0,0,0,0.2);
    z-index: 99999;
}

/* ==========================================================================
   3. SETTINGS PAGE LAYOUT & PREVIEW
   ========================================================================== */
.flex-settings { display: flex; flex-wrap: wrap; gap: 20px; align-items: stretch; margin-bottom: 20px; }
.flex-settings .webheads-settings-block.white { margin-bottom: 0; }
.flex-settings .webheads-settings-block, .flex-settings .chat-preview { flex: 1; display: flex; flex-direction: column; }
.flex-settings .logo-size, .flex-settings .logo-position { display: flex; flex-direction: column; }
.logo-position button { margin-top: 59px !important; }
.logo-size button { margin-top: 31px !important; }
/*.size-header { display: flex; justify-content: space-between; }*/
.aspect-ratio { display: block; margin-top: 10px !important; }
.size-header label { margin-block: auto; }
.chat-preview { display: flex; flex-direction: column; }
.preview-window-container { flex-grow: 1; }

.chat-preview {
    flex: 0 0 380px !important;
    background: #111;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #333;
}

.chat-preview h3 {
    color: #fff;
    margin-top: 0;
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
    border: none;
}

.preview-window-container {
    background: #f0f0f1;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #333;
    display: flex;
    justify-content: center;
}

#webheads-chat-widget.preview-mode {
    position: relative !important;
    bottom: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 480px !important;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    border: 1px solid #ddd;
    opacity: 1 !important;
    transform: none !important;
    pointer-events: none;
    display: flex !important;
}

#webheads-chat-widget.preview-mode #chat-messages { background: #fafafa; }
#preview-brand-name { transition: font-size 0.1s ease; display: inline-block; white-space: nowrap; }

/* ==========================================================================
   4. WIDGET STATUS & ANIMATIONS
   ========================================================================== */
.webheads-toggle-group { display: inline-flex; gap: 15px; }
.webheads-toggle-group input { display: none; }
.webheads-toggle-group label { margin: 0 !important; padding: 6px 16px; background: #f6f7f7; color: #3c434a; border: none; border-right: 1px solid #c3c4c7; cursor: pointer; font-weight: 500; font-size: 13px; }

#status_on:checked + label[for="status_on"] { background: #007cba; color: #fff; }
#status_off:checked + label[for="status_off"] { background: #d63638; border-color: #d63638; color: #fff; }

.msg.bot.typing { font-style: italic; color: #666; background: #e9ecef; padding: 10px 15px; font-size: 0.85rem; }
.msg.bot.typing::after { content: '...'; animation: dots 1.5s infinite; }
@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60% { content: '...'; }
    80%, 100% { content: ''; }
}