/* Spinner */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: #25a9e0;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Product card hover */
.product-card {
    position: relative;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Badge */
.badge-erp {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 9999px;
    background: rgba(245, 158, 11, 0.15);
    color: #b45309;
    backdrop-filter: blur(4px);
}
.badge-local {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 9999px;
    background: rgba(37, 169, 224, 0.15);
    color: #196f95;
    backdrop-filter: blur(4px);
}

/* Upload overlay on card */
.upload-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(2px);
    z-index: 10;
}
.upload-overlay.active {
    display: flex;
}

/* Drop zone overlay */
.drop-zone-overlay {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(234, 246, 253, 0.95);
    border: 3px dashed #25a9e0;
    border-radius: 12px;
    z-index: 10;
}
.drop-zone-overlay.active {
    display: flex;
}

/* Toast animation */
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}
.toast {
    animation: slideIn 0.3s ease forwards;
}
.toast.removing {
    animation: slideOut 0.3s ease forwards;
}

/* Lightbox */
#lightbox {
    transition: opacity 0.2s ease;
}
#lightbox.show {
    display: flex;
}

/* Status badges */
.status-active {
    background: #dcfce7;
    color: #166534;
}
.status-new {
    background: #dbeafe;
    color: #1e40af;
}

/* Nav action buttons */
.nav-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

/* Filter buttons — pill/chip style. Inactive pills carry a light fill + border
   so they clearly read as tappable, not plain text. */
.filter-btn {
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 999px;
    background: #f1f5f9;
    border: 1px solid transparent;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.filter-btn:hover {
    background: #e2e8f0;
    color: #334155;
}
.filter-btn.active {
    background: #eaf6fd;
    color: #1d8bba;
    border-color: #a9ddf3;
    font-weight: 600;
}

/* Filter row label — fixed width so every group's controls line up.
   Wide enough for the longest column-name label (PSALESTATUS / SUBCATEGORY);
   nowrap so it never wraps or gets clipped. */
.filter-label {
    width: 112px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: visible;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
}

/* Styled dropdown for หมวด / หมวดย่อย — custom chevron, matches pill height */
.filter-select {
    font-size: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 5px 32px 5px 12px;
    background-color: #f8fafc;
    color: #334155;
    cursor: pointer;
    outline: none;
    transition: all 0.15s ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 220px;
    max-width: 320px;
}
.filter-select:hover {
    border-color: #cbd5e1;
    background-color: #fff;
}
.filter-select:focus {
    border-color: #47b7e7;
    background-color: #fff;
    box-shadow: 0 0 0 3px #d0edfa;
}

/* Sale status badges */
.sale-a { background: #dcfce7; color: #166534; }
.sale-b { background: #dbeafe; color: #1e40af; }
.sale-c { background: #fef9c3; color: #854d0e; }
.sale-clearance { background: #fee2e2; color: #991b1b; }

/* ── View-only role: hide add/edit/delete controls ──
   (server also enforces 403; this hides the affordances from viewers) */
html[data-role="viewer"] [onclick*="deleteAllImages"],
html[data-role="viewer"] [onclick*="deleteSlotImage"],
html[data-role="viewer"] [onclick*="deleteSingleImage"],
html[data-role="viewer"] [onclick*="triggerExtraUpload"],
html[data-role="viewer"] [onchange*="setSlot"],
html[data-role="viewer"] [onclick*="openMapModal"],
html[data-role="viewer"] [onclick*="doMap"],
html[data-role="viewer"] [onclick*="deleteOrphan"] {
  display: none !important;
}
/* Empty upload slots: keep the placeholder box + label, drop the "+" add affordance */
html[data-role="viewer"] [onclick*="triggerSlotUpload"] {
  pointer-events: none !important;
  cursor: default !important;
}
html[data-role="viewer"] [onclick*="triggerSlotUpload"] svg { display: none !important; }
html[data-role="viewer"] [onclick*="triggerSlotUpload"]:hover {
  border-color: rgb(226 232 240) !important;
  background: transparent !important;
  color: rgb(203 213 225) !important;
}
/* Hide the "ลากรูปมาวางได้" hint on the extra-images section for viewers */
html[data-role="viewer"] .extra-drop-zone .text-slate-400 { display: none !important; }

/* ── Mobile responsive (≤640px) ── */
@media (max-width: 640px) {
  /* หมวด/หมวดย่อย เดิมกว้างคงที่ 220–320px → ล้นขอบจอ. ให้แต่ละแถวเต็มกว้าง
     แล้ว select ยืดเติมพื้นที่ที่เหลือ (min-width:0 = ยอมให้หดได้) */
  #catFilter, #subcatFilter { width: 100%; }
  .filter-select { min-width: 0; max-width: 100%; flex: 1 1 auto; }
}
