/* Chat by Petar Kordić - Modular Chat Widget Styles */

:root {
    --cbpk-primary: #1f93ff;
    --cbpk-secondary: #ffffff;
    --cbpk-text: #000000;
    --cbpk-button-size: 60px;
    --cbpk-widget-width: 400px;
    --cbpk-widget-height: 600px;
    --cbpk-border-radius: 12px;
    --cbpk-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    --cbpk-shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.24);
}

/* Chat Widget Container */
.cbpk-chat-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.cbpk-chat-widget * {
    box-sizing: border-box;
}

/* Position variants */
.cbpk-chat-widget.cbpk-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.cbpk-chat-widget.cbpk-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Chat Button */
.cbpk-chat-button {
    width: var(--cbpk-button-size);
    height: var(--cbpk-button-size);
    border-radius: 50%;
    background: var(--cbpk-primary);
    border: none;
    cursor: pointer;
    box-shadow: var(--cbpk-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.cbpk-chat-button:hover {
    transform: scale(1.1);
    box-shadow: var(--cbpk-shadow-lg);
}

.cbpk-chat-button:active {
    transform: scale(0.95);
}

.cbpk-chat-button svg {
    width: 24px;
    height: 24px;
    color: #ffffff;
    transition: all 0.2s;
}

.cbpk-chat-icon {
    display: block;
}

.cbpk-close-icon {
    display: none;
}

.cbpk-chat-button.cbpk-active .cbpk-chat-icon {
    display: none;
}

.cbpk-chat-button.cbpk-active .cbpk-close-icon {
    display: block;
}

/* Unread Badge */
.cbpk-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: #ffffff;
    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: cbpkPulse 2s infinite;
}

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

/* Chat Window */
.cbpk-chat-window {
    position: absolute;
    bottom: calc(var(--cbpk-button-size) + 15px);
    width: var(--cbpk-widget-width);
    max-width: calc(100vw - 40px);
    height: var(--cbpk-widget-height);
    max-height: calc(100vh - 100px);
    background: var(--cbpk-secondary);
    border-radius: var(--cbpk-border-radius);
    box-shadow: var(--cbpk-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: cbpkSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Pre-chat Form */
.cbpk-prechat-form {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 30px;
    background: var(--cbpk-secondary);
}

.cbpk-prechat-header {
    margin-bottom: 30px;
}

.cbpk-prechat-header h3 {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 600;
    color: var(--cbpk-text);
}

.cbpk-prechat-header p {
    margin: 0;
    font-size: 14px;
    color: #6b7280;
}

.cbpk-prechat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.cbpk-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cbpk-form-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--cbpk-text);
}

.cbpk-required {
    color: #ef4444;
}

.cbpk-optional {
    font-weight: 400;
    color: #9ca3af;
}

.cbpk-form-group input {
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.cbpk-form-group input:focus {
    border-color: var(--cbpk-primary);
}

.cbpk-form-group input::placeholder {
    color: #9ca3af;
}

.cbpk-prechat-submit {
    margin-top: auto;
    padding: 14px 24px;
    background: var(--cbpk-primary);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.cbpk-prechat-submit:hover {
    background: color-mix(in srgb, var(--cbpk-primary) 85%, black);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(31, 147, 255, 0.3);
}

.cbpk-prechat-submit:active {
    transform: translateY(0);
}

.cbpk-prechat-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.cbpk-prechat-form.cbpk-hidden {
    display: none;
}

@keyframes cbpkSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.cbpk-position-bottom-right .cbpk-chat-window {
    right: 0;
}

.cbpk-position-bottom-left .cbpk-chat-window {
    left: 0;
}

/* Chat Header */
.cbpk-chat-header {
    background: var(--cbpk-primary);
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.cbpk-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.cbpk-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.cbpk-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cbpk-header-avatar svg {
    width: 20px;
    height: 20px;
    color: #ffffff;
}

.cbpk-header-info {
    flex: 1;
}

.cbpk-header-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.cbpk-header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    opacity: 0.9;
}

.cbpk-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    animation: cbpkBlink 2s infinite;
}

@keyframes cbpkBlink {
    0%, 50%, 100% {
        opacity: 1;
    }
    25%, 75% {
        opacity: 0.4;
    }
}

.cbpk-minimize-button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cbpk-minimize-button:hover {
    background: rgba(255, 255, 255, 0.15);
}

.cbpk-minimize-button svg {
    width: 20px;
    height: 20px;
    color: #ffffff;
}

/* Messages Container */
.cbpk-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f9fafb;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 transparent;
}

.cbpk-messages-container::-webkit-scrollbar {
    width: 6px;
}

.cbpk-messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.cbpk-messages-container::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.cbpk-messages-container::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Loading Spinner */
.cbpk-loading-spinner {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.cbpk-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--cbpk-primary);
    border-radius: 50%;
    animation: cbpkSpin 0.8s linear infinite;
}

