.ai-page { padding: 40px 20px 80px; max-width: 1100px; margin: 0 auto; }
.ai-header { text-align: center; margin-bottom: 50px; }
.ai-header h1 { font-size: 2.2rem; font-weight: 700; color: #16477f; margin-bottom: 15px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.ai-header p { color: #64748b; font-size: 1.1rem; max-width: 600px; margin: 0 auto; line-height: 1.5; }

.mood-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 15px; margin-bottom: 40px; }
.mood-card { background: #fff; border: 2px solid #e2e8f0; border-radius: 20px; padding: 25px 15px; text-align: center; cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); user-select: none; }
.mood-card--senang { --mood-color: #fbbf24; --mood-light: #fbbf2420; }
.mood-card--sedih { --mood-color: #60a5fa; --mood-light: #60a5fa20; }
.mood-card--frustasi { --mood-color: #f87171; --mood-light: #f8717120; }
.mood-card--penasaran { --mood-color: #a78bfa; --mood-light: #a78bfa20; }
.mood-card--bosan { --mood-color: #9ca3af; --mood-light: #9ca3af20; }
.mood-card--romantis { --mood-color: #fb7185; --mood-light: #fb718520; }
.mood-card--cemas { --mood-color: #fcd34d; --mood-light: #fcd34d20; }
.mood-card--bersemangat { --mood-color: #f97316; --mood-light: #f9731620; }
.mood-card--tenang { --mood-color: #34d399; --mood-light: #34d39920; }
.mood-card--termotivasi { --mood-color: #818cf8; --mood-light: #818cf820; }
.mood-card:hover { transform: translateY(-5px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); border-color: #cbd5e1; }
.mood-card.selected { border-color: var(--mood-color); background: var(--mood-light); }
.mood-card.selected .mood-emoji { transform: scale(1.1); }
.mood-emoji { font-size: 3rem; margin-bottom: 10px; display: block; transition: transform 0.2s; }
.mood-label { font-weight: 700; color: #334155; font-size: 0.95rem; }

.mood-desc-area { background: #fff; padding: 30px; border-radius: 20px; border: 1px solid #e2e8f0; margin-bottom: 30px; display: none; animation: fadeIn 0.4s; }
.mood-desc-area label { font-weight: 600; color: #1e293b; margin-bottom: 10px; display: block; }
.mood-desc-area textarea { width: 100%; border: 2px solid #e2e8f0; border-radius: 12px; padding: 15px; font-family: inherit; font-size: 0.95rem; outline: none; transition: border-color 0.2s; resize: vertical; min-height: 100px; }
.mood-desc-area textarea:focus { border-color: var(--opac-blue); }

.btn-ai { padding: 14px 30px; border-radius: 12px; font-weight: 700; border: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 10px; transition: all 0.2s; font-size: 1rem; color: white; background: linear-gradient(135deg, #f59e0b, #f97316); width: 100%; max-width: 300px; margin: 0 auto; }
.btn-ai:hover { opacity: 0.9; transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(245,158,11,0.3); }

/* Result State */
#mood-result-container { display: none; }
.result-banner { padding: 40px; border-radius: 24px; color: white; margin-bottom: 40px; text-align: center; position: relative; overflow: hidden; }
.result-banner--senang { background: linear-gradient(135deg, #fbbf24, #1e293b); }
.result-banner--sedih { background: linear-gradient(135deg, #60a5fa, #1e293b); }
.result-banner--frustasi { background: linear-gradient(135deg, #f87171, #1e293b); }
.result-banner--penasaran { background: linear-gradient(135deg, #a78bfa, #1e293b); }
.result-banner--bosan { background: linear-gradient(135deg, #9ca3af, #1e293b); }
.result-banner--romantis { background: linear-gradient(135deg, #fb7185, #1e293b); }
.result-banner--cemas { background: linear-gradient(135deg, #fcd34d, #1e293b); }
.result-banner--bersemangat { background: linear-gradient(135deg, #f97316, #1e293b); }
.result-banner--tenang { background: linear-gradient(135deg, #34d399, #1e293b); }
.result-banner--termotivasi { background: linear-gradient(135deg, #818cf8, #1e293b); }
.result-banner::before { content: '"'; position: absolute; font-size: 15rem; font-family: serif; opacity: 0.1; top: -50px; left: 20px; line-height: 1; }
.quote-text { font-size: 1.5rem; font-style: italic; font-weight: 600; margin-bottom: 20px; position: relative; z-index: 1; }
.analysis-text { font-size: 1.05rem; opacity: 0.9; max-width: 800px; margin: 0 auto; line-height: 1.6; }

.section-title { font-size: 1.4rem; font-weight: 700; color: #1e293b; margin: 0 0 20px; display: flex; align-items: center; gap: 10px; }

.books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 20px; }
.ai-books-pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 20px; padding-top: 16px; border-top: 1px solid #e2e8f0; color: #64748b; font-size: .9rem; }
.ai-books-pagination[hidden] { display: none !important; }
.ai-books-pagination button { border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 14px; background: #fff; color: #334155; font: inherit; font-weight: 600; cursor: pointer; }
.ai-books-pagination button:hover:not(:disabled) { background: #eff6ff; border-color: #93c5fd; }
.ai-books-pagination button:disabled { opacity: .5; cursor: not-allowed; }
.book-card { background: #fff; border-radius: 12px; overflow: hidden; border: 1px solid #e2e8f0; text-decoration: none; color: inherit; transition: transform 0.2s; display: flex; flex-direction: column; }
.book-card:hover { transform: translateY(-5px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); }
.book-cover { width: 100%; aspect-ratio: 2/3; object-fit: cover; background: #f1f5f9; }
.book-info { padding: 15px; flex-grow: 1; }
.book-title { font-weight: 700; font-size: 0.9rem; margin: 0 0 5px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-author { font-size: 0.8rem; color: #64748b; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.playlist-card { background: #fff; border-radius: 16px; border: 1px solid #e2e8f0; padding: 25px; height: 100%; }
.playlist-item { display: flex; gap: 15px; margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid #f1f5f9; }
.playlist-item:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.playlist-number { width: 32px; height: 32px; border-radius: 50%; background: #f1f5f9; color: #475569; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.playlist-content h4 { margin: 0 0 5px; font-size: 1rem; color: #1e293b; }
.playlist-content p { margin: 0; font-size: 0.9rem; color: #64748b; line-height: 1.5; }

.loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.9); z-index: 1000; display: none; flex-direction: column; align-items: center; justify-content: center; }
.ai-tab-icon--purple { color: #9333ea; }
.ai-tab-icon--amber { color: #d97706; }
.ai-tab-icon--green { color: #16a34a; }
.ai-tab-icon--orange { color: #ea580c; }
.ai-tab-icon--blue { color: #2563eb; }
.ai-icon-blue { color: #3b82f6; }
.ai-icon-amber { color: #f59e0b; }
.ai-icon-green { color: #22c55e; }
.ai-icon-14 { width: 14px; }
.ai-icon-16 { width: 16px; }
.ai-icon-18 { width: 18px; }
.sidebar-box--tips { background: #f0fdf4; border-color: #bbf7d0; }
.sidebar-box__title--tips { color: #166534 !important; }
.family-tips-list { margin: 0; padding-left: 20px; color: #15803d; font-size: .9rem; line-height: 1.6; }
.family-back-wrap { margin-top: 50px; text-align: center; }
.btn-ai--outline { width: auto; border: 1px solid #3b82f6; color: #3b82f6; background: transparent; }
.loading-title { color: #1e293b; }
.loading-desc { color: #64748b; }
.ai-empty-search { padding: 15px; text-align: center; color: #64748b; }
.ai-subsection-heading { font-size: 1.1rem; margin-bottom: 15px; }
.ai-subsection-heading--compact { margin-bottom: 10px; }
.family-member-card--entering { animation: fadeIn .3s; }
.ai-empty-family-book { color: #64748b; font-size: .9rem; }
.ai-level-badge { font-size: .9rem; font-weight: 400; color: #64748b; margin-left: 10px; }
.ai-timeline-book { margin-bottom: 15px; }
.ai-timeline-book a { color: #647d68; text-decoration: none; }
.is-hidden { display: none !important; }
.spinner { width: 50px; height: 50px; border: 5px solid #f3f3f3; border-top: 5px solid #f59e0b; border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 20px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.ai-bottom-actions { display: flex; flex-direction: column; align-items: center; gap: 15px; margin-top: 40px; padding-bottom: 20px; }

/* Give the retry and return actions clear spacing in the OPAC AI panel. */
#tab-mood-baca .ai-bottom-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    width: min(100%, 320px);
    margin: 32px auto 0;
    padding: 0 0 20px;
}

#tab-mood-baca .ai-bottom-actions .btn-ai {
    box-sizing: border-box;
    width: 100%;
    max-width: none;
    min-height: 48px;
    margin: 0;
    text-align: center;
    text-decoration: none;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .ai-page { padding: 20px 10px 40px; }
    .ai-header h1 { font-size: 1.6rem; }
    .ai-header p { font-size: 0.95rem; }
    .mood-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
    .mood-card { padding: 15px 10px; }
    .mood-emoji { font-size: 2.5rem; }
    .mood-label { font-size: 0.85rem; }
    .btn-ai { font-size: 0.95rem; padding: 12px 20px; }
    .result-banner { padding: 25px 20px; margin-bottom: 30px; }
    .result-banner::before { font-size: 10rem; top: -30px; left: 10px; }
    .quote-text { font-size: 1.2rem; margin-bottom: 15px; }
    .analysis-text { font-size: 0.95rem; }
    .section-title { font-size: 1.2rem; }
    .playlist-card { padding: 20px; }
}

@media (max-width: 767.98px) {
    .ai-spa-container .books-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .ai-spa-container .book-info { padding: 10px; }
    .ai-spa-container .ai-books-pagination { gap: 8px; font-size: .8rem; }
    .ai-spa-container .ai-books-pagination button { padding: 7px 9px; }
}

/* Keep the mood result sections in a stable two-column layout on wide screens. */
#tab-mood-baca .mood-result-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(260px, .9fr);
    align-items: start;
    gap: 24px;
}
#tab-mood-baca .mood-result-grid > * { min-width: 0; }
#tab-mood-baca .mood-result-side { display: flex; flex-direction: column; gap: 22px; }
#tab-mood-baca .playlist-card { box-sizing: border-box; width: 100%; height: auto; min-height: 120px; }
#tab-mood-baca .ai-friend-container {
    box-sizing: border-box;
    display: block;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 20px;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: #f8fafc;
    box-shadow: none;
}
#tab-mood-baca .ai-friend-title { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: 1.05rem; }
#tab-mood-baca .ai-friend-desc { margin: 0; color: #475569; line-height: 1.6; overflow-wrap: anywhere; }
#tab-mood-baca .ai-empty-state { grid-column: 1 / -1; margin: 0; padding: 18px; color: #64748b; border: 1px dashed #cbd5e1; border-radius: 12px; text-align: center; }

@media (max-width: 768px) {
    #tab-mood-baca .mood-result-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
    #tab-mood-baca .mood-result-side { gap: 18px; }
    #tab-mood-baca .ai-bottom-actions { position: static; width: 100%; max-width: 360px; margin: 24px auto 0; gap: 12px; }
    #tab-mood-baca .ai-bottom-actions .btn-ai { position: static; transform: none; }
}
