/**
 * MYPX — Tabs Plugin styles (admin + frontend)
 */

.mypx-tabs {
    margin: 1.5rem 0;
    font-size: 1rem;
}

.mypx-tabs-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 0;
}

.mypx-tabs-btn {
    background: transparent;
    border: 1px solid transparent;
    border-bottom: 0;
    padding: 0.55rem 1rem;
    font-size: 0.95rem;
    color: #4b5563;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    font-weight: 500;
    margin-bottom: -1px;
    line-height: 1.4;
    font-family: inherit;
}

.mypx-tabs-btn:hover {
    color: #111827;
    background: #f9fafb;
}

.mypx-tabs-btn.is-active {
    color: #111827;
    background: #fff;
    border-color: #e5e7eb;
    border-bottom-color: #fff;
}

.mypx-tabs-btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.mypx-tabs-panels {
    padding: 1rem 0.25rem;
}

.mypx-tabs-panel {
    display: none;
    animation: mypxTabFade 0.2s ease;
}

.mypx-tabs-panel.is-active {
    display: block;
}

@keyframes mypxTabFade {
    from { opacity: 0; transform: translateY(2px); }
    to   { opacity: 1; transform: none; }
}

.mypx-tabs-panel > :first-child { margin-top: 0; }
.mypx-tabs-panel > :last-child  { margin-bottom: 0; }

/* style: pills */
.mypx-tabs.is-style-pills .mypx-tabs-nav {
    border-bottom: 0;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}
.mypx-tabs.is-style-pills .mypx-tabs-btn {
    background: #f3f4f6;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.45rem 1rem;
    margin-bottom: 0;
}
.mypx-tabs.is-style-pills .mypx-tabs-btn:hover {
    background: #e5e7eb;
}
.mypx-tabs.is-style-pills .mypx-tabs-btn.is-active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* style: underline */
.mypx-tabs.is-style-underline .mypx-tabs-btn {
    border-radius: 0;
    border: 0;
    border-bottom: 2px solid transparent;
    padding: 0.6rem 0.5rem;
    margin-bottom: -1px;
}
.mypx-tabs.is-style-underline .mypx-tabs-btn.is-active {
    background: transparent;
    color: #2563eb;
    border-bottom-color: #2563eb;
}

/* style: boxed (default ทำอยู่แล้ว) — alias */
.mypx-tabs.is-style-boxed .mypx-tabs-nav {
    border-bottom: 1px solid #e5e7eb;
}
.mypx-tabs.is-style-boxed .mypx-tabs-panels {
    border: 1px solid #e5e7eb;
    border-top: 0;
    padding: 1.1rem 1.25rem;
    border-radius: 0 0 8px 8px;
    background: #fff;
}

/* responsive — overflow horizontal nav if too many tabs */
@media (max-width: 640px) {
    .mypx-tabs-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .mypx-tabs-btn { white-space: nowrap; }
}

/* ── โหมดในตัวแก้ไข Jodit ─────────────────────────────────────────── */
/* ไม่ซ่อน panel — แสดงทุกแถบตอนแก้ไข (กำกับด้วยหัวข้อ) เพื่อให้ authorsเห็นเนื้อหาทุกแถบโดยไม่ต้องคลิกสลับ */
.jodit-wysiwyg .mypx-tabs {
    outline: 1px dashed transparent;
    outline-offset: 4px;
    border-radius: 4px;
    transition: outline-color 0.15s ease, background-color 0.15s ease;
}
.jodit-wysiwyg .mypx-tabs:hover {
    outline-color: #60a5fa;
    background: rgba(239, 246, 255, 0.3);
}
/* hint แถบคลิก — กดตรงแถบนี้ = เปิด modal แก้ไข */
.jodit-wysiwyg .mypx-tabs::before {
    content: "✏ คลิกเพื่อแก้ไขบล็อกแถบ (หรือคลิกที่ชื่อแถบด้านล่าง)";
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #1d4ed8;
    background: #eff6ff;
    border: 1px dashed #93c5fd;
    padding: 0.3rem 0.6rem;
    margin-bottom: 0.4rem;
    border-radius: 4px;
    letter-spacing: 0.02em;
    cursor: pointer;
    text-align: center;
}
.jodit-wysiwyg .mypx-tabs:hover::before {
    background: #dbeafe;
    border-color: #60a5fa;
    color: #1e40af;
}

