/* SocialChat Pro - Modern Chat Widget */

:root {
    --scp-color: #2271b1;
    --scp-color-light: #e8f4fc;
    --scp-color-dark: #1a5a8a;
    --scp-gray-100: #f8f9fa;
    --scp-gray-200: #e9ecef;
    --scp-gray-300: #dee2e6;
    --scp-gray-500: #6c757d;
    --scp-gray-700: #495057;
    --scp-gray-900: #212529;
    --scp-success: #28a745;
    --scp-warning: #ffc107;
    --scp-danger: #dc3545;
    --scp-shadow: 0 10px 40px rgba(0,0,0,0.15);
    --scp-shadow-sm: 0 2px 8px rgba(0,0,0,0.1);
    --scp-radius: 16px;
    --scp-radius-sm: 8px;
    --scp-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Widget Container */
.scp-chat-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.scp-chat-widget[data-position="bottom-right"] {
    right: 20px;
    bottom: 20px;
}

.scp-chat-widget[data-position="bottom-left"] {
    left: 20px;
    bottom: 20px;
}

/* Chat Launcher Button */
.scp-chat-launcher {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--scp-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--scp-shadow);
    transition: var(--scp-transition);
    position: relative;
}

.scp-chat-launcher:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 50px rgba(0,0,0,0.2);
}

.scp-chat-launcher:active {
    transform: scale(0.95);
}

.scp-chat-launcher svg {
    width: 28px;
    height: 28px;
    color: white;
    transition: var(--scp-transition);
}

.scp-chat-launcher .scp-icon-close {
    position: absolute;
}

.scp-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--scp-danger);
    color: white;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    animation: scp-pulse 2s infinite;
}

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

/* Chat Container */
.scp-chat-container {
    position: absolute;
    bottom: 75px;
    width: 380px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: var(--scp-radius);
    box-shadow: var(--scp-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: scp-slideUp 0.3s ease-out;
}

.scp-chat-widget[data-position="bottom-right"] .scp-chat-container {
    right: 0;
}

.scp-chat-widget[data-position="bottom-left"] .scp-chat-container {
    left: 0;
}

@keyframes scp-slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.scp-chat-header {
    background: linear-gradient(135deg, var(--scp-color), var(--scp-color-dark));
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.scp-header-avatar {
    width: 42px;
    height: 42px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scp-header-avatar svg {
    width: 24px;
    height: 24px;
    color: white;
}

.scp-header-text {
    display: flex;
    flex-direction: column;
}

.scp-header-title {
    color: white;
    font-weight: 600;
    font-size: 15px;
}

.scp-header-status {
    color: rgba(255,255,255,0.85);
    font-size: 12px;
}

.scp-header-status.online::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #4caf50;
    border-radius: 50%;
    margin-right: 6px;
    animation: scp-pulse 2s infinite;
}

.scp-chat-minimize {
    background: rgba(255,255,255,0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--scp-transition);
}

.scp-chat-minimize:hover {
    background: rgba(255,255,255,0.3);
}

.scp-chat-minimize svg {
    width: 18px;
    height: 18px;
    color: white;
}

/* Chat Body */
.scp-chat-body {
    flex: 1;
    min-height: 280px;
    max-height: 350px;
    overflow-y: auto;
    padding: 16px;
    background: var(--scp-gray-100);
    scroll-behavior: smooth;
}

.scp-chat-body::-webkit-scrollbar {
    width: 6px;
}

.scp-chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.scp-chat-body::-webkit-scrollbar-thumb {
    background: var(--scp-gray-300);
    border-radius: 3px;
}

/* Messages */
.scp-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.scp-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: scp-fadeIn 0.3s ease-out;
}

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

.scp-message-bubble {
    padding: 12px 16px;
    border-radius: var(--scp-radius-sm);
    word-wrap: break-word;
    position: relative;
}

.scp-message-time {
    font-size: 10px;
    color: var(--scp-gray-500);
    margin-top: 4px;
}

/* User Message */
.scp-message-user {
    align-self: flex-end;
}

.scp-message-user .scp-message-bubble {
    background: var(--scp-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.scp-message-user .scp-message-time {
    text-align: right;
}

/* Optimistic Message (sending) */
.scp-message-optimistic .scp-message-bubble {
    opacity: 0.7;
}

/* Failed Message */
.scp-message-failed .scp-message-bubble {
    background: #fee2e2 !important;
    color: #991b1b !important;
    border: 1px solid #fecaca;
}

.scp-message-failed .scp-message-bubble::after {
    content: " ⚠";
}

/* Bot Message */
.scp-message-bot {
    align-self: flex-start;
}

.scp-message-bot .scp-message-bubble {
    background: white;
    color: var(--scp-gray-900);
    border-bottom-left-radius: 4px;
    box-shadow: var(--scp-shadow-sm);
}

/* Agent Message */
.scp-message-agent {
    align-self: flex-start;
}

.scp-message-agent .scp-message-bubble {
    background: white;
    color: var(--scp-gray-900);
    border-bottom-left-radius: 4px;
    box-shadow: var(--scp-shadow-sm);
    border-left: 3px solid var(--scp-success);
}

.scp-message-agent .scp-agent-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--scp-success);
    margin-bottom: 4px;
}

/* System Message */
.scp-message-system {
    align-self: center;
    max-width: 90%;
}

.scp-message-system .scp-message-bubble {
    background: var(--scp-gray-200);
    color: var(--scp-gray-700);
    font-size: 12px;
    font-style: italic;
    text-align: center;
    padding: 8px 16px;
}

/* Typing Indicator */
.scp-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: var(--scp-radius-sm);
    width: fit-content;
    box-shadow: var(--scp-shadow-sm);
    margin-top: 8px;
}

