/**
 * UI4 - Tiểu Mai Đồng Hành (Hỗ trợ cha mẹ trẻ tự kỷ)
 * File: ui4/css/ui4-autism.css
 * Version: 1.0.0
 * 
 * Copy từ preview đã được duyệt
 */


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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f5f5;
    color: #1a1a1a;
    line-height: 1.6;
}

/* ============================================
   CSS VARIABLES
============================================ */
:root {
    /* Primary - Xanh lá ấm áp */
    --ui4-primary: #34A853;
    --ui4-primary-dark: #2d9248;
    --ui4-primary-light: #f0faf3;
    
    /* Secondary */
    --ui4-secondary: #4f726c;
    
    /* Active color - màu kem nhẹ */
    --ui4-active: #F2ECD9;
    --ui4-active-text: #333333;
    
    /* Text */
    --ui4-text: #1a1a1a;
    --ui4-text-muted: #5f6368;
    
    /* Background - sẫm hơn, liền mạch */
    --ui4-bg: #f5f0e8;
    --ui4-bg-light: #f5f5f0;
    --ui4-bg-gray: #ebe6dc;
    
    /* Sizing */
    --ui4-max-width: 800px;
    --ui4-radius-sm: 8px;
    --ui4-radius-md: 12px;
    --ui4-radius-lg: 16px;
}

/* ============================================
   CONTAINER
============================================ */
.ui4-container {
    min-height: 100vh;
    padding: 25px;
    background: var(--ui4-bg);
}

.ui4-wrapper {
    max-width: var(--ui4-max-width);
    margin: 0 auto;
}

/* ============================================
   HEADER
============================================ */
.ui4-header {
    text-align: center;
    padding: 20px 0 10px;
}

.ui4-header-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 0;
}

.ui4-header-icon {
    font-size: 40px;
}

.ui4-header-text {
    font-size: 28px;
    font-weight: 700;
    color: #1e73be;
}

.ui4-header-subtitle {
    display: none;
}

/* ============================================
   CATEGORIES
============================================ */
.ui4-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 24px;
}

.ui4-cat-btn {
    padding: 10px 14px;
    border-radius: var(--ui4-radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 2px solid var(--ui4-primary);
    background: #e8e8e8;
    color: var(--ui4-text);
    transition: all 0.2s;
}

.ui4-cat-btn:hover {
    background: var(--ui4-active);
}

.ui4-cat-btn.active {
    background: var(--ui4-active);
    color: var(--ui4-active-text);
    border-color: var(--ui4-primary);
}

.ui4-cat-btn.all-btn {
    border-color: var(--ui4-secondary);
    color: var(--ui4-text);
}

.ui4-cat-btn.all-btn:hover {
    background: var(--ui4-active);
}

.ui4-cat-btn.all-btn.active {
    background: var(--ui4-active);
    color: var(--ui4-active-text);
}

/* Category buttons - tất cả dùng cùng style */
.ui4-cat-btn[data-cat] {
    border-color: var(--ui4-primary);
    color: var(--ui4-text);
}

.ui4-cat-btn[data-cat].active {
    background: var(--ui4-active);
    color: var(--ui4-active-text);
}

.ui4-cat-count {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    background: rgba(0,0,0,0.08);
}

.ui4-cat-btn.active .ui4-cat-count {
    background: rgba(255,255,255,0.3);
}

/* ============================================
   SEARCH
============================================ */
.ui4-search {
    position: relative;
    margin-bottom: 24px;
}

.ui4-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--ui4-primary);
    pointer-events: none;
    z-index: 1;
}

.ui4-search-input {
    width: 100%;
    padding: 16px 50px 16px 70px !important;
    border-radius: var(--ui4-radius-md);
    border: 2px solid var(--ui4-primary);
    font-size: 16px;
    color: var(--ui4-text);
    outline: none;
    background: #e8e8e8;
}

.ui4-search-input:focus {
    box-shadow: 0 0 0 3px rgba(52, 168, 83, 0.15);
}

.ui4-search-input::placeholder {
    color: var(--ui4-text-muted);
}

.ui4-search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: #e8e8e8;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--ui4-text-muted);
}

.ui4-search-clear.show {
    display: flex;
}

/* ============================================
   RESULTS BOX
============================================ */
.ui4-results {
    background: #e8e8e8;
    border-radius: var(--ui4-radius-lg);
    overflow: hidden;
    border: 2px solid var(--ui4-primary);
    margin-bottom: 24px;
}

.ui4-results-header {
    padding: 14px 20px;
    background: var(--ui4-bg-gray);
    border-bottom: 2px solid rgba(52, 168, 83, 0.2);
    font-size: 15px;
    font-weight: 600;
    color: var(--ui4-text-muted);
}

