/* SmarterCalendar Chat Widget — Self-contained styles */
/* All selectors scoped with #sc-chat to avoid host page conflicts */

#sc-chat-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #5083ff;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(80, 131, 255, 0.4);
    z-index: 99999;
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 24px;
    line-height: 1;
    padding: 0;
}

#sc-chat-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(80, 131, 255, 0.5);
}

#sc-chat-launcher .sc-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #d9534f;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid #fff;
    line-height: 1;
}

#sc-chat-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 370px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    z-index: 99999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #1e293b;
    animation: sc-chat-slide-up 0.25s ease-out;
}

#sc-chat-panel * {
    box-sizing: border-box;
}

#sc-chat-panel.sc-open {
    display: flex;
}

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

/* Header */
#sc-chat-panel .sc-header {
    background: #5083ff;
    color: #fff;
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

#sc-chat-panel .sc-header-info h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}

#sc-chat-panel .sc-header-info p {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.85;
    line-height: 1.3;
}

#sc-chat-panel .sc-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

#sc-chat-panel .sc-end-chat-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: rgba(255, 255, 255, 0.85);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}

#sc-chat-panel .sc-end-chat-btn:hover {
    background: rgba(255, 80, 80, 0.35);
    color: #fff;
}

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

#sc-chat-panel .sc-close-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* Status dot */
#sc-chat-panel .sc-status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
    position: relative;
    top: -1px;
}

#sc-chat-panel .sc-status-dot.sc-online {
    background: #34d399;
    box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.3);
}

#sc-chat-panel .sc-status-dot.sc-away {
    background: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
}

#sc-chat-panel .sc-status-dot.sc-offline {
    background: #94a3b8;
}

/* Offline banner */
#sc-chat-panel .sc-offline-banner {
    padding: 12px 16px;
    background: #fef3c7;
    border-bottom: 1px solid #fde68a;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    flex-shrink: 0;
    color: #92400e;
}

#sc-chat-panel .sc-offline-banner p {
    margin: 0;
    font-size: 12px;
    line-height: 1.45;
}

#sc-chat-panel .sc-offline-banner .sc-next-open {
    margin-top: 4px;
    font-weight: 600;
    font-size: 11px;
    color: #78350f;
}

#sc-chat-panel .sc-offline-banner.sc-away-banner {
    background: #fff7ed;
    border-bottom-color: #fed7aa;
    color: #9a3412;
}

/* Pre-chat form */
#sc-chat-panel .sc-prechat {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 30px 24px;
}

#sc-chat-panel .sc-prechat h5 {
    margin: 0 0 6px;
    font-size: 17px;
    font-weight: 600;
    color: #1e293b;
}

#sc-chat-panel .sc-prechat p {
    margin: 0 0 20px;
    font-size: 13px;
    color: #64748b;
}

#sc-chat-panel .sc-form-group {
    margin-bottom: 14px;
}

#sc-chat-panel .sc-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}

#sc-chat-panel .sc-form-group input,
#sc-chat-panel .sc-form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    color: #1e293b;
    background: #fff;
}

#sc-chat-panel .sc-form-group input:focus,
#sc-chat-panel .sc-form-group textarea:focus {
    border-color: #5083ff;
}

#sc-chat-panel .sc-form-group textarea {
    resize: none;
    min-height: 60px;
}

#sc-chat-panel .sc-start-btn {
    width: 100%;
    padding: 10px;
    background: #5083ff;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 4px;
    font-family: inherit;
}

#sc-chat-panel .sc-start-btn:hover {
    background: #4275e0;
}

#sc-chat-panel .sc-start-btn:disabled {
    background: #a7a8a9;
    cursor: not-allowed;
}

/* Messages area */
#sc-chat-panel .sc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #f8f9fa;
}

#sc-chat-panel .sc-msg {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

#sc-chat-panel .sc-msg.sc-visitor {
    align-self: flex-end;
    align-items: flex-end;
}

#sc-chat-panel .sc-msg.sc-admin {
    align-self: flex-start;
    align-items: flex-start;
}

#sc-chat-panel .sc-msg-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
}

#sc-chat-panel .sc-msg.sc-visitor .sc-msg-bubble {
    background: #5083ff;
    color: #fff;
    border-bottom-right-radius: 4px;
}

#sc-chat-panel .sc-msg.sc-admin .sc-msg-bubble {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

#sc-chat-panel .sc-msg-time {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 2px;
    padding: 0 4px;
}

#sc-chat-panel .sc-date-divider {
    text-align: center;
    margin: 10px 0;
    font-size: 11px;
    color: #94a3b8;
}

#sc-chat-panel .sc-date-divider span {
    background: #f8f9fa;
    padding: 0 10px;
}

