/* =========================================================
   buddyth_ ADMIN THEME (LIGHT) + SIDEBAR
   ใช้กับหน้า admin/settings, admin/laws ฯลฯ
   ========================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --buddyth-bg: #f3f6ff;
    --buddyth-bg-soft: #e5edff;
    --buddyth-card-bg: #ffffff;
    --buddyth-border-soft: #e2e8f0;
    --buddyth-border-strong: #cbd5f5;
    --buddyth-shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.10);
    --buddyth-primary: #2563eb;
    --buddyth-primary-soft: #dbeafe;
    --buddyth-primary-strong: #1d4ed8;
    --buddyth-text: #0f172a;
    --buddyth-text-soft: #6b7280;
    --buddyth-radius-lg: 22px;
    --buddyth-radius-md: 16px;
    --buddyth-radius-sm: 10px;
    --buddyth-transition-fast: 0.18s ease-out;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: "Kanit", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top left, #e0edff 0, #f8fbff 40%, #eef2ff 100%);
    color: var(--buddyth-text);
}

/* =========================================================
   MAIN SHELL + SIDEBAR LAYOUT
   ========================================================= */

/* ตัวครอบทั้ง admin */
.buddyth_shell {
    min-height: 100vh;
    display: flex;
    background: transparent;
}

/* SIDEBAR (desktop) */
.buddyth_sidebar {
    position: sticky;
    top: 0;
    left: 0;
    height: 100vh;
    flex: 0 0 250px;
    background: rgba(255,255,255,0.98);
    border-right: 1px solid rgba(209,213,219,0.9);
    box-shadow: 12px 0 45px rgba(148,163,184,0.18);
    padding: 18px 14px;
    z-index: 30;
    display: flex;
    flex-direction: column;
}

/* toggle สำหรับ mobile */
.buddyth_sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 40;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: none;
    background: #2563eb;
    color: #fff;
    box-shadow: 0 14px 35px rgba(37,99,235,0.6);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

/* ส่วนเนื้อหาหลัก */
.buddyth_main {
    flex: 1;
    min-width: 0;
    padding: 26px 24px 28px;
}


/* =========================================================
   SIDEBAR MENU
   ========================================================= */

.buddyth_sidebar-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #9ca3af;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.buddyth_sidebar-title i {
    font-size: 14px;
}

.buddyth_menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.buddyth_menu-item + .buddyth_menu-item {
    margin-top: 4px;
}

.buddyth_menu-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 999px;
    font-size: 13px;
    text-decoration: none;
    color: #4b5563;
    transition: background-color var(--buddyth-transition-fast),
                color var(--buddyth-transition-fast),
                transform var(--buddyth-transition-fast),
                box-shadow var(--buddyth-transition-fast);
}

.buddyth_menu-icon {
    width: 20px;
    text-align: center;
    font-size: 14px;
}

.buddyth_menu-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #e5e7eb;
}

.buddyth_menu-text {
    flex: 1;
    white-space: nowrap;
}

.buddyth_menu-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
}

.buddyth_menu-link:hover {
    background: #eff6ff;
    color: #1d4ed8;
    transform: translateX(2px);
}

