/* ============================================
   AI Chat Widget - Real Food Kitchen
   ============================================ */

.rfk-chat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #f05a28;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(240, 90, 40, 0.4);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.rfk-chat-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(240, 90, 40, 0.5);
}

.rfk-chat-btn svg {
    width: 26px;
    height: 26px;
    fill: white;
}

.rfk-chat-btn .rfk-chat-btn-close {
    display: none;
}

.rfk-chat-btn.active .rfk-chat-btn-icon {
    display: none;
}

.rfk-chat-btn.active .rfk-chat-btn-close {
    display: block;
}

/* Chat Panel */
.rfk-chat-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 400px;
    height: 560px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'DM Sans', sans-serif;
}

.rfk-chat-panel.active {
    display: flex;
}

/* Header */
.rfk-chat-header {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.rfk-chat-header-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.3rem;
    letter-spacing: 0.5px;
}

.rfk-chat-header-title span {
    color: #f05a28;
}

.rfk-chat-header-actions {
    display: flex;
    gap: 8px;
}

.rfk-chat-header-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    transition: color 0.2s;
}

.rfk-chat-header-btn:hover {
    color: #f05a28;
}

/* Messages */
.rfk-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rfk-chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.rfk-chat-msg-user {
    align-self: flex-end;
    background: #f05a28;
    color: white;
    border-bottom-right-radius: 4px;
}

.rfk-chat-msg-assistant {
    align-self: flex-start;
    background: #f0f0f0;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
}

.rfk-chat-msg-assistant p {
    margin: 0 0 8px 0;
}

.rfk-chat-msg-assistant p:last-child {
    margin-bottom: 0;
}

.rfk-chat-msg-assistant strong {
    font-weight: 600;
}

.rfk-chat-msg-assistant a {
    color: #f05a28;
    text-decoration: underline;
}

.rfk-chat-msg-assistant ul,
.rfk-chat-msg-assistant ol {
    margin: 4px 0;
    padding-left: 20px;
    list-style: disc;
}

.rfk-chat-msg-assistant ol {
    list-style: decimal;
}

.rfk-chat-msg-assistant li {
    margin: 2px 0;
    display: list-item;
}

/* Suggestion buttons */
.rfk-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
    align-self: flex-start;
}

.rfk-chat-suggest-btn {
    background: white;
    border: 1.5px solid #f05a28;
    color: #f05a28;
    border-radius: 20px;
    padding: 7px 14px;
    font-size: 13px;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

.rfk-chat-suggest-btn:hover {
    background: #f05a28;
    color: white;
}

/* Typing indicator */
.rfk-chat-typing {
    align-self: flex-start;
    padding: 12px 16px;
    display: none;
}

.rfk-chat-typing.active {
    display: flex;
}

.rfk-chat-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.rfk-chat-typing-dots span {
    width: 8px;
    height: 8px;
    background: #ccc;
    border-radius: 50%;
    animation: rfk-bounce 1.4s infinite;
}

.rfk-chat-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.rfk-chat-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes rfk-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Thinking indicator */
.rfk-chat-thinking {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #f8f8f8;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    font-size: 13px;
    color: #888;
    animation: rfk-fade-in 0.2s ease;
}

.rfk-chat-thinking-icon {
    display: flex;
    align-items: center;
    color: #f05a28;
    animation: rfk-spin 1.5s linear infinite;
}

@keyframes rfk-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes rfk-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.rfk-chat-thinking-label {
    font-style: italic;
}

.rfk-chat-thinking-dots {
    display: flex;
    gap: 3px;
    align-items: center;
}

.rfk-chat-thinking-dots span {
    width: 4px;
    height: 4px;
    background: #ccc;
    border-radius: 50%;
    animation: rfk-bounce 1.4s infinite;
}

.rfk-chat-thinking-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.rfk-chat-thinking-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Input */
.rfk-chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid #e5e5e5;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    background: #fafafa;
}

.rfk-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: 'DM Sans', sans-serif;
    outline: none;
    resize: none;
    max-height: 100px;
    line-height: 1.4;
}

.rfk-chat-input:focus {
    border-color: #f05a28;
}

.rfk-chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f05a28;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.rfk-chat-send-btn:hover {
    background: #d94d1e;
}

.rfk-chat-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.rfk-chat-send-btn svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* Conversation history sidebar */
.rfk-chat-history {
    display: none;
    flex-direction: column;
    height: 100%;
}

.rfk-chat-history.active {
    display: flex;
}

.rfk-chat-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.rfk-chat-history-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    transition: background 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    display: block;
}

.rfk-chat-history-item:hover {
    background: #f0f0f0;
}

.rfk-chat-history-item-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rfk-chat-history-item-time {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
}

.rfk-chat-history-back {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    color: #f05a28;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    width: 100%;
    text-align: left;
}

/* Welcome screen */
.rfk-chat-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
    color: #666;
}

.rfk-chat-welcome h3 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.5rem;
    color: #1a1a1a;
    margin-bottom: 8px;
}

.rfk-chat-welcome p {
    font-size: 14px;
    margin-bottom: 16px;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .rfk-chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .rfk-chat-btn {
        bottom: 16px;
        right: 16px;
    }
}
