/* ==========================================================================
   Shared Dashboard Filter Language (Super Kaichon Master Filter System)
   Exact match reference: "ประกาศขายของฉัน" (dashboard/self-market.html)
   ========================================================================== */

/* 1. Toolbar Container */
.dashboard-filter-toolbar {
    position: relative;
    z-index: 2;
    width: 100%;
    display: flex !important;
    flex-flow: row wrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    padding: 6px 0 !important;
    margin: 0;
    overflow: visible;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    box-sizing: border-box;
}

/* 2. Expanding Search Circle & Slot */
.dashboard-filter-search-slot {
    position: relative !important;
    flex: 0 0 48px !important;
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    height: 48px !important;
    min-height: 48px !important;
    z-index: 30;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    transition: width 0.3s ease, flex-basis 0.3s ease, max-width 0.3s ease;
}

.dashboard-filter-search-slot:hover,
.dashboard-filter-search-slot:focus-within,
.dashboard-filter-search-slot.is-open {
    flex: 0 0 240px !important;
    flex-basis: 240px !important;
    width: 240px !important;
    max-width: 240px !important;
}

.dashboard-filter-search {
    position: absolute !important;
    inset: 0 auto auto 0 !important;
    display: flex !important;
    align-items: center !important;
    width: 48px !important;
    min-width: 48px !important;
    max-width: none !important;
    height: 48px !important;
    min-height: 48px !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    color: #ffffff !important;
    background: #111111 !important;
    border: 0 !important;
    border-radius: 999px !important;
    box-shadow: 0 8px 20px rgba(17, 17, 17, 0.15) !important;
    transition: width 0.3s ease, background-color 0.2s ease, box-shadow 0.2s ease !important;
}

.dashboard-filter-search-slot:hover .dashboard-filter-search,
.dashboard-filter-search-slot:focus-within .dashboard-filter-search,
.dashboard-filter-search-slot.is-open .dashboard-filter-search {
    width: 240px !important;
    background: #1c1c1c !important;
    box-shadow: 0 10px 24px rgba(17, 17, 17, 0.18) !important;
}

.dashboard-filter-search-button,
#search-btn.dashboard-filter-search-button {
    flex: 0 0 46px !important;
    width: 46px !important;
    min-width: 46px !important;
    height: 46px !important;
    min-height: 46px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: transparent !important;
    color: #ffffff !important;
    cursor: pointer;
    font-size: 15px;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    outline: 0 !important;
}

.dashboard-filter-search-button i {
    font-size: 15px;
    line-height: 1;
    color: #ffffff !important;
}

.dashboard-filter-search input,
.dashboard-filter-search label {
    min-width: 0;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translateX(8px) !important;
    transition: width 0.3s ease, opacity 0.2s ease 0.05s, transform 0.3s ease !important;
}

.dashboard-filter-search-slot:hover input,
.dashboard-filter-search-slot:focus-within input,
.dashboard-filter-search-slot.is-open input,
.dashboard-filter-search-slot:hover label,
.dashboard-filter-search-slot:focus-within label,
.dashboard-filter-search-slot.is-open label {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateX(0) !important;
}

.dashboard-filter-search input {
    display: block !important;
    flex: 1 1 auto !important;
    width: 0 !important;
    height: 46px !important;
    padding: 0 16px 0 2px !important;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    caret-color: #ffffff !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    outline: 0 !important;
    font: inherit;
    font-size: 13px;
}

.dashboard-filter-search-slot:hover input,
.dashboard-filter-search-slot:focus-within input,
.dashboard-filter-search-slot.is-open input {
    width: 180px !important;
}

.dashboard-filter-search input::placeholder {
    color: rgba(255, 255, 255, 0.75) !important;
    -webkit-text-fill-color: rgba(255, 255, 255, 0.75) !important;
    opacity: 1 !important;
}

/* 3. Filter Trigger Capsules */
.dashboard-filter-capsule-field,
.chicken-filter-panel > .filter-field {
    display: inline-flex !important;
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
}

