/* ==========================================================================
   CSS Layer 4: Reusable UI Components
   ช่องค้นหา ปุ่มตัวกรอง แท็กรสยา การ์ดสมุนไพร กล่องคำเตือน และหมายเหตุสรรพคุณเสมอ
   ========================================================================== */

/* Search Inputs & Clear Buttons */
.search-container {
    margin-bottom: 1rem;
}

.si-wrap {
    position: relative;
    display: block;
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 0.9rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    box-sizing: border-box;
}

.search-input.has-clear {
    padding-right: 2.75rem;
}

.search-input::-webkit-search-cancel-button,
.lp-search-input::-webkit-search-cancel-button,
.pg-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

.si-clear {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    background: #e8e5dc;
    color: var(--text-color);
    font-size: 1.3rem;
    line-height: 1;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.si-clear:hover {
    background: #d6d2c6;
}

/* Filter Pills & Buttons */
.category-buttons,
.filter-section {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.category-buttons {
    justify-content: center;
}

.btn-pill {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.btn-pill:hover,
.btn-pill.active {
    background: var(--secondary-color);
    color: #fff;
    border-color: var(--secondary-color);
}

.reset-btn {
    padding: 0.5rem 1rem;
    background: #888;
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
}

.reset-btn:hover {
    background: #666;
}

/* View Mode Toggle */
.view-toggle {
    display: flex;
    gap: 0.5rem;
    margin: 0.5rem 0 0.8rem;
}

.view-btn {
    padding: 0.5rem 1.1rem;
    border-radius: 20px;
    border: 1px solid var(--primary-color);
    background: var(--card-bg);
    color: var(--primary-color);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.view-btn:hover {
    background: #eef4f0;
}

.view-btn.active {
    background: var(--primary-color);
    color: #fff;
}

/* Herb Cards Grid */
.herb-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.2rem;
    margin-top: 1rem;
}

.herb-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.2rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.herb-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
}

.herb-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0 0 0.4rem 0;
}

.herb-cat-tag {
    display: inline-block;
    font-size: 0.85rem;
    background: var(--bg-color);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    color: #666;
}

.herb-other-names {
    font-size: 0.85rem;
    color: var(--text-subtle);
    line-height: 1.4;
    margin: 0.15rem 0 0.4rem;
}

/* Taste Badges */
.taste-hot { color: var(--taste-hot); font-weight: 600; }
.taste-cold { color: var(--taste-cold); font-weight: 600; }
.taste-warm { color: var(--taste-warm); font-weight: 600; }

.taste-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
    margin-right: 0.3rem;
    margin-bottom: 0.3rem;
}

.badge-hot { background: #fcece9; color: var(--taste-hot); }
.badge-cold { background: #eaf7ef; color: #3a8a5e; }
.badge-warm { background: #fef4e3; color: #b37700; }

/* Warning & Caution Boxes */
.warning-box {
    background-color: var(--warning-bg);
    border: 1px solid var(--warning-border);
    color: var(--warning-text);
    padding: 0.9rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.warning-icon {
    font-size: 1.05rem;
    font-weight: 700;
    margin-right: 0.4rem;
}

.cell-caution {
    background-color: var(--warning-bg);
    border: 1px solid var(--warning-border);
    color: var(--warning-text);
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
}

/* Equivalent Herb Note */
.equiv-note {
    margin-top: 0.5rem;
    padding: 0.4rem 0.7rem;
    font-size: 0.95rem;
    line-height: 1.5;
    background: var(--warning-bg);
    border-left: 4px solid var(--warning-border);
    color: var(--warning-text);
    border-radius: var(--radius-sm);
    font-weight: 400;
}

.equiv-label {
    font-weight: 700;
}

.equiv-link {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: underline;
}

/* Load More Button */
.load-more-btn {
    display: block;
    margin: 1rem auto 0.5rem;
    padding: 0.7rem 1.6rem;
    border-radius: 24px;
    border: 1px solid var(--primary-color);
    background: var(--card-bg);
    color: var(--primary-color);
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
}

.load-more-btn:hover {
    background: var(--primary-color);
    color: #fff;
}

/* Stacked Mobile Block */
.m-herb {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
}

.m-herb h3 {
    font-size: 1.2rem;
    margin: 0 0 0.3rem;
}

.m-plant {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.m-use {
    background: var(--bg-color);
    border-left: 4px solid var(--primary-color);
    padding: 0.8rem;
    margin-top: 0.8rem;
    border-radius: 0 8px 8px 0;
}

.m-row {
    margin-bottom: 0.4rem;
}

.m-label {
    font-weight: 600;
    margin-right: 0.3rem;
}

.m-herb > .equiv-note {
    margin-top: 0.75rem;
}

@media screen and (max-width: 375px) {
    .herb-list {
        grid-template-columns: 1fr;
    }

    .btn-pill,
    .reset-btn {
        width: 100%;
        text-align: center;
        padding: 0.7rem;
    }

    .category-buttons,
    .filter-section {
        flex-direction: column;
    }
}
