/* =============================================
   DASSS Custom Chat Widget – Frontend Styles

   All selectors are scoped under #dasss-chat-root so host theme styles
   (Astra, Elementor, Divi etc.) can't bleed into the widget. The reset
   block below explicitly declares the properties themes most often set
   globally on buttons, inputs and labels.
   ============================================= */

#dasss-chat-root {
    --dc-primary:       #2563eb;
    --dc-primary-dark:  #1d4ed8;
    --dc-primary-light: #eff6ff;
    --dc-bg:            #ffffff;
    --dc-border:        #e5e7eb;
    --dc-text:          #111827;
    --dc-text-muted:    #6b7280;
    --dc-bubble-bot:    #f3f4f6;
    --dc-radius:        16px;
    --dc-shadow:        0 8px 32px rgba(0,0,0,0.15);
    --dc-z:             99999;
}

/* =============================================
   Scoped Reset — neutralise inherited theme styles
   ============================================= */

#dasss-chat-root,
#dasss-chat-root *,
#dasss-chat-root *::before,
#dasss-chat-root *::after {
    box-sizing: border-box;
}

#dasss-chat-root button,
#dasss-chat-root input,
#dasss-chat-root select,
#dasss-chat-root textarea {
    margin: 0;
    padding: 0;
    width: auto;
    height: auto;
    min-width: 0;
    min-height: 0;
    max-width: none;
    font-family: inherit;
    font-size: inherit;
    font-weight: normal;
    line-height: normal;
    letter-spacing: normal;
    text-transform: none;
    text-align: left;
    box-shadow: none;
    text-shadow: none;
    background-image: none;
    float: none;
}

#dasss-chat-root label,
#dasss-chat-root p,
#dasss-chat-root div,
#dasss-chat-root span {
    margin: 0;
    padding: 0;
    font-family: inherit;
}

#dasss-chat-root svg {
    vertical-align: middle;
    max-width: none;
}

/* =============================================
   Root Container
   ============================================= */

#dasss-chat-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: var(--dc-z);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: normal;
    text-align: left;
    text-transform: none;
    color: var(--dc-text);
}

/* =============================================
   Toggle Button
   ============================================= */

#dasss-chat-root #dasss-chat-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 50%;
    background: var(--dc-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(37,99,235,0.45);
    transition: background 0.2s, transform 0.2s;
    position: relative;
}

#dasss-chat-root #dasss-chat-toggle:hover {
    background: var(--dc-primary-dark);
    transform: scale(1.08);
}

#dasss-chat-root #dasss-chat-toggle svg {
    width: 26px;
    height: 26px;
    position: absolute;
    transition: opacity 0.2s, transform 0.2s;
}

#dasss-chat-root #dasss-chat-toggle .dasss-icon-chat {
    opacity: 1;
    transform: scale(1);
}

#dasss-chat-root #dasss-chat-toggle .dasss-icon-close {
    opacity: 0;
    transform: scale(0.6);
}

#dasss-chat-root #dasss-chat-toggle[aria-expanded="true"] .dasss-icon-chat {
    opacity: 0;
    transform: scale(0.6);
}

#dasss-chat-root #dasss-chat-toggle[aria-expanded="true"] .dasss-icon-close {
    opacity: 1;
    transform: scale(1);
}

/* =============================================
   Chat Window
   ============================================= */

#dasss-chat-root #dasss-chat-window {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 360px;
    max-height: 560px;
    background: var(--dc-bg);
    border-radius: var(--dc-radius);
    box-shadow: var(--dc-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: dasss-slide-up 0.25s ease;
}

#dasss-chat-root #dasss-chat-window[hidden] {
    display: none;
}

@keyframes dasss-slide-up {
    from { opacity: 0; transform: translateY(16px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* =============================================
   Header
   ============================================= */

#dasss-chat-root #dasss-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--dc-primary);
    color: #fff;
    flex-shrink: 0;
}

#dasss-chat-root #dasss-chat-title {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.4;
    color: #fff;
}

#dasss-chat-root #dasss-chat-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    flex-shrink: 0;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    transition: background 0.15s;
}

#dasss-chat-root #dasss-chat-close:hover {
    background: rgba(255,255,255,0.35);
}

#dasss-chat-root #dasss-chat-close svg {
    width: 16px;
    height: 16px;
}

/* =============================================
   Messages Area
   ============================================= */

#dasss-chat-root #dasss-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

/* Bot message bubble */
#dasss-chat-root .dasss-msg-bot {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 85%;
    animation: dasss-fade-in 0.2s ease;
}

#dasss-chat-root .dasss-msg-bot .dasss-bubble {
    background: var(--dc-bubble-bot);
    color: var(--dc-text);
    padding: 10px 14px;
    border-radius: 4px 16px 16px 16px;
    font-size: 14px;
    line-height: 1.45;
}

/* Typing indicator */
#dasss-chat-root .dasss-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 14px;
    background: var(--dc-bubble-bot);
    border-radius: 4px 16px 16px 16px;
    width: 52px;
}

