/**
 * SmartChat AI Widget Styles
 */

/* ── Reset & Container ──────────────────────────────── */

#smartchat-container,
#smartchat-container * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

#smartchat-container {
    position: fixed;
    bottom: 20px;
    z-index: 999999;
}

#smartchat-container.smartchat-pos-right {
    right: 20px;
}

#smartchat-container.smartchat-pos-left {
    left: 20px;
}

/* ── Chat Bubble Button ──────────────────────────────── */

#smartchat-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--smartchat-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16), 0 2px 4px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

#smartchat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}

#smartchat-bubble:active {
    transform: scale(0.96);
}

#smartchat-unread {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: smartchat-pulse 2s ease-in-out infinite;
}

@keyframes smartchat-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

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

#smartchat-panel {
    position: absolute;
    bottom: 76px;
    width: 380px;
    max-height: 560px;
    height: 560px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.smartchat-pos-right #smartchat-panel {
    right: 0;
}

.smartchat-pos-left #smartchat-panel {
    left: 0;
}

#smartchat-panel.smartchat-hidden {
    opacity: 0;
    transform: translateY(12px) scale(0.95);
    pointer-events: none;
}

#smartchat-panel.smartchat-open {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ── Header ──────────────────────────────────────────── */

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

.smartchat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.smartchat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.smartchat-header-name {
    font-weight: 600;
    font-size: 15px;
}

.smartchat-header-status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}

.smartchat-header-status::before {
    content: '';
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
}

#smartchat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s;
    padding: 0 4px;
    line-height: 1;
}

#smartchat-close:hover {
    opacity: 1;
}

/* ── Messages Area ───────────────────────────────────── */

#smartchat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    background: #f8f9fb;
}

/* Scrollbar */
#smartchat-messages::-webkit-scrollbar {
    width: 5px;
}

#smartchat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#smartchat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

/* ── Message Bubbles ─────────────────────────────────── */

.smartchat-msg {
    display: flex;
    max-width: 85%;
    animation: smartchat-fadeIn 0.25s ease;
}

@keyframes smartchat-fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.smartchat-msg-bot {
    align-self: flex-start;
}

.smartchat-msg-user {
    align-self: flex-end;
}

.smartchat-bubble-msg {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.smartchat-bubble-bot {
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.smartchat-bubble-user {
    background: var(--smartchat-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.smartchat-bubble-msg a {
    color: inherit;
    text-decoration: underline;
}

.smartchat-bubble-bot a {
    color: var(--smartchat-primary);
}

/* ── Phone CTA Button ────────────────────────────────── */

.smartchat-phone-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: #16a34a;
    color: #fff !important;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none !important;
    transition: background 0.2s;
}

.smartchat-phone-btn:hover {
    background: #15803d;
}

/* ── Typing Indicator ────────────────────────────────── */

#smartchat-typing {
    padding: 0 16px 8px;
    background: #f8f9fb;
}

.smartchat-typing-dots {
    display: inline-flex;
    gap: 4px;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.smartchat-typing-dots span {
    width: 7px;
    height: 7px;
    background: #9ca3af;
    border-radius: 50%;
    animation: smartchat-bounce 1.4s ease-in-out infinite;
}

.smartchat-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.smartchat-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* ── Input Area ──────────────────────────────────────── */

#smartchat-input-area {
    padding: 12px 14px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #fff;
}

#smartchat-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    outline: none;
    max-height: 100px;
    background: #f9fafb;
    transition: border-color 0.15s, background 0.15s;
    font-family: inherit;
}

#smartchat-input:focus {
    border-color: var(--smartchat-primary);
    background: #fff;
}

#smartchat-input::placeholder {
    color: #9ca3af;
}

#smartchat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--smartchat-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, opacity 0.15s;
}

#smartchat-send:hover {
    background: var(--smartchat-primary-dark);
}

#smartchat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

#smartchat-powered {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    padding: 6px;
    background: #fff;
    border-top: 1px solid #f3f4f6;
}

/* ── Utility ─────────────────────────────────────────── */

.smartchat-hidden {
    display: none !important;
}

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

@media (max-width: 480px) {
    #smartchat-container {
        bottom: 12px;
        right: 12px !important;
        left: 12px !important;
    }

    #smartchat-panel {
        width: calc(100vw - 24px);
        height: calc(100vh - 120px);
        max-height: calc(100vh - 120px);
        bottom: 70px;
        right: 0 !important;
        left: 0 !important;
        border-radius: 12px;
    }

    #smartchat-bubble {
        width: 54px;
        height: 54px;
    }

    .smartchat-pos-right #smartchat-container,
    .smartchat-pos-left #smartchat-container {
        right: 12px;
    }
}