.buddyth_menu-link.buddyth_active {
    background: linear-gradient(to right,#2563eb,#4f46e5);
    color: #f9fafb;
}

.buddyth_menu-link.buddyth_active .buddyth_menu-badge {
    background: rgba(15,23,42,0.15);
    color: #e5e7eb;
}

/* logo/brand ด้านบน sidebar (จะใช้หรือไม่ใช้ก็ได้) */
.buddyth_sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.buddyth_sidebar-brand-icon {
    width: 32px;
    height: 32px;
    border-radius: 12px;
    background: #2563eb;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.buddyth_sidebar-brand-text {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

/* =========================================================
   PAGE HEADER + CHIPS
   ========================================================= */

.buddyth_page-header {
    margin-bottom: 20px;
}

.buddyth_page-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 24px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 4px;
}

.buddyth_page-title i {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #1d4ed8;
    color: white;
}

.buddyth_page-subtitle {
    margin: 0;
    font-size: 13px;
    color: var(--buddyth-text-soft);
}

/* chips ด้านบน */
.buddyth_chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.buddyth_status-chip {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    font-size: 12px;
    color: #4b5563;
}

.buddyth_status-chip-count {
    padding: 2px 8px;
    border-radius: 999px;
    background: #4f46e5;
    color: white;
    font-weight: 600;
}

/* flash message */
.buddyth_flash {
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.buddyth_flash-success {
    background: #dcfce7;
    color: #166534;
}

.buddyth_flash-error {
    background: #fee2e2;
    color: #b91c1c;
}

/* =========================================================
   OVERVIEW CARDS
   ========================================================= */

.buddyth_overview-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 16px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.buddyth_overview-card {
    background: rgba(255, 255, 255, 0.96);
    border-radius: var(--buddyth-radius-lg);
    padding: 14px 16px 12px;
    border: 1px solid rgba(209, 213, 219, 0.7);
}

.buddyth_overview-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
    margin-bottom: 4px;
}

.buddyth_overview-value {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 4px;
}

.buddyth_overview-sub {
    font-size: 12px;
    color: #9ca3af;
}

/* =========================================================
   MAIN MENU CARDS
   ========================================================= */

.buddyth_main-menu {
    margin-bottom: 22px;
}

.buddyth_main-menu-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 14px;
}

