/* Hikayat Hang Tuah Chatbot - Improved Stylesheet */

:root {
    --primary-color: #FF6D1F;
    --secondary-color: #F5E7C6;
    --bg-color: #FAF3E1;
    --chat-bg: #ffffff;
    --user-msg-bg: #FF6D1F;
    --bot-msg-bg: #FAF3E1;
    --text-dark: #222222;
    --text-light: #666666;
    --border-color: #F5E7C6;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --cinta-color: #FF6D1F;
    --wanita-color: #F5E7C6;
    --politik-color: #222222;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #222222 0%, #FF6D1F 100%);
    display: flex;
    flex-direction: column;
}

/* Header - Fixed at top */
.chat-header {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    padding: 12px 0;
    box-shadow: var(--shadow);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 70px;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 22px;
}

.logo-text h1 {
    font-size: 1.3rem;
    color: var(--text-dark);
    font-weight: 700;
}

.logo-text p {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Main Container - Full height minus header */
.main-container {
    flex: 1;
    /* padding-top: 70px; */
    height: 100vh;
    overflow: hidden;
}

.main-container > .container {
    height: 100%;
    padding-top: 15px;
    padding-bottom: 15px;
}

.chat-wrapper {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 15px;
    height: 100%;
}

/* Chat Area - Fixed height with flex layout */
.chat-area {
    background: var(--chat-bg);
    border-radius: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

/* Chat Messages - Scrollable area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0; /* Important for flex scroll */
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: fadeInUp 0.3s ease;
}

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

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.bot {
    align-self: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.message.user .message-avatar {
    background: var(--user-msg-bg);
    color: white;
}

.message.bot .message-avatar {
    background: linear-gradient(135deg, #FF6D1F, #F5E7C6);
    color: white;
}

.message-content {
    padding: 10px 15px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 0.95rem;
}

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

.message.bot .message-content {
    background: var(--bot-msg-bg);
    color: var(--text-dark);
    border-bottom-left-radius: 4px;
}

/* Bot Answer Card - Enhanced */
.bot-answer {
    background: white !important;
    border: 1px solid var(--border-color);
    padding: 15px !important;
    border-radius: 12px !important;
    max-width: 100%;
}

.answer-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.answer-category {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.75rem;
    color: white;
    font-weight: 500;
}

.answer-subcategory {
    font-size: 0.8rem;
    color: var(--text-light);
    background: #f0f0f0;
    padding: 3px 10px;
    border-radius: 10px;
}

.answer-question {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
    font-size: 0.95rem;
}

.answer-section {
    margin-bottom: 12px;
}

.answer-section-title {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.85rem;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.answer-section-title i {
    color: var(--primary-color);
}

.answer-text {
    color: var(--text-dark);
    font-size: 0.9rem;
    line-height: 1.6;
}

.answer-huraian {
    background: #f8f9fa;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.88rem;
    color: #555;
    border-left: 3px solid var(--secondary-color);
}

/* Petikan (Quote) Styling */
.petikan-box {
    background: linear-gradient(135deg, #FAF3E1 0%, #F5E7C6 100%);
    padding: 12px 15px;
    border-radius: 8px;
    margin-top: 8px;
    position: relative;
}

.petikan-box::before {
    content: '"';
    font-size: 2.5rem;
    color: rgba(0,0,0,0.1);
    position: absolute;
    top: 0;
    left: 10px;
    font-family: Georgia, serif;
}

.petikan-text {
    font-style: italic;
    color: #222222;
    font-size: 0.88rem;
    line-height: 1.5;
    padding-left: 20px;
}

.petikan-source {
    text-align: right;
    font-size: 0.75rem;
    color: #222222;
    margin-top: 8px;
    font-weight: 500;
}

.petikan-mhs {
    background: linear-gradient(135deg, #FAF3E1 0%, #FF6D1F 100%);
}

.petikan-mhs .petikan-text {
    color: #222222;
}

.petikan-mhs .petikan-source {
    color: #222222;
}

/* Related Questions */
.related-questions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border-color);
}

.related-questions h6 {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 8px;
}

.related-question-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    margin-bottom: 5px;
    background: #f8f9fa;
    border: none;
    border-radius: 6px;
    color: var(--text-dark);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.related-question-btn:hover {
    background: var(--secondary-color);
    color: white;
}

/* Suggestion Buttons */
.suggestion-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.suggestion-btn {
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    font-size: 0.8rem;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Chat Input - FIXED at bottom */
.chat-input-area {
    padding: 12px 15px;
    background: white;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0; /* Prevent shrinking */
}

/* Category Filter - Above Input */
.category-filter {
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.filter-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.filter-label i {
    color: var(--primary-color);
}

.filter-toggle-btn {
    display: none; /* Hidden by default, only show on mobile */
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-dark);
}

.filter-toggle-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.filter-toggle-btn i {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.filter-btn {
    padding: 6px 14px;
    border: 2px solid var(--border-color);
    border-radius: 20px;
    background: white;
    color: var(--text-dark);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.filter-btn i {
    font-size: 0.9rem;
}

.filter-btn:hover {
    background: var(--bg-color);
    transform: translateY(-2px);
}

.filter-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.filter-btn.active:hover {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid var(--border-color);
    border-radius: 25px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.chat-input:focus {
    border-color: var(--primary-color);
}

.chat-input::placeholder {
    color: #aaa;
}

.send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    height: 100%;
}

.sidebar-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 12px 15px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.sidebar-header h5 {
    font-size: 0.9rem;
    margin: 0;
}

.sidebar-body {
    padding: 12px;
}

/* Category Buttons */
.category-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 6px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.category-btn:hover {
    transform: translateX(3px);
    background: #f0f0f0;
}

.category-btn.active {
    border-color: var(--primary-color);
    background: white;
}

.category-btn i {
    font-size: 1rem;
}

.category-btn .category-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-dark);
    font-size: 0.85rem;
}

.category-btn .category-count {
    font-size: 0.7rem;
    background: var(--border-color);
    padding: 2px 6px;
    border-radius: 8px;
    color: var(--text-light);
}

/* Category Colors */
.category-cinta { color: var(--cinta-color); }
.category-wanita { color: var(--wanita-color); }
.category-politik { color: var(--politik-color); }

.bg-cinta { background-color: var(--cinta-color) !important; }
.bg-wanita { background-color: var(--wanita-color) !important; }
.bg-politik { background-color: var(--politik-color) !important; }

/* Popular Questions */
.popular-question {
    padding: 8px 10px;
    margin-bottom: 6px;
    background: #f8f9fa;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8rem;
}

.popular-question:hover {
    background: var(--secondary-color);
    color: white;
}

.popular-question .question-category {
    display: inline-block;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 8px;
    color: white;
    margin-bottom: 4px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-light);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

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

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 30px 20px;
}

.welcome-icon {
    width: 120px;
    height: 120px;
    margin: 0 auto 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    padding: 15px;
}

.welcome-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.welcome-message h3 {
    color: var(--text-dark);
    margin-bottom: 8px;
    font-size: 1.2rem;
}

.welcome-message p {
    color: var(--text-light);
    margin-bottom: 15px;
    font-size: 0.9rem;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.quick-action-btn {
    padding: 8px 15px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.quick-action-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
    width: 5px;
}

.chat-messages::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 3px;
}

/* Responsive */
@media (max-width: 992px) {
    .chat-wrapper {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
    }
    
    .chat-area {
        min-height: 50vh;
    }
    
    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        height: auto;
        max-height: 200px;
    }
    
    .sidebar-card {
        flex: 1;
        min-width: 200px;
    }
}

@media (max-width: 576px) {
    .chat-header {
        height: 60px;
        padding: 8px 0;
    }

    .main-container {
        padding-top: 60px;
    }

    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 5px;
    }

    .logo-section {
        gap: 8px;
    }

    .logo-icon {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }

    .logo-text h1 {
        font-size: 1rem;
    }

    .logo-text p {
        display: none;
    }

    .message {
        max-width: 95%;
    }

    .chat-input-area {
        padding: 10px;
    }

    .category-filter {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        padding-bottom: 8px;
        margin-bottom: 8px;
    }

    .filter-label {
        font-size: 0.75rem;
    }

    .filter-label i {
        font-size: 0.8rem;
    }

    /* Show toggle button on mobile */
    .filter-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .filter-buttons {
        width: 100%;
    }

    .filter-btn {
        padding: 4px 10px;
        font-size: 0.75rem;
    }

    .filter-btn i {
        font-size: 0.75rem;
    }

    .chat-input {
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    .send-btn {
        width: 42px;
        height: 42px;
        font-size: 0.95rem;
    }

    .sidebar {
        display: none;
    }
}

/* Questions Cards Wrapper - Full Width Container */
.questions-cards-wrapper {
    width: 100%;
    margin: 20px 0;
    animation: fadeIn 0.5s ease;
}

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

/* Section Header */
.cards-section-header {
    background: white;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    margin-bottom: 25px;
}

.cards-header-content {
    display: flex;
    align-items: center;
    gap: 20px;
}

.cards-header-content h4 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-dark);
}

.cards-header-content p {
    margin: 5px 0 0 0;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Card Columns Layout (Bootstrap-like) */
.card-columns {
    column-count: 3;
    column-gap: 20px;
}

/* Topic Cards */
.topic-card {
    display: inline-block;
    width: 100%;
    margin-bottom: 20px;
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    break-inside: avoid;
    page-break-inside: avoid;
}

.topic-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0,0,0,0.25);
}