.scp-typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--scp-gray-400);
    border-radius: 50%;
    animation: scp-typing 1.4s infinite ease-in-out;
}

.scp-typing-indicator span:nth-child(1) { animation-delay: 0s; }
.scp-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.scp-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes scp-typing {
    0%, 60%, 100% { transform: translateY(0); background: var(--scp-gray-400); }
    30% { transform: translateY(-8px); background: var(--scp-color); }
}

/* Pre-chat Form */
.scp-pre-chat-form {
    padding: 20px;
    background: white;
}

.scp-form-intro {
    color: var(--scp-gray-700);
    margin-bottom: 16px;
    font-size: 13px;
}

.scp-form-field {
    margin-bottom: 12px;
}

.scp-form-field input,
.scp-form-field select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--scp-gray-300);
    border-radius: var(--scp-radius-sm);
    font-size: 14px;
    transition: var(--scp-transition);
    background: white;
}

.scp-form-field input:focus,
.scp-form-field select:focus {
    outline: none;
    border-color: var(--scp-color);
    box-shadow: 0 0 0 3px var(--scp-color-light);
}

.scp-start-chat-btn {
    width: 100%;
    padding: 14px;
    background: var(--scp-color);
    color: white;
    border: none;
    border-radius: var(--scp-radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--scp-transition);
    margin-top: 8px;
}

.scp-start-chat-btn:hover {
    background: var(--scp-color-dark);
}

.scp-start-chat-btn:active {
    transform: scale(0.98);
}

/* Chat Input Area */
.scp-chat-input-area {
    background: white;
    border-top: 1px solid var(--scp-gray-200);
    padding: 12px 16px;
}

.scp-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.scp-chat-input {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid var(--scp-gray-300);
    border-radius: 20px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    transition: var(--scp-transition);
    font-family: inherit;
}

.scp-chat-input:focus {
    outline: none;
    border-color: var(--scp-color);
}

.scp-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--scp-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--scp-transition);
    flex-shrink: 0;
}

.scp-send-btn:hover {
    background: var(--scp-color-dark);
}

.scp-send-btn:active {
    transform: scale(0.95);
}

.scp-send-btn svg {
    width: 20px;
    height: 20px;
    color: white;
}

.scp-input-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--scp-gray-100);
}

.scp-request-agent,
.scp-end-chat {
    background: none;
    border: none;
    color: var(--scp-gray-500);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: var(--scp-radius-sm);
    transition: var(--scp-transition);
}

.scp-request-agent:hover {
    color: var(--scp-color);
    background: var(--scp-color-light);
}

.scp-request-agent svg {
    width: 16px;
    height: 16px;
}

.scp-end-chat:hover {
    color: var(--scp-danger);
    background: #fde8ea;
}

/* Rating */
.scp-chat-rating {
    padding: 24px 20px;
    background: white;
    text-align: center;
    animation: scp-fadeIn 0.3s ease-out;
}

.scp-chat-rating p {
    color: var(--scp-gray-700);
    margin-bottom: 16px;
    font-weight: 500;
}

.scp-rating-stars {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}

.scp-rating-stars button {
    background: none;
    border: none;
    font-size: 32px;
    color: var(--scp-gray-300);
    cursor: pointer;
    transition: var(--scp-transition);
    padding: 0;
}

.scp-rating-stars button:hover,
.scp-rating-stars button.active {
    color: var(--scp-warning);
    transform: scale(1.2);
}

.scp-rating-comment {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--scp-gray-300);
    border-radius: var(--scp-radius-sm);
    resize: none;
    font-family: inherit;
    font-size: 13px;
    margin-bottom: 12px;
}

.scp-rating-comment:focus {
    outline: none;
    border-color: var(--scp-color);
}

.scp-submit-rating {
    width: 100%;
    padding: 12px;
    background: var(--scp-color);
    color: white;
    border: none;
    border-radius: var(--scp-radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--scp-transition);
}

.scp-submit-rating:hover {
    background: var(--scp-color-dark);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .scp-chat-widget {
        right: 10px !important;
        left: 10px !important;
        bottom: 10px;
    }

    .scp-chat-container {
        width: calc(100vw - 20px);
        max-height: calc(100vh - 80px);
        bottom: 70px;
        right: 0 !important;
        left: 0 !important;
    }

    .scp-chat-launcher {
        width: 54px;
        height: 54px;
    }
}

/* Links in messages */
.scp-message-bubble a {
    color: inherit;
    text-decoration: underline;
}

.scp-message-user .scp-message-bubble a {
    color: white;
}

/* Markdown-like formatting */
.scp-message-bubble strong {
    font-weight: 600;
}

.scp-message-bubble em {
    font-style: italic;
}

/* Powered by */
.scp-powered-by {
    text-align: center;
    padding: 8px;
    font-size: 10px;
    color: var(--scp-gray-500);
    background: var(--scp-gray-100);
}

.scp-powered-by a {
    color: var(--scp-gray-600);
    text-decoration: none;
}

/* Loading state */
.scp-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.scp-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--scp-gray-200);
    border-top-color: var(--scp-color);
    border-radius: 50%;
    animation: scp-spin 0.8s linear infinite;
}

@keyframes scp-spin {
    to { transform: rotate(360deg); }
}
