/* ================================================================
   KruPlus Shared UI — v3.0 (index.html-aligned, Tailwind-friendly)
   ไฟล์นี้ให้เฉพาะ infrastructure ที่ Tailwind ทำไม่ได้:
     - Bottom nav (fixed)
     - Toast stack
     - Tooltip bubble
     - Help modal
   ห้ามบังคับ font / theme / colors — ให้หน้า Tailwind จัดการเอง
   ================================================================ */

:root {
    --kp-primary:   #1FA88A;
    --kp-primary-d: #178a71;
    --kp-primary-l: #e8f8f5;
    --kp-nav-h: 64px;
}

/* ══════════════════════════════════════════════════════════════
   THAI TYPOGRAPHY & LETTER-SPACING STANDARDS FOR CURRENT & FUTURE PAGES
   มาตรฐานฟอนต์และระยะช่องไฟตัวหนา เพื่อให้อ่านง่าย สบายตา สระบน/ล่างและวรรณยุกต์ไม่ชนกัน
   ══════════════════════════════════════════════════════════════ */
h1, h2, h3, h4, h5, h6 {
    letter-spacing: 0.015em;
}

.tracking-tight {
    letter-spacing: 0.01em !important;
}

.tracking-tighter {
    letter-spacing: 0 !important;
}

.font-black {
    font-weight: 800;
    letter-spacing: 0.015em;
}
.font-extrabold {
    font-weight: 700;
    letter-spacing: 0.015em;
}
.font-bold {
    letter-spacing: 0.015em;
}

/* Add padding-bottom for bottom nav, but only when nav is mounted */
body.kp-page {
    padding-bottom: calc(var(--kp-nav-h) + env(safe-area-inset-bottom, 0px));
}

/* ================================================================
   TOP BRAND HEADER (logo + tagline + semester)
   Auto-mounted by kp_header.js on every teacher page.
   Non-sticky — scrolls away when scrolling down.
   ================================================================ */
.kp-header {
    background: linear-gradient(95deg, #1FA88A 0%, #4FD1B0 60%, #7DDEC0 100%);
    padding: 10px 16px;
    color: white;
    box-shadow: 0 2px 8px rgba(14, 59, 48, .1);
    font-family: 'Sarabun', sans-serif;
}
.kp-header__inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}
.kp-header__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: white;
    flex-shrink: 0;
    transition: transform .1s;
}
.kp-header__brand:active { transform: scale(.98); }
.kp-header__logo {
    height: 38px;
    width: auto;
    object-fit: contain;
}
.kp-header__tagline {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.kp-header__sub {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, .92);
    white-space: nowrap;
}
.kp-header__sem {
    margin-left: auto;
    flex-shrink: 0;
}
.kp-header__sem-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: white;
    color: #4cbba1;
    font-family: inherit;
    font-weight: 800;
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 99px;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
    transition: box-shadow .15s, transform .1s;
    white-space: nowrap;
}
.kp-header__sem-btn:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, .15); }
.kp-header__sem-btn:active { transform: scale(.97); }
.kp-header__sem-btn--warn {
    background: #fef3c7;
    color: #b45309;
}