.ui4-results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    padding: 16px;
}

@media (max-width: 640px) {
    .ui4-results-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   SITUATION CARD
============================================ */
.ui4-situation {
    padding: 16px;
    border-radius: var(--ui4-radius-md);
    border: 2px solid #e5e7eb;
    background: var(--ui4-bg);
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: all 0.2s;
}

.ui4-situation:hover {
    border-color: var(--ui4-primary);
    background: var(--ui4-primary-light);
}

.ui4-situation-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    background: #e8e8e8;
}

.ui4-situation[data-cat="sos"] .ui4-situation-icon { background: #fef2f2; }
.ui4-situation[data-cat="behavior"] .ui4-situation-icon { background: #f5f3ff; }
.ui4-situation[data-cat="sensory"] .ui4-situation-icon { background: #ecfeff; }
.ui4-situation[data-cat="communication"] .ui4-situation-icon { background: #ecfdf5; }
.ui4-situation[data-cat="daily"] .ui4-situation-icon { background: #fffbeb; }
.ui4-situation[data-cat="play-learn"] .ui4-situation-icon { background: #eff6ff; }
.ui4-situation[data-cat="family"] .ui4-situation-icon { background: #fdf2f8; }
.ui4-situation[data-cat="parent-mind"] .ui4-situation-icon { background: #f0fdf4; }
.ui4-situation[data-cat="knowledge"] .ui4-situation-icon { background: #f8fafc; }

.ui4-situation-content {
    flex: 1;
    min-width: 0;
}

.ui4-situation-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--ui4-text);
    line-height: 1.4;
    margin-bottom: 4px;
}

.ui4-situation-cat {
    font-size: 13px;
    color: var(--ui4-text-muted);
}

.ui4-situation-arrow {
    color: var(--ui4-primary);
    font-size: 18px;
    flex-shrink: 0;
}

/* ============================================
   FOOTER
============================================ */
.ui4-footer {
    text-align: center;
    padding: 8px;
    font-size: 14px;
    color: var(--ui4-text-muted);
}

.ui4-footer a {
    color: var(--ui4-primary);
    text-decoration: none;
    font-weight: 600;
}

/* ============================================
   VIEW CONTROLS
============================================ */
.ui4-view {
    display: none;
}

.ui4-view.active {
    display: block;
}

/* ============================================
   BACK BUTTON (đã gộp vào answer-header)
============================================ */
.ui4-back-bar {
    display: none; /* Đã chuyển vào answer-header */
}

.ui4-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--ui4-radius-sm);
    border: 2px solid var(--ui4-primary);
    background: var(--ui4-bg);
    color: var(--ui4-primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.ui4-back-btn:hover {
    background: var(--ui4-primary-light);
    color: var(--ui4-primary);
}

.ui4-current-cat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--ui4-radius-sm);
    font-size: 14px;
    font-weight: 600;
    background: var(--ui4-primary);
    color: white;
}

.ui4-current-cat.sos { background: var(--cat-sos); }
.ui4-current-cat.behavior { background: var(--cat-behavior); }
.ui4-current-cat.sensory { background: var(--cat-sensory); }
.ui4-current-cat.communication { background: var(--cat-communication); }
.ui4-current-cat.daily { background: var(--cat-daily); }
.ui4-current-cat.play-learn { background: var(--cat-play-learn); }
.ui4-current-cat.family { background: var(--cat-family); }
.ui4-current-cat.parent-mind { background: var(--cat-parent-mind); }
.ui4-current-cat.knowledge { background: var(--cat-knowledge); }

/* ============================================
   ANSWER VIEW
============================================ */
.ui4-answer-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--ui4-text);
    margin-bottom: 20px;
    line-height: 1.4;
}

.ui4-answer-box {
    background: var(--ui4-bg);
    border-radius: var(--ui4-radius-lg);
    border: 2px solid var(--ui4-primary);
    overflow: hidden;
    margin-bottom: 20px;
}

.ui4-answer-header {
    padding: 14px 20px;
    background: var(--ui4-primary-light);
    border-bottom: 2px solid rgba(52, 168, 83, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.ui4-answer-header .ui4-back-btn {
    padding: 8px 12px;
    font-size: 14px;
    margin: 0;
}

.ui4-answer-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ui4-answer-avatar {
    font-size: 24px;
}

.ui4-answer-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--ui4-primary);
}

.ui4-answer-header .ui4-current-cat {
    padding: 6px 12px;
    font-size: 13px;
    background: var(--ui4-primary);
    color: white;
    border-radius: var(--ui4-radius-sm);
}

.ui4-answer-content {
    padding: 20px;
    font-size: 16px;
    line-height: 1.8;
    color: var(--ui4-text);
    max-height: 400px;
    overflow-y: auto;
}

.ui4-answer-content strong {
    color: var(--ui4-primary-dark);
}

.ui4-answer-content p {
    margin-bottom: 16px;
}

.ui4-answer-content p:last-child {
    margin-bottom: 0;
}

/* Answer Toolbar - nhỏ gọn trong answer box */
.ui4-answer-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-top: 1px solid rgba(52, 168, 83, 0.15);
    background: var(--ui4-bg-gray);
}

.ui4-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    background: var(--ui4-bg);
    color: var(--ui4-text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.ui4-toolbar-btn:hover {
    border-color: var(--ui4-primary);
    color: var(--ui4-primary);
    background: var(--ui4-primary-light);
}

.ui4-toolbar-btn.playing {
    border-color: var(--ui4-primary);
    color: var(--ui4-primary);
    background: var(--ui4-primary-light);
}

.ui4-toolbar-btn svg {
    width: 14px;
    height: 14px;
}

/* Ask More Section */
.ui4-ask-more {
    background: var(--ui4-bg-gray);
    border-radius: var(--ui4-radius-lg);
    padding: 20px;
    margin-bottom: 20px;
}

.ui4-ask-more-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--ui4-text);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ui4-ask-input {
    width: 100%;
    padding: 14px 16px;
    border-radius: var(--ui4-radius-md);
    border: 2px solid #e5e7eb;
    font-size: 16px;
    outline: none;
    margin-bottom: 12px;
}

.ui4-ask-input:focus {
    border-color: var(--ui4-primary);
    box-shadow: 0 0 0 3px rgba(52, 168, 83, 0.15);
}

.ui4-ask-btn {
    width: 100%;
    padding: 14px;
    border-radius: var(--ui4-radius-md);
    border: 2px solid var(--ui4-primary);
    background: transparent;
    color: var(--ui4-primary);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ui4-ask-btn:hover {
    background: var(--ui4-primary-light);
    color: var(--ui4-primary);
}

/* Warning */
.ui4-warning {
    text-align: center;
    font-size: 14px;
    color: var(--ui4-text-muted);
    padding: 17px 12px 12px 12px;
    background: transparent;
    border-radius: var(--ui4-radius-sm);
}

/* ============================================
   CHAT VIEW
============================================ */
.ui4-chat-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--ui4-text);
    margin-bottom: 16px;
    line-height: 1.4;
}

.ui4-messages {
    background: var(--ui4-bg);
    border-radius: var(--ui4-radius-lg);
    border: 2px solid #e5e7eb;
    padding: 16px;
    margin-bottom: 16px;
    max-height: 450px;
    overflow-y: auto;
}

.ui4-message {
    margin-bottom: 20px;
}

.ui4-message:last-child {
    margin-bottom: 0;
}

.ui4-message-label {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ui4-message-label.user {
    color: var(--ui4-primary);
}

.ui4-message-label.bot {
    color: var(--ui4-text-muted);
}

.ui4-message-content {
    padding: 14px 18px;
    border-radius: var(--ui4-radius-md);
    font-size: 15px;
    line-height: 1.7;
}

.ui4-message-content.user {
    background: var(--ui4-primary-light);
    border: 2px solid var(--ui4-primary);
}

.ui4-message-content.bot {
    background: var(--ui4-bg-gray);
    border: 2px solid #e5e7eb;
}

.ui4-message-content strong {
    color: var(--ui4-primary-dark);
}

/* Typing indicator */
.ui4-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    font-size: 14px;
    color: var(--ui4-text-muted);
}

.ui4-typing-dots {
    display: flex;
    gap: 4px;
}

.ui4-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ui4-primary);
    animation: typing 1.4s infinite ease-in-out both;
}