/* ในตัวแก้ไข: แสดงเนื้อหาทุก panel เรียงลงมา + กำกับชื่อแถบไว้บน panel
   ทำให้ผู้เขียนเห็นเนื้อหาทั้งหมด / กัน "แถบแรกตกหล่น" ไม่เห็น  */
.jodit-wysiwyg .mypx-tabs .mypx-tabs-panel {
    display: block;
    animation: none;
    border: 1px dashed #d1d5db;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-top: 0.5rem;
    position: relative;
}
.jodit-wysiwyg .mypx-tabs .mypx-tabs-panel::before {
    content: attr(data-label);
    display: inline-block;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 11px;
    font-weight: 600;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    margin-bottom: 0.35rem;
    letter-spacing: 0.02em;
}
/* ในตัวแก้ไข: ปุ่มแถบทำหน้าที่ "เปิด modal แก้ไข" (คลิกเดียว) — แสดง cursor pointer
   และ hover สีฟ้าเพื่อสื่อว่าคลิกได้ */
.jodit-wysiwyg .mypx-tabs .mypx-tabs-nav {
    user-select: none;
}
.jodit-wysiwyg .mypx-tabs .mypx-tabs-btn {
    cursor: pointer;
    position: relative;
}
.jodit-wysiwyg .mypx-tabs .mypx-tabs-btn:hover {
    background: #eff6ff;
    color: #1d4ed8;
}
.jodit-wysiwyg .mypx-tabs .mypx-tabs-btn:hover::after {
    content: "แก้ไข";
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    color: #1d4ed8;
    background: #fff;
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    pointer-events: none;
}

/* ── Modal styling ───────────────────────────────────────────────── */
.mypx-tabs-modal .mypx-tabs-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1rem;
    min-height: 440px;
}

@media (max-width: 820px) {
    .mypx-tabs-modal .mypx-tabs-layout {
        grid-template-columns: 1fr;
    }
}

.mypx-tabs-modal .mypx-tabs-sidebar {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-height: 0;
}

.mypx-tabs-modal .mypx-tabs-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    overflow-y: auto;
    max-height: 400px;
    min-height: 0;
    padding-right: 2px;
}

.mypx-tabs-modal .mypx-tabs-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem 0.5rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #374151;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.mypx-tabs-modal .mypx-tabs-item:hover {
    border-color: #93c5fd;
}
.mypx-tabs-modal .mypx-tabs-item.is-active {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 600;
}
.mypx-tabs-modal .mypx-tabs-item-label {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mypx-tabs-modal .mypx-tabs-item-num {
    min-width: 1.5rem;
    font-size: 0.75rem;
    color: #6b7280;
    text-align: right;
}
.mypx-tabs-modal .mypx-tabs-item-actions {
    display: flex;
    gap: 0.1rem;
}
.mypx-tabs-modal .mypx-tabs-item-actions button {
    background: transparent;
    border: 0;
    padding: 0.1rem 0.3rem;
    color: #6b7280;
    cursor: pointer;
    font-size: 0.9rem;
    border-radius: 3px;
}
.mypx-tabs-modal .mypx-tabs-item-actions button:hover {
    background: #e5e7eb;
    color: #111827;
}
.mypx-tabs-modal .mypx-tabs-item-actions button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
.mypx-tabs-modal .mypx-tabs-item-actions .is-del:hover {
    background: #fee2e2;
    color: #b91c1c;
}

.mypx-tabs-modal .mypx-tabs-editor {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}
.mypx-tabs-modal .mypx-tabs-editor-empty {
    color: #6b7280;
    text-align: center;
    padding: 2rem 0;
    font-size: 0.9rem;
}

.mypx-tabs-modal .mypx-tabs-style-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.mypx-tabs-modal .mypx-tabs-style-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    font-size: 0.82rem;
    background: #fff;
    cursor: pointer;
    user-select: none;
    color: #374151;
}
.mypx-tabs-modal .mypx-tabs-style-chip input { display: none; }
.mypx-tabs-modal .mypx-tabs-style-chip.is-on {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #1d4ed8;
    font-weight: 600;
}