/* Mobile: hide tagline, shrink badge */
@media (max-width: 640px) {
    .kp-header { padding: 8px 12px; }
    .kp-header__logo { height: 34px; }
    .kp-header__tagline { display: none; }
    .kp-header__sem-btn { font-size: 11.5px; padding: 6px 10px; }
}
@media (max-width: 380px) {
    .kp-header__sem-btn span { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
}

/* Don't print the brand strip */
@media print {
    .kp-header { display: none !important; }
}

/* ================================================================
   BOTTOM NAV
   ================================================================ */
.kp-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 20px -4px rgba(0,0,0,.06);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.kp-bottom-nav__inner {
    max-width: 600px;
    margin: 0 auto;
    height: var(--kp-nav-h);
    display: flex; align-items: stretch;
}
.kp-bottom-nav__item {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: #94a3b8;
    font-family: inherit;
    font-size: 11px; font-weight: 700;
    border: none; background: transparent;
    cursor: pointer;
    padding: 6px 4px;
    transition: color .15s, background-color .15s;
}
.kp-bottom-nav__item:hover { background: #f0fdf9; color: #475569; }
.kp-bottom-nav__item.active { color: var(--kp-primary-d); }
.kp-bottom-nav__item.active .kp-bottom-nav__icon {
    background: var(--kp-primary-l);
    color: var(--kp-primary-d);
    transform: scale(1.05);
}
.kp-bottom-nav__icon {
    font-size: 22px; line-height: 1;
    width: 40px; height: 28px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    transition: background-color .15s, transform .15s;
}
@media (min-width: 768px) {
    .kp-bottom-nav__inner { max-width: 720px; }
    .kp-bottom-nav__item { font-size: 12px; }
    .kp-bottom-nav__icon { font-size: 24px; width: 48px; height: 32px; }
}

/* ================================================================
   TOAST
   ================================================================ */
#kp-toast-stack {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    left: 50%; transform: translateX(-50%);
    z-index: 9999;
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
    max-width: calc(100vw - 24px);
}
.kp-toast {
    background: #1e293b;
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 8px 32px -8px rgba(0,0,0,.4);
    pointer-events: auto;
    display: flex; align-items: center; gap: 12px;
    min-width: 240px; max-width: 480px;
    font-family: inherit;
    font-size: 14px; font-weight: 600;
    animation: kpToastIn .25s cubic-bezier(.2,1,.3,1);
}
.kp-toast-success { background: #1FA88A; }
.kp-toast-error   { background: #ef4444; }
.kp-toast-warn    { background: #f59e0b; color: #422006; }
.kp-toast-info    { background: #3b82f6; }
.kp-toast .kp-toast-undo {
    background: rgba(255,255,255,.25); color: white;
    padding: 4px 10px; border-radius: 8px; border: 0;
    font-weight: 800; font-size: 12px; cursor: pointer;
    font-family: inherit;
    margin-left: auto;
}
@keyframes kpToastIn {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: none; }
}
.kp-toast.fading { opacity: 0; transition: opacity .3s; }

/* ================================================================
   TOOLTIP
   ================================================================ */
.kp-tip-bubble {
    position: absolute;
    background: #1e293b;
    color: white;
    padding: 8px 12px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 12px;
    max-width: 260px;
    box-shadow: 0 4px 16px -4px rgba(0,0,0,.2);
    z-index: 9998;
    pointer-events: none;
    line-height: 1.4;
}

/* ================================================================
   HELP MODAL
   ================================================================ */
#kp-help-modal {
    position: fixed; inset: 0;
    z-index: 9990;
    background: rgba(0,0,0,.4);
    display: flex; align-items: flex-end; justify-content: center;
    padding: 16px;
    font-family: inherit;
}
#kp-help-modal.hidden { display: none; }
#kp-help-modal .panel {
    background: white;
    border-radius: 24px 24px 0 0;
    width: 100%; max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px 20px;
    box-shadow: 0 -8px 32px -8px rgba(0,0,0,.2);
}
@media (min-width: 640px) {
    #kp-help-modal { align-items: center; }
    #kp-help-modal .panel { border-radius: 24px; }
}
.kp-help-item {
    border-bottom: 1px solid #e2e8f0;
    padding: 12px 0;
}
.kp-help-item:last-child { border: none; }
.kp-help-item-title {
    font-weight: 800; color: #1e293b;
    margin-bottom: 4px;
}
.kp-help-item-text {
    font-size: 13.5px; color: #64748b;
}

/* ================================================================
   EMPTY STATE (used by kp.empty())
   ================================================================ */
.kp-empty {
    background: white;
    border: 2px dashed #e2e8f0;
    border-radius: 24px;
    padding: 40px 24px;
    text-align: center;
    color: #64748b;
    font-family: inherit;
}
.kp-empty-icon { font-size: 56px; margin-bottom: 14px; line-height: 1; }
.kp-empty h3 {
    font-size: 17px; font-weight: 800;
    color: #1e293b; margin: 0 0 6px;
}
.kp-empty p {
    font-size: 13.5px; margin: 0 0 18px;
    color: #94a3b8;
    max-width: 380px; margin-left: auto; margin-right: auto;
}

/* ================================================================
   PRINT
   ================================================================ */
@media print {
    .kp-bottom-nav, #kp-toast-stack, #kp-help-modal { display: none !important; }
    body.kp-page { padding-bottom: 0; }
}

/* ================================================================
   🌟 CARTOON 3D BUTTON (Playful, Tactile with Highlight Sweep)
   ================================================================ */
.btn-cartoon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 48px;
    padding: 0 24px;
    font-size: 15px;
    font-weight: 800;
    border-radius: 9999px;
    border: 2px solid #262626 !important;
    color: #262626;
    background-color: #fb923c; /* default orange-400 */
    cursor: pointer;
    overflow: hidden;
    transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    text-decoration: none !important;
    user-select: none;
    line-height: 1;
    white-space: nowrap;
    outline: none;
    box-sizing: border-box;
}

.btn-cartoon:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 0 0 #262626 !important;
}

