* {
    font-family: 'Google Sans', sans-serif;
}

body {
    background: linear-gradient(135deg, #dbdbdb 0%, #c7e0fd 100%);
    min-height: 100vh;
    padding: 15px;
}

/* Responsive Container */
.faq-container {
    max-width: 90%;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header Responsive */
.header {
    background: linear-gradient(135deg, #3f5ee9, #04067e);
    color: white;
    padding: 30px 20px;
    text-align: center;
}

.header i {
    font-size: 50px;
}

.header h2 {
    margin: 15px 0 10px;
    font-weight: 600;
    font-size: 1.8rem;
}

.header p {
    font-size: 1rem;
    margin-bottom: 0;
}

/* Search Area Responsive */
.search-area {
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.input-group {
    flex-wrap: nowrap;
}

.input-group-text {
    padding: 0.75rem 1rem;
}

#searchInput {
    font-size: 16px;
    /* ป้องกัน zoom บน iOS */
    padding: 0.75rem 1rem;
}

.btn-ask {
    background: linear-gradient(135deg, #3f7ec5, #0d0b7e);
    border: none;
    transition: all 0.3s;
    padding: 0.75rem 1.5rem;
    white-space: nowrap;
    color:#fff;
}

/* Popular Questions - Responsive */
.question-badge {
    background: #e3f2fd;
    color: #1976d2;
    padding: 8px 15px;
    border-radius: 20px;
    margin: 5px;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-block;
    font-size: 13px;
    font-weight: 500;
    word-break: keep-all;
}

/* Answer Card */
.answer-card {
    padding: 20px;
    border-radius: 15px;
    margin: 15px;
    background: #f0f7ff;
    display: none;
    animation: fadeInUp 0.6s ease-out;
    border-left: 5px solid #4A90E2;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* FAQ List */
.faq-list {
    padding: 15px 20px 25px;
    background: white;
}

.faq-list h5 {
    font-size: 1.2rem;
    margin-bottom: 15px;
}

.faq-item {
    border-left: 4px solid #4A90E2;
    margin-bottom: 12px;
    padding: 12px 15px;
    background: #f8f9fa;
    border-radius: 10px;
    transition: all 0.3s;
    cursor: pointer;
}

.faq-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.faq-question {
    font-weight: 600;
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    line-height: 1.4;
}

.faq-question span {
    flex: 1;
}

.faq-answer {
    color: #555;
    margin-top: 10px;
    padding-left: 15px;
    display: none;
    border-left: 3px solid #4A90E2;
    line-height: 1.6;
    font-size: 0.9rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.faq-answer p img { width:100%; object-fit: contain; }

/* Stats Bar */
.stats-bar {
    background: #2c3e50;
    color: white;
    padding: 10px 15px;
    font-size: 12px;
    text-align: center;
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, .1);
    border-radius: 50%;
    border-top-color: #4A90E2;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Badge Category */
.badge-category {
    background: #6c5ce7;
    color: white;
    padding: 3px 10px;
    border-radius: 15px;
    font-size: 10px;
    margin-left: 8px;
    white-space: nowrap;
}

/* View Count */
.view-count {
    font-size: 11px;
    color: #999;
    margin-left: 8px;
}

/* Card inside answer */
.answer-card .card {
    border-radius: 12px;
    overflow: hidden;
}

.answer-card .card-body {
    padding: 15px;
}

.answer-card .card-body p {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Alert */
.alert {
    padding: 12px;
    font-size: 14px;
}

/* ========== Responsive Breakpoints ========== */

/* Mobile (<= 576px) */
@media (max-width: 576px) {
    body {
        padding: 10px;
    }

    .header {
        padding: 20px 15px;
    }

    .header i {
        font-size: 40px;
    }

    .header h2 {
        font-size: 1.3rem;
    }

    .header p {
        font-size: 0.85rem;
    }

    .search-area {
        padding: 15px;
    }

    .input-group {
        flex-direction: column;
        gap: 8px;
    }

    .input-group .input-group-text {
        width: 100%;
        justify-content: center;
    }

    #searchInput {
        width: 100%;
        border-radius: 10px !important;
        margin: 5px 0;
    }

    .btn-ask {
        width: 100%;
        border-radius: 10px !important;
        margin-top: 5px;
    }

    .question-badge {
        font-size: 11px;
        padding: 6px 12px;
        margin: 4px;
    }

    .answer-card {
        margin: 12px;
        padding: 15px;
    }

    .faq-list {
        padding: 12px 15px 20px;
    }

    .faq-list h5 {
        font-size: 1rem;
    }

    .faq-question {
        font-size: 0.85rem;
    }

    .badge-category {
        font-size: 9px;
        padding: 2px 6px;
    }

    .stats-bar {
        font-size: 10px;
        padding: 8px 12px;
    }

    .stats-bar i {
        margin-right: 3px;
    }
}

/* Tablet (577px - 768px) */
@media (min-width: 577px) and (max-width: 768px) {
    body {
        padding: 15px;
    }

    .header h2 {
        font-size: 1.5rem;
    }

    .header p {
        font-size: 0.9rem;
    }

    .question-badge {
        font-size: 12px;
        padding: 7px 13px;
    }

    .faq-question {
        font-size: 0.9rem;
    }
}

/* Small Mobile (<= 380px) */
@media (max-width: 380px) {
    .header i {
        font-size: 35px;
    }

    .header h2 {
        font-size: 1.1rem;
    }

    .question-badge {
        font-size: 10px;
        padding: 5px 10px;
    }

    .faq-question {
        font-size: 0.8rem;
        flex-wrap: wrap;
    }

    .badge-category {
        margin-left: 0;
        margin-top: 5px;
        display: inline-block;
    }

    .stats-bar {
        font-size: 9px;
    }
}

/* Landscape mode */
@media (max-width: 768px) and (orientation: landscape) {
    body {
        padding: 10px;
    }

    .header {
        padding: 15px;
    }

    .header i {
        font-size: 35px;
    }

    .header h2 {
        font-size: 1.2rem;
        margin: 8px 0;
    }

    .search-area {
        padding: 12px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    @media (max-width: 768px) {
        .faq-container {
            background: #1a1a2e;
        }

        .search-area {
            background: #16213e;
        }

        .faq-list {
            background: #1a1a2e;
        }

        .faq-item {
            background: #16213e;
            color: #eee;
        }

        .faq-question {
            color: #eee;
        }

        .faq-answer {
            color: #ccc;
        }
    }
}

/* Touch-friendly buttons */
@media (max-width: 768px) {

    .btn-ask,
    .question-badge,
    .faq-item {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .btn-ask:active,
    .question-badge:active,
    .faq-item:active {
        transform: scale(0.98);
    }
}

/* Scroll to top button for mobile */
.scroll-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #4A90E2;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

.scroll-top.visible {
    opacity: 1;
}

@media (max-width: 576px) {
    .scroll-top {
        bottom: 15px;
        right: 15px;
        width: 35px;
        height: 35px;
    }
}

/* Typing effect for mobile */
.typing-effect {
    overflow-x: auto;
    white-space: normal;
    word-wrap: break-word;
}

.typing-effect p img { width:100%; object-fit: contain; }