.dashboard-filter-capsule,
[data-custom-dropdown].dashboard-filter-capsule,
.custom-dropdown.dashboard-filter-capsule {
    position: relative !important;
    z-index: 1;
    flex: 0 0 auto !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
    width: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.dashboard-filter-capsule.is-open,
[data-custom-dropdown].dashboard-filter-capsule.is-open,
.custom-dropdown.dashboard-filter-capsule.is-open {
    z-index: 200 !important;
}

/* Master Filter Trigger Button */
.dashboard-filter-capsule > .custom-dropdown-toggle,
.custom-dropdown.dashboard-filter-capsule > .custom-dropdown-toggle {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 44px !important;
    height: 44px !important;
    padding: 0 14px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 999px !important;
    background: #f5f5f5 !important;
    color: #242424 !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    box-shadow: 0 4px 12px rgba(17, 17, 17, 0.04) !important;
    box-sizing: border-box !important;
    white-space: nowrap !important;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease !important;
}

.dashboard-filter-capsule > .custom-dropdown-toggle:hover,
.dashboard-filter-capsule > .custom-dropdown-toggle:focus-visible,
.dashboard-filter-capsule.is-open > .custom-dropdown-toggle,
.custom-dropdown.dashboard-filter-capsule > .custom-dropdown-toggle:hover,
.custom-dropdown.dashboard-filter-capsule > .custom-dropdown-toggle:focus-visible,
.custom-dropdown.dashboard-filter-capsule.is-open > .custom-dropdown-toggle {
    background: #ebebeb !important;
    border-color: #d8d8d8 !important;
    box-shadow: 0 6px 16px rgba(17, 17, 17, 0.08) !important;
    outline: 0 !important;
}

.dashboard-filter-capsule .custom-dropdown-label {
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #242424 !important;
    line-height: 1 !important;
}

.dashboard-filter-capsule .custom-dropdown-chevron {
    flex: 0 0 auto !important;
    font-size: 11px !important;
    color: #6b7280 !important;
    line-height: 1 !important;
    transition: transform 0.2s ease !important;
}

.dashboard-filter-capsule.is-open .custom-dropdown-chevron,
.custom-dropdown.dashboard-filter-capsule.is-open .custom-dropdown-chevron {
    transform: rotate(180deg) !important;
    color: #6b7280 !important;
}

/* 4. Dropdown Menu */
.dashboard-filter-capsule .custom-dropdown-menu,
.custom-dropdown.dashboard-filter-capsule .custom-dropdown-menu {
    position: absolute !important;
    top: calc(100% + 6px) !important;
    left: 0 !important;
    right: auto !important;
    z-index: 300 !important;
    min-width: 170px !important;
    max-width: min(280px, calc(100vw - 28px)) !important;
    max-height: min(280px, calc(100vh - 24px)) !important;
    padding: 6px !important;
    overflow-y: auto !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 16px !important;
    background: #ffffff !important;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.16), 0 2px 8px rgba(15, 23, 42, 0.06) !important;
    box-sizing: border-box !important;
}

.dashboard-filter-capsule .custom-dropdown-menu[hidden],
.custom-dropdown.dashboard-filter-capsule .custom-dropdown-menu[hidden] {
    display: none !important;
}

/* 5. Dropdown Options */
.dashboard-filter-capsule .custom-dropdown-option,
.custom-dropdown.dashboard-filter-capsule .custom-dropdown-option {
    width: 100% !important;
    min-height: 44px !important;
    padding: 10px 14px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: transparent !important;
    color: #374151 !important;
    font: inherit !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    text-align: left !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
    transition: background-color 0.15s ease, color 0.15s ease !important;
}

.dashboard-filter-capsule .custom-dropdown-option:hover,
.dashboard-filter-capsule .custom-dropdown-option:focus-visible,
.custom-dropdown.dashboard-filter-capsule .custom-dropdown-option:hover,
.custom-dropdown.dashboard-filter-capsule .custom-dropdown-option:focus-visible {
    background: #f3f4f6 !important;
    color: #111827 !important;
    outline: 0 !important;
}

.dashboard-filter-capsule .custom-dropdown-option.is-selected,
.dashboard-filter-capsule .custom-dropdown-option[aria-selected="true"],
.custom-dropdown.dashboard-filter-capsule .custom-dropdown-option.is-selected,
.custom-dropdown.dashboard-filter-capsule .custom-dropdown-option[aria-selected="true"] {
    background: #eef7f1 !important;
    color: #166534 !important;
    font-weight: 600 !important;
}

.dashboard-filter-capsule .custom-dropdown-option.is-selected::after,
.dashboard-filter-capsule .custom-dropdown-option[aria-selected="true"]::after,
.custom-dropdown.dashboard-filter-capsule .custom-dropdown-option.is-selected::after,
.custom-dropdown.dashboard-filter-capsule .custom-dropdown-option[aria-selected="true"]::after {
    content: "✓" !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 auto !important;
    margin-left: auto !important;
    color: #166534 !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    line-height: 1 !important;
}

/* 6. Clear Filter Button (Exact visual parity with .reset-filter-btn from MASTER) */
.reset-filter-btn,
.clear-filter-button,
.empty-reset-btn {
    min-height: 40px !important;
    height: 40px !important;
    padding: 0 14px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 7px !important;
    border: 1px solid #e3e9e5 !important;
    border-radius: 10px !important;
    background: #ffffff !important;
    color: #526159 !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    box-shadow: none !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    flex: 0 0 auto !important;
    transition: color 0.18s ease, border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease !important;
}

.reset-filter-btn:hover,
.clear-filter-button:hover,
.empty-reset-btn:hover {
    color: #183f2c !important;
    border-color: #b9c8bf !important;
    background: #f7f9f7 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04) !important;
}

.reset-filter-btn:active,
.clear-filter-button:active,
.empty-reset-btn:active {
    background: #eef3ef !important;
}

.reset-filter-btn:focus-visible,
.clear-filter-button:focus-visible,
.empty-reset-btn:focus-visible {
    outline: 2px solid #183f2c !important;
    outline-offset: 2px !important;
}

.reset-filter-btn i,
.clear-filter-button i,
.empty-reset-btn i {
    font-size: 13px !important;
    line-height: 1 !important;
    color: inherit !important;
}

/* 7. Date filter fields for dashboard pages (sick/vaccine/cost) */
.dashboard-filter-toolbar .dashboard-filter-date-field,
.dashboard-filter-date-field {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 260px !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.dashboard-filter-date-field .thai-datetime-control {
    width: 100% !important;
    min-width: 0 !important;
}

.dashboard-filter-date-field .thai-datetime-date-group {
    width: 100% !important;
    min-width: 0 !important;
    grid-template-columns: minmax(58px, .75fr) minmax(96px, 1.4fr) minmax(80px, .95fr) !important;
    gap: 6px !important;
}

.dashboard-filter-date-field .thai-datetime-select {
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 22px 0 8px !important;
    font-size: .82rem !important;
}

/* 8. Responsive Layouts */
@media (max-width: 700px) {
    .dashboard-filter-toolbar {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
        width: 100% !important;
    }

    .dashboard-filter-search-slot,
    .dashboard-filter-search-slot:hover,
    .dashboard-filter-search-slot:focus-within,
    .dashboard-filter-search-slot.is-open {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        flex: 1 1 100% !important;
    }

    .dashboard-filter-search-slot .dashboard-filter-search,
    .dashboard-filter-search-slot:hover .dashboard-filter-search,
    .dashboard-filter-search-slot:focus-within .dashboard-filter-search,
    .dashboard-filter-search-slot.is-open .dashboard-filter-search {
        position: relative !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        border-radius: 999px !important;
    }

    .dashboard-filter-search input {
        width: 100% !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        transform: none !important;
    }

    .dashboard-filter-capsule-field,
    .chicken-filter-panel > .filter-field,
    .dashboard-filter-capsule,
    [data-custom-dropdown].dashboard-filter-capsule,
    .custom-dropdown.dashboard-filter-capsule {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        flex: none !important;
    }

    .dashboard-filter-capsule > .custom-dropdown-toggle,
    .custom-dropdown.dashboard-filter-capsule > .custom-dropdown-toggle {
        width: 100% !important;
        padding: 0 12px !important;
    }

    .clear-filter-button,
    .reset-filter-btn {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        min-height: 44px !important;
        height: 44px !important;
        border-radius: 999px !important;
    }

    .dashboard-filter-toolbar .dashboard-filter-date-field {
        grid-column: 1 / -1 !important;
        width: 100% !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dashboard-filter-search-slot,
    .dashboard-filter-search,
    .dashboard-filter-search input,
    .dashboard-filter-search label,
    .dashboard-filter-capsule,
    .custom-dropdown-toggle {
        transition-duration: .01ms !important;
    }
}