.buddyth_menu-card {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 14px 12px;
    text-decoration: none;
    color: inherit;
    background: linear-gradient(135deg, #ffffff 0%, #f5f7ff 40%, #edf2ff 100%);
    border-radius: var(--buddyth-radius-lg);
    border: 1px solid rgba(199, 210, 254, 0.9);
   /* box-shadow: 0 20px 45px rgba(148, 163, 184, 0.25);*/
    transition: transform var(--buddyth-transition-fast),
                box-shadow var(--buddyth-transition-fast),
                border-color var(--buddyth-transition-fast),
                background 0.25s ease-out;
}

.buddyth_menu-card:hover {
    transform: translateY(-4px);
    background: linear-gradient(135deg,#eff6ff 0%,#e0ecff 50%,#eef2ff 100%);
}

.buddyth_menu-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.buddyth_menu-card-icon {
    width: 32px;
    height: 32px;
    border-radius: 12px;
    background: #e0ebff;
    color: #1d4ed8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.buddyth_menu-card-title {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}

.buddyth_menu-card-desc {
    font-size: 12px;
    color: #6b7280;
    margin: 0 0 4px;
}

.buddyth_menu-card-stat {
    font-size: 11px;
    color: #4b5563;
}

.buddyth_menu-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
}

.buddyth_menu-card-chip {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.08);
    color: #1d4ed8;
}

.buddyth_menu-card-arrow {
    font-size: 11px;
    color: #1e40af;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* =========================================================
   PANEL + SETTINGS FORM
   ========================================================= */

.buddyth_panel {
    margin-top: 6px;
    background: rgba(255,255,255,0.98);
    border-radius: 26px;
    border: 1px solid rgba(209,213,219,0.8);
    overflow: hidden;
}

.buddyth_panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px 18px 10px;
    border-bottom: 1px solid rgba(226,232,240,0.9);
    background: linear-gradient(135deg, #eff6ff 0%, #eef2ff 100%);
}

.buddyth_panel-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
}

.buddyth_panel-title i {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: #2563eb;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.buddyth_panel-sub {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}

.buddyth_panel-body {
    padding: 18px 18px 16px;
}

.buddyth_settings-form {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

/* section ในฟอร์ม */
.buddyth_settings-section {
    padding: 12px 12px 14px;
    border-radius: 18px;
    border: 1px dashed rgba(203,213,225,0.9);
    background: #f9fafb;
}

.buddyth_settings-section-title {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.buddyth_settings-section-title i {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: #e0ecff;
    color: #1d4ed8;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* grid 2 คอลัมน์ */
.buddyth_settings-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 14px;
    margin-bottom: 10px;
}

.buddyth_settings-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.buddyth_settings-field label {
    font-size: 12px;
    color: #4b5563;
}

.buddyth_settings-field input[type="text"],
.buddyth_settings-field input[type="password"],
.buddyth_settings-field input[type="number"],
.buddyth_settings-field input[type="url"],
.buddyth_settings-field input[type="email"],
.buddyth_settings-field input[type="tel"],
.buddyth_settings-field input[type="date"],
.buddyth_settings-field input[type="datetime-local"],
.buddyth_settings-field input[type="time"],
.buddyth_settings-field input[type="search"],
.buddyth_settings-field select,
.buddyth_settings-field textarea {
    border-radius: 12px;
    border: 1px solid #d1d5db;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    background: white;
    color: #111827;
    width: 100%;
    box-sizing: border-box;
    transition: border-color var(--buddyth-transition-fast),
                box-shadow var(--buddyth-transition-fast),
                background-color var(--buddyth-transition-fast);
}

.buddyth_settings-field input[type="text"]:focus,
.buddyth_settings-field input[type="password"]:focus,
.buddyth_settings-field input[type="number"]:focus,
.buddyth_settings-field input[type="url"]:focus,
.buddyth_settings-field input[type="email"]:focus,
.buddyth_settings-field input[type="tel"]:focus,
.buddyth_settings-field input[type="date"]:focus,
.buddyth_settings-field input[type="datetime-local"]:focus,
.buddyth_settings-field input[type="time"]:focus,
.buddyth_settings-field input[type="search"]:focus,
.buddyth_settings-field select:focus,
.buddyth_settings-field textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 1px rgba(37,99,235,0.35);
    background: #f9fbff;
}

.buddyth_settings-field textarea {
    min-height: 70px;
    resize: vertical;
}

.buddyth_help-text {
    font-size: 11px;
    color: #9ca3af;
}

/* checkbox fields */
.buddyth_checkbox-field {
    justify-content: center;
}

.buddyth_checkbox-field label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #374151;
}

.buddyth_checkbox-field input[type="checkbox"] {
    width: 15px;
    height: 15px;
}

/* ปุ่มบันทึก */
.buddyth_settings-submit {
    margin-top: 4px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.buddyth_btn-primary,
.buddyth_btn-secondary {
    border-radius: 999px;
    border: none;
    font-size: 13px;
    padding: 7px 16px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    font-family: inherit;
}

.buddyth_btn-primary {
    background: linear-gradient(to right, #2563eb, #4f46e5);
    color: white;
    box-shadow: 0 16px 35px rgba(37,99,235,0.4);
}

.buddyth_btn-primary:hover {
    background: linear-gradient(to right, #1d4ed8, #4338ca);
}

.buddyth_btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.buddyth_btn-secondary:hover {
    background: #d1d5db;
}

/* =========================================================
   RESPONSIVE + COLLAPSE BEHAVIOUR
   ========================================================= */

/* 1) Tablet: sidebar แคบลง เหลือ icon + text หดลง */
@media (max-width: 1024px) {
    .buddyth_sidebar {
        flex: 0 0 76px;
        padding-inline: 10px;
    }

    .buddyth_menu-text {
        display: none;
    }

    .buddyth_sidebar-brand-text {
        display: none;
    }

    .buddyth_main {
        padding: 24px 18px 26px;
    }

    .buddyth_overview-grid {
        grid-template-columns: repeat(2, minmax(0,1fr));
    }

    .buddyth_main-menu-grid {
        grid-template-columns: repeat(2, minmax(0,1fr));
    }
}

/* 2) Mobile: sidebar เป็น overlay พับ/เปิดได้ */
@media (max-width: 768px) {
    .buddyth_shell {
        padding-left: 0;
    }

    .buddyth_sidebar {
        position: fixed;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform var(--buddyth-transition-fast);
        width: 240px;
        flex: 0 0 auto;
        border-right: 1px solid rgba(148,163,184,0.9);
    }

    /* max-width:1024px ด้านบนซ่อน .buddyth_menu-text ไว้สำหรับโหมด tablet (icon-only)
       แต่ query นั้นครอบคลุมจอมือถือด้วย (max-width ไม่ exclusive กัน) ทำให้ข้อความ
       เมนูหายไปแม้ sidebar จะกางเต็ม 240px พอแสดงข้อความได้แล้วก็ตาม — เปิดกลับที่นี่ */
    .buddyth_menu-text,
    .buddyth_sidebar-brand-text {
        display: inline;
    }

    /* เมื่อมี class buddyth_sidebar-open ที่ shell → แสดง */
    .buddyth_shell.buddyth_sidebar-open .buddyth_sidebar {
        transform: translateX(0);
    }

    .buddyth_sidebar-toggle {
        display: inline-flex;
    }

    .buddyth_main {
        padding: 22px 12px 24px;
        width: 100%;
    }

    .buddyth_page-container {
        max-width: 100%;
    }

    .buddyth_overview-grid,
    .buddyth_main-menu-grid,
    .buddyth_settings-grid-2 {
        grid-template-columns: minmax(0,1fr);
    }

    .buddyth_panel {
        border-radius: 18px;
    }
}

.buddyth_confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.28);
    backdrop-filter: blur(3px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 9999;
}

.buddyth_confirm-overlay.show {
    display: flex;
}

.buddyth_confirm-modal {
    width: 100%;
    max-width: 760px;
    background: #f8f8f8;
    border-radius: 22px;
    box-shadow: 0 30px 80px rgba(15, 23, 42, 0.22);
    border: 1px solid rgba(209, 213, 219, 0.9);
    overflow: hidden;
    animation: buddythConfirmPop 0.18s ease-out;
}

@keyframes buddythConfirmPop {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.buddyth_confirm-body {
    padding: 22px 22px 14px;
}

.buddyth_confirm-title {
    margin: 0 0 12px;
    font-size: 28px;
    line-height: 1.25;
    font-weight: 700;
    color: #111827;
}

.buddyth_confirm-text {
    margin: 0 0 8px;
    font-size: 18px;
    line-height: 1.7;
    color: #111827;
}

.buddyth_confirm-subtext {
    margin: 0;
    font-size: 15px;
    line-height: 1.8;
    color: #9ca3af;
}

.buddyth_confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 14px;
    padding: 16px 22px 22px;
}

.buddyth_confirm-cancel,
.buddyth_confirm-delete {
    min-width: 92px;
    height: 52px;
    border-radius: 999px;
    border: none;
    font-family: inherit;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.18s ease-out;
}

.buddyth_confirm-cancel {
    background: #f3f4f6;
    color: #111827;
    border: 1px solid #d1d5db;
}

.buddyth_confirm-cancel:hover {
    background: #e5e7eb;
}

.buddyth_confirm-delete {
    background: #e62b28;
    color: #fff;
    box-shadow: 0 14px 30px rgba(230, 43, 40, 0.28);
}

.buddyth_confirm-delete:hover {
    background: #cf211e;
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .buddyth_confirm-modal {
        max-width: 100%;
        border-radius: 18px;
    }

    .buddyth_confirm-title {
        font-size: 22px;
    }

    .buddyth_confirm-text {
        font-size: 16px;
    }

    .buddyth_confirm-subtext {
        font-size: 14px;
    }

    .buddyth_confirm-cancel,
    .buddyth_confirm-delete {
        min-width: 84px;
        height: 46px;
        font-size: 16px;
    }
}