@keyframes cbpkSpin {
    to {
        transform: rotate(360deg);
    }
}

/* Message Bubble */
.cbpk-message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    animation: cbpkFadeIn 0.3s ease-out;
}

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

.cbpk-message.cbpk-incoming {
    flex-direction: row;
}

.cbpk-message.cbpk-outgoing {
    flex-direction: row-reverse;
}

.cbpk-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--cbpk-primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.cbpk-message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.cbpk-message-content {
    max-width: 70%;
}

.cbpk-message-sender {
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 4px;
}

.cbpk-message.cbpk-outgoing .cbpk-message-sender {
    text-align: right;
}

.cbpk-message-bubble {
    background: #ffffff;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--cbpk-text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    word-wrap: break-word;
}

.cbpk-message.cbpk-incoming .cbpk-message-bubble {
    border-bottom-left-radius: 4px;
}

.cbpk-message.cbpk-outgoing .cbpk-message-bubble {
    background: var(--cbpk-primary);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.cbpk-message-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
}

.cbpk-message.cbpk-outgoing .cbpk-message-time {
    text-align: right;
}

/* Message Attachment */
.cbpk-message-attachment {
    margin-top: 8px;
}

.cbpk-message-attachment img {
    max-width: 200px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.cbpk-message-attachment img:hover {
    transform: scale(1.02);
}

.cbpk-message-attachment a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    font-size: 13px;
}

.cbpk-message-attachment a:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Input Area */
.cbpk-input-area {
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    padding: 12px 16px;
    flex-shrink: 0;
}

.cbpk-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.cbpk-attachment-button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.cbpk-attachment-button:hover {
    background: #f3f4f6;
}

.cbpk-attachment-button svg {
    width: 20px;
    height: 20px;
    color: #6b7280;
}

.cbpk-message-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    max-height: 120px;
}

.cbpk-message-input:focus {
    border-color: var(--cbpk-primary);
    box-shadow: 0 0 0 3px rgba(31, 147, 255, 0.1);
}

.cbpk-send-button {
    background: var(--cbpk-primary);
    border: none;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.cbpk-send-button:hover {
    background: color-mix(in srgb, var(--cbpk-primary) 85%, black);
    transform: translateY(-1px);
}

.cbpk-send-button:active {
    transform: translateY(0);
}

.cbpk-send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cbpk-send-button svg {
    width: 20px;
    height: 20px;
    color: #ffffff;
}

/* File Preview */
.cbpk-file-preview {
    margin-top: 8px;
    padding: 8px 12px;
    background: #f3f4f6;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.cbpk-file-preview-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cbpk-file-preview-remove {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
}

.cbpk-file-preview-remove:hover {
    color: #ef4444;
}

/* Typing Indicator */
.cbpk-typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.cbpk-typing-dots {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #ffffff;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.cbpk-typing-dot {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: cbpkTyping 1.4s infinite;
}

.cbpk-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.cbpk-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes cbpkTyping {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .cbpk-chat-window {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    .cbpk-position-bottom-right .cbpk-chat-window,
    .cbpk-position-bottom-left .cbpk-chat-window {
        right: 0;
        left: 0;
    }
}

/* Footer Credit */
.cbpk-footer-credit {
    padding: 8px 16px;
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.cbpk-footer-credit a {
    color: var(--cbpk-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.cbpk-footer-credit a:hover {
    color: color-mix(in srgb, var(--cbpk-primary) 85%, black);
    text-decoration: underline;
}
