/* ========================================
   Chatbot Widget - Shriaaditya Dweller
   Embeddable floating popup widget
   ======================================== */

/* Widget Container */
#sdChatWidget {
    display: none;
    position: fixed;
    top: 80px;
    bottom: 90px;
    right: 24px;
    width: 390px;
    z-index: 99999;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    flex-direction: column;
    background: #fff;
    animation: sdWidgetSlideUp 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

#sdChatWidget.sd-open {
    display: flex;
}

@keyframes sdWidgetSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
#sdChatWidget .sdw-header {
    background: linear-gradient(135deg, #FFC631 0%, #FFB800 100%);
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
#sdChatWidget .sdw-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
#sdChatWidget .sdw-avatar {
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 15px;
    font-weight: bold;
}
#sdChatWidget .sdw-title {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    margin: 0;
    line-height: 1.2;
}
#sdChatWidget .sdw-status {
    font-size: 11px;
    color: rgba(255,255,255,0.85);
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}
#sdChatWidget .sdw-status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px rgba(34,197,94,0.8);
}
#sdChatWidget .sdw-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
}
#sdChatWidget .sdw-menu-btn,
#sdChatWidget .sdw-close-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    font-size: 22px;
    color: #fff;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.2s;
    line-height: 1;
}
#sdChatWidget .sdw-menu-btn:hover,
#sdChatWidget .sdw-close-btn:hover {
    background: rgba(255,255,255,0.25);
}

/* Dropdown Menu */
#sdChatWidget .sdw-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    min-width: 200px;
    z-index: 100;
    overflow: hidden;
    animation: sdwDropSlide 0.2s ease;
}
#sdChatWidget .sdw-dropdown.sdw-show { display: block; }
@keyframes sdwDropSlide {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
#sdChatWidget .sdw-drop-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 14px 18px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
    font-family: inherit;
}
#sdChatWidget .sdw-drop-item:hover { background: #f3f4f6; }
#sdChatWidget .sdw-drop-item:not(:last-child) { border-bottom: 1px solid #f0f0f0; }

/* Chat Messages */
#sdChatWidget .sdw-messages {
    flex: 1;
    min-height: 200px;
    overflow-y: auto;
    padding: 16px 14px;
    background: #f8f9fa;
}
#sdChatWidget .sdw-messages::-webkit-scrollbar { width: 5px; }
#sdChatWidget .sdw-messages::-webkit-scrollbar-track { background: #f1f1f1; }
#sdChatWidget .sdw-messages::-webkit-scrollbar-thumb { background: #c0c0c0; border-radius: 3px; }

#sdChatWidget .sdw-msg {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    animation: sdwMsgIn 0.3s ease;
}
@keyframes sdwMsgIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
#sdChatWidget .sdw-msg-bot { align-items: flex-start; }
#sdChatWidget .sdw-msg-user { flex-direction: row-reverse; }

#sdChatWidget .sdw-msg-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #FFC631 0%, #FFB800 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(255,198,49,0.4);
}
#sdChatWidget .sdw-msg-user .sdw-msg-icon {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 12px rgba(245,87,108,0.3);
}

#sdChatWidget .sdw-msg-body {
    background: #fff;
    padding: 10px 14px;
    border-radius: 14px;
    max-width: 80%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    line-height: 1.5;
    font-size: 13px;
    color: #374151;
    word-wrap: break-word;
}
#sdChatWidget .sdw-msg-user .sdw-msg-body {
    background: linear-gradient(135deg, #FFC631 0%, #FFB800 100%);
    color: #1f2937;
    box-shadow: 0 4px 16px rgba(255,198,49,0.4);
}
#sdChatWidget .sdw-msg-body strong { color: #1f2937; font-weight: 600; }
#sdChatWidget .sdw-msg-body em { color: #FFC631; font-style: italic; font-weight: 500; }
#sdChatWidget .sdw-msg-user .sdw-msg-body em { color: #1f2937; }
#sdChatWidget .sdw-msg-body a { color: #FFC631; text-decoration: none; border-bottom: 1px solid #FFC631; }
#sdChatWidget .sdw-msg-body a:hover { color: #FFB800; }
#sdChatWidget .sdw-msg-time {
    font-size: 10px;
    color: #9ca3af;
    display: block;
    margin-top: 6px;
    opacity: 0.8;
}
#sdChatWidget .sdw-msg-user .sdw-msg-time { color: rgba(31,41,55,0.65); }

/* Typing Indicator */
#sdChatWidget .sdw-typing .sdw-msg-body {
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 6px;
}
#sdChatWidget .sdw-typing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    margin-left: 4px;
}
#sdChatWidget .sdw-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #FFC631;
    animation: sdwDot 1.4s infinite;
}
#sdChatWidget .sdw-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
#sdChatWidget .sdw-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes sdwDot {
    0%,60%,100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-6px); }
}