#dasss-chat-root .dasss-typing span {
    width: 7px;
    height: 7px;
    background: var(--dc-text-muted);
    border-radius: 50%;
    animation: dasss-bounce 1.2s infinite;
}

#dasss-chat-root .dasss-typing span:nth-child(2) { animation-delay: 0.2s; }
#dasss-chat-root .dasss-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dasss-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-6px); }
}

@keyframes dasss-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Location buttons */
#dasss-chat-root .dasss-location-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

#dasss-chat-root .dasss-location-btn {
    padding: 7px 14px;
    width: auto;
    background: #fff;
    color: var(--dc-primary);
    border: 1.5px solid var(--dc-primary);
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    text-align: center;
    transition: background 0.15s, color 0.15s;
}

#dasss-chat-root .dasss-location-btn:hover,
#dasss-chat-root .dasss-location-btn.selected {
    background: var(--dc-primary);
    color: #fff;
}

#dasss-chat-root .dasss-location-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* =============================================
   Form Area
   ============================================= */

#dasss-chat-root #dasss-chat-form-area {
    flex-shrink: 0;
    border-top: 1px solid var(--dc-border);
    padding: 14px 16px 16px;
    max-height: 320px;
    overflow-y: auto;
    animation: dasss-fade-in 0.25s ease;
}

#dasss-chat-root #dasss-chat-form-area[hidden] {
    display: none;
}

#dasss-chat-root .dasss-form-field {
    margin-bottom: 10px;
}

#dasss-chat-root .dasss-form-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--dc-text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.4;
}

#dasss-chat-root .dasss-form-field label .dasss-required {
    color: #dc2626;
    margin-left: 2px;
}

#dasss-chat-root .dasss-form-field input[type="text"],
#dasss-chat-root .dasss-form-field input[type="tel"],
#dasss-chat-root .dasss-form-field input[type="email"],
#dasss-chat-root .dasss-form-field select,
#dasss-chat-root .dasss-form-field textarea {
    width: 100%;
    height: auto;
    padding: 8px 10px;
    border: 1.5px solid var(--dc-border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 400;
    line-height: 1.4;
    letter-spacing: normal;
    text-transform: none;
    color: var(--dc-text);
    background: #fff;
    background-image: none;
    transition: border-color 0.15s;
    box-sizing: border-box;
}

#dasss-chat-root .dasss-form-field input:focus,
#dasss-chat-root .dasss-form-field select:focus,
#dasss-chat-root .dasss-form-field textarea:focus {
    outline: none;
    border-color: var(--dc-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

#dasss-chat-root .dasss-form-field textarea {
    min-height: 72px;
    resize: vertical;
}

/* Radio / Checkbox group */
#dasss-chat-root .dasss-radio-group,
#dasss-chat-root .dasss-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 2px;
}

#dasss-chat-root .dasss-radio-group label,
#dasss-chat-root .dasss-checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 400;
    color: var(--dc-text);
    text-transform: none;
    letter-spacing: 0;
    margin-bottom: 0;
    cursor: pointer;
}

#dasss-chat-root .dasss-radio-group input,
#dasss-chat-root .dasss-checkbox-group input {
    width: auto;
    height: auto;
    margin: 0;
    accent-color: var(--dc-primary);
}

/* Turnstile container */
#dasss-chat-root .dasss-turnstile-container {
    margin-top: 10px;
    margin-bottom: 10px;
}

/* Submit button */
#dasss-chat-root #dasss-chat-submit-btn {
    display: block;
    width: 100%;
    height: auto;
    padding: 10px;
    background: var(--dc-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: normal;
    text-transform: none;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    margin-top: 6px;
    font-family: inherit;
}

#dasss-chat-root #dasss-chat-submit-btn:hover:not(:disabled) {
    background: var(--dc-primary-dark);
}

#dasss-chat-root #dasss-chat-submit-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Error message */
#dasss-chat-root .dasss-form-error {
    color: #dc2626;
    font-size: 13px;
    line-height: 1.45;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 10px;
}

/* Success state */
#dasss-chat-root .dasss-success-msg {
    text-align: center;
    padding: 24px 16px;
    animation: dasss-fade-in 0.3s ease;
}

#dasss-chat-root .dasss-success-icon {
    width: 48px;
    height: 48px;
    background: #dcfce7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}

#dasss-chat-root .dasss-success-icon svg {
    width: 26px;
    height: 26px;
    color: #16a34a;
}

#dasss-chat-root .dasss-success-text {
    font-size: 14px;
    line-height: 1.5;
    color: var(--dc-text-muted);
}

/* =============================================
   Responsive
   ============================================= */

@media (max-width: 400px) {
    #dasss-chat-root #dasss-chat-window {
        width: calc(100vw - 32px);
        right: 0;
    }

    #dasss-chat-root {
        bottom: 16px;
        right: 16px;
    }
}
