/* ============================================================
   TômSoft AI Chatbot - Style chuyên ngành Thủy sản - Nông nghiệp
   ============================================================ */

/* ===== CHAT TOGGLE BUTTON ===== */
.chat-toggle-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999;
    background: linear-gradient(135deg, #1a7a3a, #0f5729);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 14px 24px;
    font-weight: 700;
    font-size: 15px;
    box-shadow: 0 4px 25px rgba(26, 122, 58, 0.45);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Be Vietnam Pro', -apple-system, sans-serif;
    letter-spacing: 0.3px;
}
.chat-toggle-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 35px rgba(26, 122, 58, 0.55);
}
.chat-toggle-btn:active {
    transform: scale(0.95);
}
.chat-toggle-btn .btn-icon {
    font-size: 20px;
}
.chat-toggle-btn .label-text {
    font-size: 14px;
}
.chat-toggle-btn .badge-online {
    background: #28a745;
    color: white;
    font-size: 8px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: pulse-badge 2s infinite;
}
@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== CHAT BOX ===== */
.chat-box {
    position: fixed;
    bottom: 100px;
    right: 30px;
    z-index: 998;
    width: 420px;
    max-width: calc(100vw - 60px);
    max-height: 650px;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(26, 122, 58, 0.15);
    font-family: 'Be Vietnam Pro', -apple-system, sans-serif;
    animation: slideUp 0.3s ease;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== CHAT HEADER ===== */
.chat-header {
    background: linear-gradient(135deg, #1a7a3a, #0f5729);
    padding: 14px 18px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}
.chat-header .title {
    font-weight: 700;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.chat-header .title .status-dot {
    width: 10px;
    height: 10px;
    background: #28a745;
    border-radius: 50%;
    display: inline-block;
    animation: pulse-dot 1.5s infinite;
    border: 2px solid rgba(255, 255, 255, 0.3);
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}
.chat-header .title .brand-icon {
    font-size: 18px;
}
.chat-header .title .brand-name {
    font-weight: 800;
}
.chat-header .title .badge-specialist {
    background: #f59e0b;
    color: #1a202c;
    font-size: 8px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 4px;
}
.chat-header .title .status-text {
    font-size: 10px;
    font-weight: 400;
    opacity: 0.8;
    margin-left: 4px;
}
.chat-header .close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

/* ===== MESSAGES CONTAINER ===== */
.chat-messages {
    flex: 1;
    padding: 16px 16px 8px;
    overflow-y: auto;
    background: #f8faf7;
    min-height: 320px;
    max-height: 420px;
    scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar {
    width: 5px;
}
.chat-messages::-webkit-scrollbar-track {
    background: #e8ede8;
    border-radius: 10px;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: #1a7a3a;
    border-radius: 10px;
}

/* ===== MESSAGE ITEMS ===== */
.chat-messages .message {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    animation: fadeInUp 0.3s ease;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.chat-messages .message.user {
    flex-direction: row-reverse;
}
.chat-messages .message-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.chat-messages .message.user .message-avatar {
    background: linear-gradient(135deg, #6c5ce7, #5a4bd1);
    color: white;
}
.chat-messages .message.assistant .message-avatar {
    background: linear-gradient(135deg, #1a7a3a, #0f5729);
    color: white;
}
.chat-messages .message-bubble {
    max-width: 78%;
    padding: 10px 16px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.6;
    word-wrap: break-word;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.chat-messages .message.user .message-bubble {
    background: linear-gradient(135deg, #6c5ce7, #5a4bd1);
    color: white;
    border-bottom-right-radius: 4px;
}
.chat-messages .message.assistant .message-bubble {
    background: #ffffff;
    color: #1a202c;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}
.chat-messages .message.assistant .message-bubble strong {
    color: #1a7a3a;
}
.chat-messages .message.assistant .message-bubble a {
    color: #1a7a3a;
    text-decoration: underline;
}

/* ===== TYPING ANIMATION ===== */
.chat-messages .typing .message-bubble {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 60px;
}
.chat-messages .typing .dot {
    width: 8px;
    height: 8px;
    background: #1a7a3a;
    border-radius: 50%;
    display: inline-block;
    animation: typing-bounce 1.4s infinite;
}
.chat-messages .typing .dot:nth-child(2) { animation-delay: 0.2s; }
.chat-messages .typing .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* ===== TOPIC SUGGESTIONS ===== */
.topic-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px 12px;
    background: #f1f5ef;
    border-top: 1px solid #e2e8e0;
    flex-shrink: 0;
}
.topic-suggestions .chip {
    background: white;
    border: 1px solid #d5dbe5;
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #1a202c;
    font-family: 'Be Vietnam Pro', -apple-system, sans-serif;
    white-space: nowrap;
}
.topic-suggestions .chip:hover {
    background: #1a7a3a;
    color: white;
    border-color: #1a7a3a;
    transform: translateY(-1px);
    box-shadow: 0 2px 10px rgba(26, 122, 58, 0.2);
}
.topic-suggestions .chip:active {
    transform: scale(0.95);
}
.topic-suggestions .chip .chip-icon {
    margin-right: 4px;
}

/* ===== INPUT AREA ===== */
.chat-input-area {
    display: flex;
    gap: 6px;
    padding: 10px 12px 12px;
    background: white;
    border-top: 1px solid #e2e8f0;
    align-items: flex-end;
    flex-shrink: 0;
}
.chat-input-area textarea {
    flex: 1;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 8px 14px;
    resize: none;
    font-family: 'Be Vietnam Pro', -apple-system, sans-serif;
    font-size: 13px;
    max-height: 80px;
    min-height: 38px;
    outline: none;
    transition: all 0.2s;
    line-height: 1.5;
    background: #fafcfa;
}
.chat-input-area textarea:focus {
    border-color: #1a7a3a;
    box-shadow: 0 0 0 3px rgba(26, 122, 58, 0.12);
    background: white;
}
.chat-input-area textarea::placeholder {
    color: #a0aec0;
}
.chat-input-area .btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: #f1f5ef;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}
.chat-input-area .btn-icon:hover {
    background: #e2e8e0;
    transform: translateY(-1px);
}
.chat-input-area .btn-icon:active {
    transform: scale(0.92);
}
.chat-input-area .btn-send {
    background: linear-gradient(135deg, #1a7a3a, #0f5729);
    color: white;
}
.chat-input-area .btn-send:hover {
    background: linear-gradient(135deg, #0f5729, #0a401e);
    box-shadow: 0 2px 15px rgba(26, 122, 58, 0.3);
}
.chat-input-area .btn-upload {
    position: relative;
    overflow: hidden;
}
.chat-input-area .btn-upload input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.chat-input-area .btn-voice.recording {
    background: #dc3545;
    color: white;
    animation: pulse-recording 1.2s infinite;
}
@keyframes pulse-recording {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
    50% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(220, 53, 69, 0); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .chat-box {
        bottom: 85px;
        right: 15px;
        width: calc(100vw - 30px);
        max-height: 550px;
        border-radius: 16px;
    }
    .chat-messages {
        max-height: 340px;
        min-height: 240px;
        padding: 12px 14px 6px;
    }
    .chat-messages .message-bubble {
        font-size: 13px;
        padding: 8px 14px;
    }
    .chat-toggle-btn {
        bottom: 20px;
        right: 15px;
        padding: 12px 18px;
        font-size: 13px;
        border-radius: 40px;
    }
    .chat-toggle-btn .label-text {
        font-size: 12px;
    }
    .chat-toggle-btn .btn-icon {
        font-size: 17px;
    }
    .chat-header {
        padding: 12px 14px;
    }
    .chat-header .title {
        font-size: 13px;
    }
    .chat-input-area {
        padding: 8px 10px 10px;
        gap: 5px;
    }
    .chat-input-area .btn-icon {
        width: 34px;
        height: 34px;
        font-size: 13px;
    }
    .chat-input-area textarea {
        font-size: 12px;
        padding: 6px 12px;
        min-height: 34px;
    }
    .topic-suggestions {
        padding: 6px 10px 10px;
        gap: 4px;
    }
    .topic-suggestions .chip {
        font-size: 10px;
        padding: 4px 10px;
    }
}

@media (max-width: 480px) {
    .chat-box {
        bottom: 75px;
        right: 10px;
        width: calc(100vw - 20px);
        max-height: 480px;
        border-radius: 14px;
    }
    .chat-messages {
        max-height: 280px;
        min-height: 180px;
        padding: 10px 12px 4px;
    }
    .chat-messages .message {
        gap: 6px;
        margin-bottom: 8px;
    }
    .chat-messages .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }
    .chat-messages .message-bubble {
        font-size: 12px;
        padding: 6px 12px;
        border-radius: 12px;
    }
    .chat-toggle-btn {
        bottom: 15px;
        right: 10px;
        padding: 10px 14px;
        font-size: 11px;
        border-radius: 30px;
    }
    .chat-toggle-btn .label-text {
        display: none;
    }
    .chat-toggle-btn .btn-icon {
        font-size: 16px;
    }
    .chat-toggle-btn .badge-online {
        font-size: 7px;
        padding: 1px 6px;
    }
    .chat-header .title .badge-specialist {
        display: none;
    }
    .chat-input-area textarea {
        font-size: 12px;
        padding: 5px 10px;
        min-height: 30px;
    }
    .chat-input-area .btn-icon {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
    .topic-suggestions .chip {
        font-size: 9px;
        padding: 3px 8px;
    }
}

/* ===== DARK MODE SUPPORT (Optional) ===== */
@media (prefers-color-scheme: dark) {
    .chat-box {
        background: #1a202c;
        border-color: rgba(26, 122, 58, 0.3);
    }
    .chat-messages {
        background: #1a202c;
    }
    .chat-messages .message.assistant .message-bubble {
        background: #2d3748;
        color: #e2e8f0;
        border-color: #4a5568;
    }
    .chat-messages .message.assistant .message-bubble strong {
        color: #68d391;
    }
    .chat-input-area {
        background: #1a202c;
        border-color: #2d3748;
    }
    .chat-input-area textarea {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    .chat-input-area textarea:focus {
        border-color: #1a7a3a;
        box-shadow: 0 0 0 3px rgba(26, 122, 58, 0.2);
        background: #2d3748;
    }
    .chat-input-area textarea::placeholder {
        color: #718096;
    }
    .chat-input-area .btn-icon {
        background: #2d3748;
        color: #a0aec0;
    }
    .chat-input-area .btn-icon:hover {
        background: #4a5568;
    }
    .topic-suggestions {
        background: #1a202c;
        border-color: #2d3748;
    }
    .topic-suggestions .chip {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    .topic-suggestions .chip:hover {
        background: #1a7a3a;
        border-color: #1a7a3a;
    }
    .chat-header .title .badge-specialist {
        background: #f59e0b;
        color: #1a202c;
    }
}