/* Welcome message */
#sc-chat-panel .sc-welcome {
    text-align: center;
    padding: 24px 16px;
    color: #64748b;
    font-size: 13px;
}

#sc-chat-panel .sc-welcome-icon {
    font-size: 36px;
    margin-bottom: 8px;
    opacity: 0.4;
}

/* Input area */
#sc-chat-panel .sc-input-area {
    padding: 12px 14px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: #fff;
    flex-shrink: 0;
}

#sc-chat-panel .sc-input-area textarea {
    flex: 1;
    resize: none;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    max-height: 80px;
    min-height: 36px;
    line-height: 1.4;
    transition: border-color 0.2s;
    color: #1e293b;
    background: #fff;
}

#sc-chat-panel .sc-input-area textarea:focus {
    border-color: #5083ff;
}

#sc-chat-panel .sc-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #5083ff;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: background 0.2s;
    flex-shrink: 0;
    padding: 0;
}

#sc-chat-panel .sc-send-btn:hover {
    background: #4275e0;
}

#sc-chat-panel .sc-send-btn:disabled {
    background: #a7a8a9;
    cursor: not-allowed;
}

/* Powered by footer */
#sc-chat-panel .sc-powered {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: #94a3b8;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

#sc-chat-panel .sc-powered a {
    color: #5083ff;
    text-decoration: none;
    font-weight: 600;
}

/* Scrollbar */
#sc-chat-panel .sc-messages::-webkit-scrollbar {
    width: 5px;
}

#sc-chat-panel .sc-messages::-webkit-scrollbar-track {
    background: transparent;
}

#sc-chat-panel .sc-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

/* Typing indicator */
#sc-chat-panel .sc-typing-indicator {
    align-self: flex-start;
    display: flex;
    align-items: center;
    padding: 9px 13px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    max-width: 80%;
}

#sc-chat-panel .sc-typing-dots {
    display: flex;
    gap: 3px;
    align-items: center;
}

#sc-chat-panel .sc-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: sc-typing-bounce 1.4s infinite ease-in-out both;
}

#sc-chat-panel .sc-typing-dot:nth-child(1) { animation-delay: 0s; }
#sc-chat-panel .sc-typing-dot:nth-child(2) { animation-delay: 0.16s; }
#sc-chat-panel .sc-typing-dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes sc-typing-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Conversation closed banner */
#sc-chat-panel .sc-closed-banner {
    text-align: center;
    padding: 20px 16px;
    margin-top: 12px;
}

#sc-chat-panel .sc-closed-banner p {
    margin: 0 0 12px;
    font-size: 13px;
    color: #64748b;
}

#sc-chat-panel .sc-new-chat-btn {
    padding: 8px 20px;
    background: #5083ff;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

#sc-chat-panel .sc-new-chat-btn:hover {
    background: #4275e0;
}

/* Offline modal */
#sc-offline-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 100000;
    align-items: center;
    justify-content: center;
    animation: sc-modal-fade-in 0.2s ease-out;
}

#sc-offline-modal.sc-modal-open {
    display: flex;
}

@keyframes sc-modal-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

#sc-offline-modal .sc-modal-card {
    background: #fff;
    border-radius: 16px;
    width: 380px;
    max-width: 90%;
    padding: 36px 28px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: sc-modal-slide-up 0.25s ease-out;
    position: relative;
}

@keyframes sc-modal-slide-up {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

#sc-offline-modal .sc-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    font-size: 20px;
    color: #94a3b8;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
    line-height: 1;
    padding: 0;
}

#sc-offline-modal .sc-modal-close:hover {
    background: #f1f5f9;
    color: #1e293b;
}

#sc-offline-modal .sc-modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 28px;
}

#sc-offline-modal .sc-modal-card h3 {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
}

#sc-offline-modal .sc-modal-card p {
    margin: 0 0 24px;
    font-size: 14px;
    color: #64748b;
    line-height: 1.6;
}

#sc-offline-modal .sc-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

#sc-offline-modal .sc-modal-btn {
    padding: 10px 22px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#sc-offline-modal .sc-modal-btn-primary {
    background: #5083ff;
    color: #fff;
    box-shadow: 0 2px 8px rgba(80, 131, 255, 0.3);
}

#sc-offline-modal .sc-modal-btn-primary:hover {
    background: #4275e0;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(80, 131, 255, 0.4);
}

#sc-offline-modal .sc-modal-btn-ghost {
    background: transparent;
    color: #64748b;
}

#sc-offline-modal .sc-modal-btn-ghost:hover {
    background: #f1f5f9;
    color: #1e293b;
}

/* Mobile responsive */
@media (max-width: 480px) {
    #sc-chat-panel {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    #sc-chat-launcher {
        bottom: 16px;
        right: 16px;
    }
}
