*{
    margin:0;
    padding:0;
    box-sizing:border-box;
    font-family:"Segoe UI",Tahoma,sans-serif;
}

body{
    background:#f4f7fb;
    color:#222;
}

.container{
    width:min(1200px,95%);
    margin:30px auto;
}

header{
    text-align:center;
    margin-bottom:25px;
}

header h1{
    font-size:34px;
    color:#2563eb;
}

header p{
    color:#666;
    margin-top:8px;
}

.toolbar{
    display:flex;
    gap:10px;
    margin-bottom:18px;
}

.toolbar input{
    flex:1;
    padding:14px;
    border:1px solid #ddd;
    border-radius:10px;
    font-size:16px;
}

.toolbar input:focus{
    outline:none;
    border-color:#2563eb;
    box-shadow:0 0 0 3px rgba(37,99,235,.15);
}

.toolbar button{
    padding:14px 24px;
    border:none;
    border-radius:10px;
    background:#2563eb;
    color:#fff;
    font-size:16px;
    cursor:pointer;
    transition:.2s;
}

.toolbar button:hover{
    background:#1d4ed8;
}

.toolbar button:disabled{
    opacity:.6;
    cursor:not-allowed;
}

.filters{
    display:flex;
    gap:15px;
    margin-bottom:20px;
}

.filters select{
    flex:1;
    padding:12px;
    border-radius:10px;
    border:1px solid #ddd;
    background:white;
    font-size:15px;
}

.status-panel{
    display:grid;
    grid-template-columns:repeat(2,1fr);
}

.status-panel div{
    background:white;
    padding:18px;
    border-radius:12px;
    box-shadow:0 2px 8px rgba(0,0,0,.08);
}

.status-panel strong{
    display:block;
    color:#666;
    margin-bottom:6px;
}

#scanStatus.scanning{
    color:#f59e0b;
    font-weight:bold;
}

#scanStatus.ready{
    color:#10b981;
    font-weight:bold;
}

.message{
    min-height:24px;
    margin-bottom:15px;
    color:#444;
}

.message.success{
    color:#16a34a;
}

.message.error{
    color:#dc2626;
}

.result-count{
    font-weight:bold;
    margin-bottom:15px;
}

.results{
    display:grid;
    gap:18px;
}

.results.empty{
    text-align:center;
    color:#666;
    padding:30px;
}

.file-card{
    display:flex;
    justify-content:space-between;
    gap:20px;
    align-items:flex-start;
    background:white;
    padding:18px;
    border-radius:14px;
    box-shadow:0 3px 10px rgba(0,0,0,.08);
    transition:.2s;
}

.file-card:hover{
    transform:translateY(-2px);
}

.file-left{
    flex:1;
}

.file-title{
    display:flex;
    align-items:center;
    gap:10px;
    font-size:18px;
    font-weight:700;
    margin-bottom:8px;
}

.file-icon{
    font-size:24px;
}

.file-meta{
    display:flex;
    flex-wrap:wrap;
    gap:8px;
    margin-bottom:10px;
    color:#666;
    font-size:14px;
}

.badge{
    background:#2563eb;
    color:white;
    padding:4px 10px;
    border-radius:20px;
    font-size:12px;
}

.badge.pdf{
    background:#ea580c !important;   /* PDF สีส้มแดง */
}

.badge.word{
    background:#2563eb;   /* WORD สีเดิม */
}

.category{
    background:#10b981;
}

.badge.subcategory{
    background:#0d9488;   /* เขียวอมฟ้า ต่างจาก category เพื่อแยกให้เห็นชัด */
}

.file-path{
    color:#888;
    font-size:13px;
    margin-bottom:10px;
}


.download-btn{
    align-self:center;
    text-decoration:none;
    background:#2563eb;
    color:white;
    padding:10px 18px;
    border-radius:8px;
    white-space:nowrap;
}

.download-btn:hover{
    background:#1d4ed8;
}

@media(max-width:768px){

.status-panel{
    grid-template-columns:1fr;
}

.toolbar{
    flex-direction:column;
}

.filters{
    flex-direction:column;
}

.file-card{
    flex-direction:column;
}

.download-btn{
    width:100%;
    text-align:center;
}

}
.file-actions{
    display:flex;
    gap:10px;
    margin-top:10px;
}

.preview-btn,
.download-btn{
    display:inline-block;
    padding:8px 14px;
    border-radius:6px;
    text-decoration:none;
    color:#fff;
    background:#1976d2;
}

.download-btn{
    background:#2e7d32;
}

.preview-btn:hover{
    background:#1565c0;
}