.topic-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.3);
}

.topic-card-header i {
    font-size: 1.5rem;
    opacity: 0.9;
}

.topic-card-category {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.topic-card-body {
    margin-bottom: 15px;
}

.topic-card-body p {
    margin: 0;
    font-size: 1rem;
    line-height: 1.6;
    font-weight: 500;
}

.topic-card-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.topic-card:hover .topic-card-footer {
    opacity: 1;
}

.topic-card-footer i {
    font-size: 1.2rem;
}

/* Responsive Card Columns */
@media (max-width: 992px) {
    .card-columns {
        column-count: 2;
    }
}

@media (max-width: 768px) {
    .card-columns {
        column-count: 1;
    }

    .cards-section-header {
        padding: 12px 15px;
    }

    .cards-header-content {
        gap: 12px;
    }

    .cards-header-content i {
        font-size: 1.3rem !important;
    }

    .cards-header-content h4 {
        font-size: 1.1rem;
    }

    .cards-header-content p {
        font-size: 0.8rem;
    }

    .topic-card {
        padding: 12px;
        margin-bottom: 12px;
    }

    .topic-card-header i {
        font-size: 1.2rem;
    }

    .topic-card-category {
        font-size: 0.7rem;
    }

    .topic-card-body p {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    .topic-card-footer {
        font-size: 0.8rem;
    }

    .topic-card-footer i {
        font-size: 1rem;
    }
}

/* Extra small phones (< 576px) - Further minimize */
@media (max-width: 576px) {
    .cards-section-header {
        padding: 10px;
    }

    .cards-header-content {
        gap: 10px;
    }

    .cards-header-content i {
        font-size: 1.1rem !important;
    }

    .cards-header-content h4 {
        font-size: 0.95rem;
    }

    .cards-header-content p {
        font-size: 0.75rem;
    }

    .topic-card {
        padding: 10px;
        margin-bottom: 10px;
        border-radius: 12px;
    }

    .topic-card-header {
        margin-bottom: 10px;
        padding-bottom: 8px;
    }

    .topic-card-header i {
        font-size: 1rem;
    }

    .topic-card-category {
        font-size: 0.65rem;
    }

    .topic-card-body {
        margin-bottom: 10px;
    }

    .topic-card-body p {
        font-size: 0.85rem;
        line-height: 1.4;
    }

    .topic-card-footer {
        font-size: 0.75rem;
    }

    .topic-card-footer i {
        font-size: 0.9rem;
    }
}

/* Print styles */
@media print {
    .chat-header, .sidebar, .chat-input-area {
        display: none;
    }

    .chat-messages {
        overflow: visible;
        height: auto;
    }
}