/* Quick Actions */
#sdChatWidget .sdw-quick-actions {
    padding: 8px 12px;
    background: #fff;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}
#sdChatWidget .sdw-action-btn {
    padding: 7px 10px;
    border: 2px solid #e5e7eb;
    background: #fff;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-family: inherit;
}
#sdChatWidget .sdw-action-btn:hover {
    border-color: #FFC631;
    color: #FFC631;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255,198,49,0.3);
}
#sdChatWidget .sdw-action-btn.sdw-primary {
    background: linear-gradient(135deg, #FFC631 0%, #FFB800 100%);
    color: #1f2937;
    border-color: transparent;
    font-weight: 600;
}
#sdChatWidget .sdw-action-btn.sdw-primary:hover {
    background: linear-gradient(135deg, #FFD147 0%, #FFC631 100%);
    border-color: transparent;
    color: #1f2937;
    box-shadow: 0 4px 16px rgba(255,198,49,0.5);
}

/* Input Area */
#sdChatWidget .sdw-input-area {
    padding: 8px 12px;
    background: #fff;
    display: flex;
    gap: 8px;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}
#sdChatWidget .sdw-input {
    flex: 1;
    padding: 9px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    font-size: 13px;
    outline: none;
    transition: all 0.3s;
    background: #f9fafb;
    color: #1f2937;
    font-family: inherit;
}
#sdChatWidget .sdw-input::placeholder { color: #9ca3af; }
#sdChatWidget .sdw-input:focus {
    border-color: #FFC631;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(255,198,49,0.15);
}
#sdChatWidget .sdw-send-btn {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #FFC631 0%, #FFB800 100%);
    border: none;
    border-radius: 50%;
    color: #1f2937;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(255,198,49,0.4);
    flex-shrink: 0;
}
#sdChatWidget .sdw-send-btn:hover {
    background: linear-gradient(135deg, #FFD147 0%, #FFC631 100%);
    transform: scale(1.05);
}
#sdChatWidget .sdw-send-btn svg { width: 18px; height: 18px; }

/* Powered By */
#sdChatWidget .sdw-powered {
    text-align: center;
    padding: 6px 12px;
    font-size: 10px;
    color: #9ca3af;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}
#sdChatWidget .sdw-powered a {
    color: #FFC631;
    text-decoration: none;
    font-weight: 600;
}
#sdChatWidget .sdw-powered a:hover { color: #FFB800; text-decoration: underline; }

/* Contact Modal */
#sdChatWidget .sdw-modal-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 10;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}
#sdChatWidget .sdw-modal-overlay.sdw-show { display: flex; }

#sdChatWidget .sdw-modal-box {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    width: calc(100% - 32px);
    max-width: 360px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: sdwModalIn 0.3s ease;
}
@keyframes sdwModalIn {
    from { opacity: 0; transform: scale(0.95) translateY(12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
#sdChatWidget .sdw-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}
#sdChatWidget .sdw-modal-head h3 {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}
#sdChatWidget .sdw-modal-close {
    background: none;
    border: none;
    font-size: 26px;
    color: #9ca3af;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}
#sdChatWidget .sdw-modal-close:hover { color: #374151; }

#sdChatWidget .sdw-form-group {
    margin-bottom: 14px;
}
#sdChatWidget .sdw-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 5px;
}
#sdChatWidget .sdw-form-group input,
#sdChatWidget .sdw-form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 13px;
    color: #1f2937;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f9fafb;
    font-family: inherit;
    box-sizing: border-box;
}
#sdChatWidget .sdw-form-group input:focus,
#sdChatWidget .sdw-form-group textarea:focus {
    border-color: #FFC631;
    box-shadow: 0 0 0 3px rgba(255,198,49,0.15);
    background: #fff;
}
#sdChatWidget .sdw-form-group textarea {
    resize: vertical;
    min-height: 60px;
}
#sdChatWidget .sdw-form-submit {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #FFC631 0%, #FFB800 100%);
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(255,198,49,0.4);
    font-family: inherit;
}
#sdChatWidget .sdw-form-submit:hover {
    background: linear-gradient(135deg, #FFD147 0%, #FFC631 100%);
    transform: translateY(-1px);
}
#sdChatWidget .sdw-form-submit:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

#sdChatWidget .sdw-modal-note {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 10px;
    margin-bottom: 0;
}

/* Responsive — mobile full screen */
@media (max-width: 480px) {
    #sdChatWidget {
        top: 0;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        border-radius: 0;
    }
}
