/* ============================================================
   gene — custom CSS (เสริม Tailwind)
   ============================================================ */

:root {
    --color-primary: #6366f1;
    --color-primary-dark: #4f46e5;
    --color-secondary: #8b5cf6;
    --color-accent: #06b6d4;
}

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Prompt', system-ui, -apple-system, sans-serif;
    background-color: #f8fafc;
    color: #1e293b;
}

/* ===== สกอร์ลบาร์ ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== กราเดียนต์พื้นหลัง ===== */
.gradient-primary {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
}
.gradient-soft {
    background: linear-gradient(135deg, #eef2ff 0%, #faf5ff 50%, #fdf4ff 100%);
}
.gradient-mesh {
    background-color: #f8fafc;
    background-image:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.1) 0px, transparent 50%);
}

/* ===== Glassmorphism ===== */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}
.glass-dark {
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* ===== การ์ด ===== */
.card {
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
    transition: all 0.25s ease;
}
.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);
}
.card-clickable {
    cursor: pointer;
}
.card-clickable:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px -5px rgba(99,102,241,0.18);
}

/* ===== ปุ่ม ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 0.625rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    white-space: nowrap;
}
.btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99,102,241,0.4);
}
.btn-ghost {
    background: transparent;
    color: #475569;
}
.btn-ghost:hover {
    background: #f1f5f9;
    color: #1e293b;
}
.btn-danger {
    background: #ef4444;
    color: #fff;
}
.btn-danger:hover { background: #dc2626; }

/* ===== ช่องใส่ข้อมูล ===== */
.form-input {
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.625rem;
    background: #fff;
    transition: all 0.2s ease;
    font-family: inherit;
    font-size: 0.95rem;
}
.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(99,102,241,0.1);
}
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #475569;
    margin-bottom: 0.375rem;
}

/* ===== Material Icon ขนาด ===== */
.material-icons.text-sm { font-size: 1rem; }
.material-icons.text-md { font-size: 1.25rem; }
.material-icons.text-lg { font-size: 1.5rem; }
.material-icons.text-xl { font-size: 2rem; }
.material-icons.text-2xl { font-size: 2.5rem; }

/* ===== Sidebar ===== */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    color: #475569;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
}
.sidebar-link:hover {
    background: #f1f5f9;
    color: #1e293b;
}
.sidebar-link.active {
    background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(139,92,246,0.12));
    color: #4f46e5;
    box-shadow: inset 3px 0 0 #6366f1;
}

/* ===== Animation ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to   { transform: translateX(0); }
}
@keyframes pulse-soft {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
.animate-fade-in { animation: fadeIn 0.4s ease-out; }
.animate-slide-in { animation: slideInLeft 0.3s ease-out; }
.animate-pulse-soft { animation: pulse-soft 2s ease-in-out infinite; }

/* ===== บทเรียนเนื้อหา (prose) ===== */
.lesson-content {
    line-height: 1.8;
    color: #334155;
}
.lesson-content h1 { font-size: 1.875rem; font-weight: 700; color: #0f172a; margin: 1.5rem 0 1rem; }
.lesson-content h2 { font-size: 1.5rem; font-weight: 700; color: #1e293b; margin: 1.25rem 0 0.75rem; }
.lesson-content h3 { font-size: 1.25rem; font-weight: 600; color: #334155; margin: 1rem 0 0.5rem; }
.lesson-content p  { margin: 0.75rem 0; }
.lesson-content ul, .lesson-content ol { margin: 0.75rem 0; padding-left: 1.5rem; }
.lesson-content li { margin: 0.375rem 0; }
.lesson-content ul li { list-style: disc; }
.lesson-content ol li { list-style: decimal; }
.lesson-content a { color: #6366f1; text-decoration: underline; }
.lesson-content a:hover { color: #4f46e5; }
.lesson-content img { max-width: 100%; border-radius: 0.75rem; margin: 1rem 0; }
.lesson-content blockquote {
    border-left: 4px solid #6366f1;
    background: #f5f3ff;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    border-radius: 0 0.5rem 0.5rem 0;
    color: #4c1d95;
}
.lesson-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}
.lesson-content th, .lesson-content td {
    border: 1px solid #e2e8f0;
    padding: 0.5rem 0.75rem;
    text-align: left;
}
.lesson-content th {
    background: #f1f5f9;
    font-weight: 600;
}
.lesson-content code {
    background: #f1f5f9;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.9em;
    color: #db2777;
}
.lesson-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1rem 0;
}

/* ===== Chat bubble ===== */
.chat-bubble-user,
.chat-bubble-ai {
    display: block;
    min-width: 0;
    width: fit-content;        /* กรอบฟิตตามเนื้อหา ไม่ยืนเต็มแถว */
    max-width: 80%;            /* ไม่ให้กว้างเกิน 80% ของพื้นที่แชท */
    overflow-wrap: anywhere;   /* ตัดคำ/URL ยาว ไม่ให้ล้นเบียด */
    word-break: break-word;
    line-height: 1.6;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.chat-bubble-user {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-radius: 1.25rem 1.25rem 0.25rem 1.25rem;
}
.chat-bubble-ai {
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #1e293b;
    border-radius: 1.25rem 1.25rem 1.25rem 0.25rem;
}
/* เนื้อหา Markdown ในกรอบ AI */
.chat-bubble-ai p { margin: 0.4rem 0; }
.chat-bubble-ai p:first-child { margin-top: 0; }
.chat-bubble-ai p:last-child { margin-bottom: 0; }
.chat-bubble-ai ul, .chat-bubble-ai ol { margin: 0.4rem 0; padding-left: 1.25rem; }
.chat-bubble-ai ul li { list-style: disc; margin: 0.2rem 0; }
.chat-bubble-ai ol li { list-style: decimal; margin: 0.2rem 0; }
.chat-bubble-ai strong { font-weight: 600; color: #0f172a; }
.chat-bubble-ai code {
    background: #f1f5f9; padding: 0.1rem 0.35rem;
    border-radius: 0.25rem; font-size: 0.9em; color: #db2777;
}

/* ===== badge ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* ===== skeleton loader ===== */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.5rem;
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ===== Typing indicator ===== */
.typing-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: typing 1.4s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ===== Sidebar (lesson) collapse ===== */
.sidebar-collapsed .sidebar-text {
    display: none;
}
.sidebar-collapsed .sidebar-link {
    justify-content: center;
}
/* เมื่อยุบ sidebar: จัดไอคอนในส่วนหัว/ท้ายให้กึ่งกลางและไม่ล้น */
.sidebar-collapsed .sidebar-collapsible-row {
    justify-content: center;
}

/* ===== ซ่อน scrollbar ใน sidebar ===== */
.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

/* ===== ปรับ SweetAlert2 ให้เข้ากับ Prompt font ===== */
.swal2-popup {
    font-family: 'Prompt', sans-serif !important;
    border-radius: 1rem !important;
}
.swal2-title { font-weight: 600 !important; }
.swal2-confirm.btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    border-radius: 0.625rem !important;
}

/* ===== TinyMCE ปรับ padding ===== */
.tox-tinymce { border-radius: 0.625rem !important; border: 1.5px solid #e2e8f0 !important; }
.tox .tox-toolbar__primary { border-top-left-radius: 0.625rem !important; border-top-right-radius: 0.625rem !important; }

/* ===== responsive helpers ===== */
@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
}