.btn-cartoon:active {
    transform: translateY(0);
    box-shadow: none !important;
}

.btn-cartoon:disabled,
.btn-cartoon.disabled,
.btn-cartoon[disabled] {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
    transform: none;
    box-shadow: none !important;
}

/* Highlight Sweep Effect (Shine Animation) */
.btn-cartoon .btn-cartoon-shine,
.btn-cartoon .btn-cartoon__shine {
    position: absolute;
    top: 50%;
    left: -100%;
    width: 4.5rem;
    height: 7rem;
    background: rgba(255, 255, 255, 0.45);
    transform: translateY(-50%) rotate(12deg);
    transition: all 0.5s ease-in-out;
    pointer-events: none;
    z-index: 1;
}

.btn-cartoon:hover .btn-cartoon-shine,
.btn-cartoon:hover .btn-cartoon__shine {
    left: 200%;
}

/* Ensure inner contents sit above highlight */
.btn-cartoon > span,
.btn-cartoon > i,
.btn-cartoon > svg {
    position: relative;
    z-index: 2;
}

/* Size Modifiers */
.btn-cartoon--sm {
    height: 38px;
    padding: 0 16px;
    font-size: 13px;
    gap: 6px;
}
.btn-cartoon--sm:hover {
    transform: translateY(-3px);
    box-shadow: 0 3px 0 0 #262626 !important;
}

.btn-cartoon--lg {
    height: 56px;
    padding: 0 32px;
    font-size: 18px;
    gap: 10px;
}
.btn-cartoon--lg:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 0 0 #262626 !important;
}

/* Color Variants */
.btn-cartoon--white {
    background-color: #ffffff !important;
    color: #1e293b !important;
}

.btn-cartoon--emerald {
    background-color: #34d399 !important; /* emerald-400 */
    color: #064e3b !important;
}

.btn-cartoon--orange {
    background-color: #fb923c !important; /* orange-400 */
    color: #431407 !important;
}

.btn-cartoon--purple {
    background-color: #c084fc !important; /* purple-400 */
    color: #3b0764 !important;
}

.btn-cartoon--sky {
    background-color: #38bdf8 !important; /* sky-400 */
    color: #082f49 !important;
}

.btn-cartoon--rose {
    background-color: #fb7185 !important; /* rose-400 */
    color: #4c0519 !important;
}

.btn-cartoon--amber {
    background-color: #fcd34d !important; /* amber-300 */
    color: #451a03 !important;
}

