/**
 * Ferno Chat System Styles
 */

.ferno-chat-element {
    width: 100%;
    max-width: 100%;
}

.ferno-chat-container {
    display: flex;
    flex-direction: column;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Chat Header */
.ferno-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f7f7f7;
    border-bottom: 1px solid #e5e5e5;
}

.ferno-chat-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.ferno-chat-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ferno-chat-online-count {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: #666;
}

/* Messages Area */
.ferno-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ferno-chat-messages::-webkit-scrollbar {
    width: 8px;
}

.ferno-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.ferno-chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.ferno-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Empty State */
.ferno-chat-empty-state,
.ferno-chat-login-notice {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: #999;
}

.ferno-chat-empty-state p,
.ferno-chat-login-notice p {
    margin: 10px 0 0;
    font-size: 14px;
}

.ferno-chat-login-notice a {
    color: #0e73cc;
    text-decoration: none;
    font-weight: 600;
}

.ferno-chat-login-notice a:hover {
    text-decoration: underline;
}

/* Message */
.ferno-chat-message {
    display: flex;
    gap: 10px;
    animation: fadeInUp 0.3s ease;
}

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

.ferno-chat-message.own-message {
    flex-direction: row-reverse;
    align-self: flex-end;
    max-width: 70%;
}

.ferno-chat-message.other-message {
    flex-direction: row;
    align-self: flex-start;
    max-width: 70%;
}

/* Avatar */
.ferno-message-avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}

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

/* Message Content */
.ferno-message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.ferno-message-user {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    padding: 0 12px;
}

.ferno-message-bubble {
    padding: 10px 15px;
    border-radius: 18px;
    word-wrap: break-word;
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.5;
}

/* Bubble styles */
.ferno-chat-messages[data-bubble-style="rounded"] .ferno-message-bubble {
    border-radius: 18px;
}

.ferno-chat-messages[data-bubble-style="square"] .ferno-message-bubble {
    border-radius: 4px;
}

.ferno-chat-messages[data-bubble-style="minimal"] .ferno-message-bubble {
    border-radius: 0;
    border-left: 3px solid currentColor;
}

.own-message .ferno-message-bubble {
    border-bottom-right-radius: 4px;
}

.other-message .ferno-message-bubble {
    border-bottom-left-radius: 4px;
}

.ferno-message-time {
    font-size: 11px;
    color: #999;
    padding: 0 12px;
}

.own-message .ferno-message-time {
    text-align: right;
}

/* Typing Indicator */
.ferno-chat-typing {
    padding: 10px 20px;
    background: #f7f7f7;
    border-top: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #666;
}

.ferno-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.ferno-typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

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

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Area */
.ferno-chat-input-area {
    padding: 15px 20px;
    background: #fff;
    border-top: 1px solid #e5e5e5;
    position: relative;
}

.ferno-chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.ferno-chat-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #e5e5e5;
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 40px;
    max-height: 120px;
    overflow-y: auto;
    transition: border-color 0.2s;
}

.ferno-chat-input:focus {
    outline: none;
    border-color: #0e73cc;
}

.ferno-chat-send-btn {
    flex-shrink: 0;
    padding: 10px 20px;
    background: #0e73cc;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
}

.ferno-chat-send-btn:hover {
    background: #0c5ea8;
}

.ferno-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 640px) {
    .ferno-chat-message.own-message,
    .ferno-chat-message.other-message {
        max-width: 85%;
    }

    .ferno-chat-header {
        padding: 12px 15px;
    }

    .ferno-chat-messages {
        padding: 15px;
    }

    .ferno-chat-input-area {
        padding: 12px 15px;
    }

    .ferno-send-text {
        display: none;
    }
}

/* Emoji Picker */
.ferno-emoji-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border: 1px solid #e5e5e5;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    color: #666;
}

.ferno-emoji-btn:hover {
    background: #e5e5e5;
    color: #333;
}

.ferno-emoji-picker {
    position: absolute;
    bottom: 70px;
    left: 20px;
    width: 320px;
    max-height: 280px;
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    overflow: hidden;
}

.ferno-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    padding: 10px;
    max-height: 260px;
    overflow-y: auto;
}

.ferno-emoji-grid::-webkit-scrollbar {
    width: 6px;
}

.ferno-emoji-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.ferno-emoji-grid::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.ferno-emoji-item {
    font-size: 24px;
    cursor: pointer;
    padding: 6px;
    text-align: center;
    border-radius: 6px;
    transition: background 0.2s;
    line-height: 1;
}

.ferno-emoji-item:hover {
    background: #f5f5f5;
}

/* Nickname Button */
.ferno-nickname-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    padding: 6px 12px !important;
    border-radius: 16px !important;
    color: #333 !important;
}

.ferno-nickname-display {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #333 !important;
    font-weight: 600;
}

.ferno-nickname-display:empty:before {
    content: "Set Nickname";
    color: #666;
    font-weight: 400;
}

/* Responsive for emoji picker */
@media (max-width: 640px) {
    .ferno-emoji-picker {
        left: 10px;
        right: 10px;
        width: auto;
    }

    .ferno-emoji-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* Avatar Selection */
.ferno-avatar-option .ferno-avatar-radio:checked + .ferno-avatar-wrapper {
    border-color: #0e73cc !important;
    box-shadow: 0 0 10px rgba(14, 115, 204, 0.3);
}

.ferno-avatar-option:hover .ferno-avatar-wrapper {
    border-color: #0e73cc;
    transform: scale(1.05);
}
