/**
 * Classroom Popup - Popup Styles
 *
 * Styles for content popup modal (frontend)
 */

/* Overlay */
.classroom-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    animation: cpFadeIn 0.3s ease;
}

@keyframes cpFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Modal */
.classroom-popup-modal {
    background: #fff;
    border-radius: 12px;
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: cpSlideUp 0.3s ease;
}

@keyframes cpSlideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Header */
.classroom-popup-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #FFD54F 0%, #FCAF17 100%);
    border-radius: 12px 12px 0 0;
}

.classroom-popup-header h2 {
    margin: 0;
    font-size: 20px;
    color: #fff;
    font-weight: 600;
}

.classroom-popup-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #fff;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: all 0.2s;
    font-weight: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}

.classroom-popup-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Body */
.classroom-popup-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    color: #333;
}

/* Content Styling */
.classroom-popup-body p {
    margin-bottom: 16px;
}

.classroom-popup-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 16px 0;
}

.classroom-popup-body a {
    color: #FCAF17;
    text-decoration: underline;
}

.classroom-popup-body a:hover {
    color: #F59E0B;
}

.classroom-popup-body h1,
.classroom-popup-body h2,
.classroom-popup-body h3,
.classroom-popup-body h4 {
    margin-top: 24px;
    margin-bottom: 12px;
    color: #2c3e50;
}

.classroom-popup-body ul,
.classroom-popup-body ol {
    margin: 16px 0;
    padding-left: 24px;
}

.classroom-popup-body li {
    margin-bottom: 8px;
}

.classroom-popup-body blockquote {
    margin: 16px 0;
    padding: 16px 20px;
    background: #f8f9fa;
    border-left: 4px solid #FCAF17;
    border-radius: 4px;
}

/* Footer */
.classroom-popup-footer {
    padding: 16px 24px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
    display: flex;
    justify-content: center;
    gap: 12px;
}

.classroom-popup-continue {
    background: linear-gradient(135deg, #FFD54F 0%, #FCAF17 100%);
    color: #fff;
    border: none;
    padding: 12px 32px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(252, 175, 23, 0.4);
}

.classroom-popup-continue:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(252, 175, 23, 0.5);
}

.classroom-popup-continue:active {
    transform: translateY(0);
}

/* Body scroll lock */
body.classroom-popup-active {
    overflow: hidden;
}

/* Responsive */
@media screen and (max-width: 600px) {
    .classroom-popup-modal {
        width: 95%;
        max-height: 90vh;
        border-radius: 8px;
    }

    .classroom-popup-header {
        padding: 16px;
        border-radius: 8px 8px 0 0;
    }

    .classroom-popup-header h2 {
        font-size: 18px;
    }

    .classroom-popup-body {
        padding: 16px;
        font-size: 15px;
    }

    .classroom-popup-footer {
        padding: 12px 16px;
        border-radius: 0 0 8px 8px;
    }

    .classroom-popup-continue {
        width: 100%;
        padding: 14px;
    }
}

/* ============================================
   Pre-rendered shortcode panels
   ============================================
   popup ที่มี shortcode (เช่น [ninja_form id=5]) ถูก render ไว้ตั้งแต่โหลดหน้า
   ในกล่องนี้ เพื่อให้ปลั๊กอินเจ้าของ shortcode ได้ enqueue asset และ bootstrap
   JS ของตัวเองตามปกติ (Ninja Forms ผูกกับ DOMContentLoaded ซึ่งยิงครั้งเดียว)

   ใช้การซ่อนแบบ "ย้ายออกนอกจอ" ไม่ใช่ display:none
   เพราะสคริปต์ที่ต้องวัดขนาด (reCAPTCHA, datepicker, star rating)
   จะคำนวณผิดถ้าถูก render ในกล่องที่ display:none
*/
.classroom-popup-prerender {
    position: absolute;
    left: -99999px;
    top: 0;
    width: 640px;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}

/* panel ที่ถูกย้ายเข้ามาใน modal แล้ว ต้องกลับมาแสดงผลปกติ */
.classroom-popup-body .classroom-popup-panel {
    pointer-events: auto;
}

/* ============================================
   ฟอร์มที่อยู่ใน popup
   ============================================ */
.classroom-popup-body .nf-form-cont,
.classroom-popup-body .ninja-forms-form-wrap {
    max-width: 100%;
}

.classroom-popup-body .nf-form-title h3 {
    margin-top: 0;
}

.classroom-popup-body .nf-field-container {
    margin-bottom: 14px;
}

.classroom-popup-body .nf-field-element input[type="text"],
.classroom-popup-body .nf-field-element input[type="email"],
.classroom-popup-body .nf-field-element input[type="tel"],
.classroom-popup-body .nf-field-element input[type="number"],
.classroom-popup-body .nf-field-element select,
.classroom-popup-body .nf-field-element textarea {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* ปุ่ม submit ของฟอร์มไม่ควรโดน style ลิงก์ของ popup body */
.classroom-popup-body .nf-field-element input[type="button"],
.classroom-popup-body .nf-field-element input[type="submit"] {
    cursor: pointer;
}

/* ============================================
   โหมดบังคับตอบแบบฟอร์มก่อนปิด
   ============================================
   สถานะปกติ: ซ่อนข้อความเตือนและปุ่มข้าม
   .classroom-popup-locked        = ยังตอบไม่เสร็จ ซ่อนทางออกทั้งหมด
   .classroom-popup-escape-hatch  = ล็อกค้างเกิน 60 วิ โผล่ปุ่มข้ามให้
*/
.classroom-popup-lock-notice,
.classroom-popup-skip {
    display: none;
}

.classroom-popup-footer {
    flex-direction: column;
    align-items: center;
}

.classroom-popup-locked .classroom-popup-close,
.classroom-popup-locked .classroom-popup-continue {
    display: none;
}

.classroom-popup-locked .classroom-popup-lock-notice {
    display: block;
    margin: 0;
    padding: 4px 0;
    font-size: 15px;
    font-weight: 600;
    color: #b45309;
    text-align: center;
}

.classroom-popup-escape-hatch .classroom-popup-skip {
    display: inline-block;
    margin-top: 4px;
    background: none;
    border: none;
    padding: 6px 12px;
    font-size: 14px;
    color: #6b7280;
    text-decoration: underline;
    cursor: pointer;
}

.classroom-popup-escape-hatch .classroom-popup-skip:hover {
    color: #374151;
}

/* ล็อกอยู่ = กันปิดด้วยการคลิกพื้นหลังโดยไม่ตั้งใจ */
.classroom-popup-locked {
    cursor: default;
}