.download-btn:hover{
    background:#1b5e20;
}
.preview-box{

    white-space:pre-wrap;

    word-break:break-word;

    border:1px solid #ddd;

    border-radius:8px;

    background:#fafafa;

    padding:16px;

    min-height:250px;

    line-height:1.6;

    overflow:auto;

    font-family:Arial,sans-serif;

}

#info{

    margin-bottom:20px;

}

#info p{

    margin:8px 0;

}
#viewer{

    background:#ddd;
    padding:20px;
    text-align:center;

}

#wordViewer{

    text-align:left;
    font-size:16px;
    font-family:"TH Sarabun New",sans-serif;

}
/* ==========================
   Category Mega-menu Dropdown
========================== */

.category-dropdown{
    position:relative;
    flex:1;
}

.category-dropdown-btn{
    width:100%;
    padding:12px 14px;
    border-radius:10px;
    border:1px solid #ddd;
    background:white;
    font-size:15px;
    text-align:left;
    cursor:pointer;
    display:flex;
    align-items:center;
    justify-content:space-between;
    color:#222;
    transition:.15s;
}

.category-dropdown-btn:hover{
    border-color:#2563eb;
}

.category-dropdown-btn .chevron{
    color:#888;
    margin-left:8px;
    transition:transform .15s;
}

.category-dropdown-panel.open + .category-dropdown-btn .chevron,
.category-dropdown-btn.open .chevron{
    transform:rotate(180deg);
}

.category-dropdown-panel{
    display:none;
    position:absolute;
    top:calc(100% + 6px);
    left:0;
    width:min(560px, 90vw);
    background:white;
    border-radius:12px;
    box-shadow:0 10px 28px rgba(0,0,0,.2);
    overflow:hidden;
    z-index:50;
}

.category-dropdown-panel.open{
    display:flex;
}

.category-dropdown-left{
    width:38%;
    background:#f4f7fb;
    max-height:360px;
    overflow-y:auto;
    border-right:1px solid #e5e7eb;
}

.category-dropdown-right{
    width:62%;
    max-height:360px;
    overflow-y:auto;
    padding:6px 0;
}

.category-dropdown-item{
    padding:12px 16px;
    cursor:pointer;
    font-size:14.5px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    color:#333;
    border-bottom:1px solid rgba(0,0,0,.05);
    transition:.12s;
}

.category-dropdown-left .category-dropdown-item.active,
.category-dropdown-left .category-dropdown-item:hover{
    background:#2563eb;
    color:white;
}

.category-dropdown-left .category-dropdown-item .arrow{
    opacity:.75;
    font-size:16px;
}

.category-dropdown-left .category-dropdown-item.all-categories{
    font-weight:600;
    border-bottom:1px solid #ddd;
}

.category-dropdown-right .category-dropdown-item:hover{
    background:#eef2ff;
    color:#1d4ed8;
}

.category-dropdown-right .all-in-category{
    font-weight:600;
    color:#2563eb;
}

@media(max-width:768px){

    .category-dropdown-panel.open{
        flex-direction:column;
        width:92vw;
    }

    .category-dropdown-left,
    .category-dropdown-right{
        width:100%;
        max-height:220px;
    }

}

/* Breadcrumb + ปุ่มย้อนกลับ สำหรับเจาะลึกหมวดหมู่ย่อยหลายชั้น */
.category-dropdown-breadcrumb{
    padding:10px 16px;
    background:#f4f7fb;
    border-bottom:1px solid #e5e7eb;
    display:flex;
    align-items:center;
    gap:10px;
    font-size:13px;
    color:#555;
    position:sticky;
    top:0;
}

.category-dropdown-breadcrumb .back-btn{
    color:#2563eb;
    font-weight:600;
    cursor:pointer;
    white-space:nowrap;
}

.category-dropdown-breadcrumb .back-btn:hover{
    text-decoration:underline;
}

.category-dropdown-breadcrumb .breadcrumb-text{
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}

/* Focus visibility สำหรับ mega-menu (คีย์บอร์ด) */
.category-dropdown-item:focus-visible{
    outline:2px solid #2563eb;
    outline-offset:-2px;
    background:#eef2ff;
}

.category-dropdown-btn:focus-visible{
    outline:2px solid #2563eb;
    outline-offset:2px;
}

/* ==========================
   Product Manual (คู่มือสินค้า)
========================== */

.manual-btn{
    display:inline-block;
    padding:8px 14px;
    border-radius:6px;
    text-decoration:none;
    color:#fff;
    background:#7c3aed;   /* ม่วง แยกจาก preview (ฟ้า) และดาวน์โหลด (เขียว) */
}

.manual-btn:hover{
    background:#6d28d9;
}

.badge.manual{
    background:#7c3aed;
}