.ui4-typing-dots span:nth-child(1) { animation-delay: 0s; }
.ui4-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ui4-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

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

/* Chat input */
.ui4-chat-input {
    display: flex;
    gap: 12px;
}

.ui4-chat-input input {
    flex: 1;
    padding: 14px 16px;
    border-radius: var(--ui4-radius-md);
    border: 2px solid var(--ui4-primary);
    font-size: 16px;
    outline: none;
}

.ui4-chat-input input:focus {
    box-shadow: 0 0 0 3px rgba(52, 168, 83, 0.15);
}

.ui4-chat-input button {
    padding: 14px 24px;
    border-radius: var(--ui4-radius-md);
    border: none;
    background: var(--ui4-primary);
    color: white;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.ui4-chat-input button:hover {
    background: var(--ui4-primary-dark);
}

/* ============================================
   EMPTY STATE
============================================ */
.ui4-empty {
    padding: 48px;
    text-align: center;
    grid-column: 1 / -1;
}

.ui4-empty-icon {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 12px;
}

.ui4-empty-text {
    font-size: 16px;
    color: var(--ui4-text-muted);
}

/* ============================================
   RESPONSIVE
============================================ */
@media (max-width: 640px) {
    .ui4-container {
        font-size: 20px;
    }
    
    .ui4-header-text {
        font-size: 28px;
    }
    
    .ui4-header-subtitle {
        font-size: 19px;
    }
    
    .ui4-cat-btn {
        padding: 12px 16px;
        font-size: 18px;
    }
    
    .ui4-search-input {
        font-size: 20px;
    }
    
    .ui4-results-header {
        font-size: 19px;
    }
    
    .ui4-situation {
        font-size: 19px;
    }
    
    .ui4-answer-title {
        font-size: 24px;
    }
    
    .ui4-answer-content {
        padding: 16px;
        font-size: 19px;
    }
    
    .ui4-ask-input {
        font-size: 19px;
    }
    
    .ui4-ask-btn,
    .ui4-back-btn {
        font-size: 18px;
    }
    
    .ui4-warning {
        font-size: 17px;
    }
    
    .ui4-footer {
        font-size: 17px;
    }
    
    .ui4-message-content {
        font-size: 19px;
    }
}
    </style>
        <style>
            body { font-family: -apple-system, sans-serif; padding: 40px; line-height: 1.8; }
            h1 { color: #34A853; font-size: 24px; margin-bottom: 20px; }
            strong { color: #2d9248; }

/* ============================================
   CHAT HEADER - Đơn giản, text only
============================================ */
.ui4-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.ui4-chat-back {
    color: var(--ui4-primary);
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
}

.ui4-chat-back:hover {
    text-decoration: underline;
}

.ui4-chat-brand {
    font-weight: 700;
    color: var(--ui4-primary);
    font-size: 16px;
}

.ui4-chat-cat {
    color: var(--ui4-primary);
    font-weight: 600;
    font-size: 14px;
}

/* ============================================
   CHAT TOOLBAR - Đơn giản
============================================ */
.ui4-chat-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 12px 0;
    margin-top: 12px;
}

.ui4-text-btn {
    background: none;
    border: none;
    color: var(--ui4-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
}

.ui4-text-btn:hover {
    text-decoration: underline;
}

/* ============================================
   ANSWER HEADER - Đơn giản, text only
============================================ */
.ui4-answer-header .ui4-back-btn {
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    color: var(--ui4-primary) !important;
    font-size: 14px !important;
}

.ui4-answer-header .ui4-back-btn:hover {
    text-decoration: underline;
}

.ui4-answer-header .ui4-current-cat {
    padding: 0 !important;
    background: transparent !important;
    color: var(--ui4-primary) !important;
    font-size: 14px !important;
    border-radius: 0 !important;
}

/* ============================================
   USER TYPE TABS (Parent / Teacher)
============================================ */
.ui4-user-tabs {
    display: flex;
    gap: 12px;
    margin-top: 5px;
    padding: 0 20px 15px;
    justify-content: center;
}

.ui4-user-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: all 0.25s ease;
    font-size: 13px;
    font-weight: 600;
    color: #4f726c;
    letter-spacing: 0.3px;
}

.ui4-user-tab:hover {
    transform: translateY(-2px);
    border-color: #FFB74D;
    box-shadow: 0 4px 12px rgba(255, 183, 77, 0.25);
    background: #FFF8E1;
    color: #4f726c;
}

.ui4-user-tab.active {
    border-color: #FFB74D;
    background: linear-gradient(135deg, #FFCC80 0%, #FFB74D 100%);
    color: #5D4037;
    box-shadow: 0 4px 15px rgba(255, 183, 77, 0.35);
}

.ui4-tab-icon {
    font-size: 20px;
}

.ui4-tab-label {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 12px;
}

.ui4-tab-count {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    min-width: 28px;
    text-align: center;
}

.ui4-user-tab.active .ui4-tab-count {
    background: rgba(255,255,255,0.5);
    color: #5D4037;
}

.ui4-user-tab:not(.active) .ui4-tab-count {
    background: #FFF8E1;
    color: #FF8F00;
}

/* Responsive */
@media (max-width: 600px) {
    .ui4-user-tabs {
        flex-direction: column;
        padding: 5px 15px 15px;
        gap: 10px;
    }
    
    .ui4-user-tab {
        justify-content: center;
        padding: 14px 20px;
    }
    
    .ui4-tab-label {
        font-size: 11px;
    }
}
