/* ================================================================
   Handheld Tracker Display — Plugin Styles
   All rules scoped under .handheld-tracker to avoid theme conflicts.
   ================================================================ */

/* --- Custom properties --- */
.handheld-tracker {
    --htd-accent: #2563eb;
    --htd-accent-hover: #1d4ed8;
    --htd-green: #16a34a;
    --htd-green-bg: #dcfce7;
    --htd-yellow: #ca8a04;
    --htd-yellow-bg: #fef9c3;
    --htd-red: #dc2626;
    --htd-red-bg: #fee2e2;
    --htd-muted: #6b7280;
    --htd-border: #e5e7eb;
    --htd-bg: #ffffff;
    --htd-bg-card: #ffffff;
    --htd-bg-hover: #f9fafb;
    --htd-text: #111827;
    --htd-text-secondary: #6b7280;
    --htd-radius: 8px;
    --htd-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --htd-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.1);
    --htd-gap: 20px;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--htd-text);
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 16px;
}

/* --- Data freshness --- */
.htd-freshness {
    font-size: 0.8rem;
    color: var(--htd-text-secondary);
    margin-bottom: 16px;
}

.htd-stale-warning {
    color: var(--htd-yellow);
    font-weight: 600;
    margin-left: 8px;
}

/* --- Recent changes --- */
.htd-recent-changes {
    margin-bottom: 32px;
}

.htd-section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 12px;
}

.htd-changes-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.htd-change-card {
    flex: 0 0 260px;
    scroll-snap-align: start;
    background: var(--htd-bg-card);
    border: 1px solid var(--htd-border);
    border-radius: var(--htd-radius);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.htd-change-product {
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.3;
}

.htd-change-variant {
    font-size: 0.8rem;
    color: var(--htd-text-secondary);
}

.htd-change-summary {
    font-size: 0.85rem;
    color: var(--htd-green);
    font-weight: 500;
}

.htd-change-time {
    font-size: 0.75rem;
    color: var(--htd-muted);
}

/* --- Controls bar --- */
.htd-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--htd-bg-card);
    border: 1px solid var(--htd-border);
    border-radius: var(--htd-radius);
}

.htd-filters {
    flex: 1;
    min-width: 0;
}

.htd-filter-toggle {
    display: none;
    background: none;
    border: 1px solid var(--htd-border);
    border-radius: var(--htd-radius);
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--htd-text);
}

.htd-filter-icon {
    margin-right: 4px;
}

.htd-filter-drawer {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
}

.htd-filter-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.htd-filter-heading {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--htd-text-secondary);
    width: 100%;
}

/* Toggles */
.htd-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    user-select: none;
}

.htd-toggle input[type="checkbox"] {
    accent-color: var(--htd-accent);
    width: 16px;
    height: 16px;
}

/* Vendor pills */
.htd-vendor-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.htd-pill {
    cursor: pointer;
    user-select: none;
}

.htd-pill input {
    display: none;
}

.htd-pill span {
    display: inline-block;
    padding: 4px 12px;
    border: 1px solid var(--htd-border);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.15s ease;
    color: var(--htd-text-secondary);
    background: var(--htd-bg);
}

.htd-pill input:checked + span {
    background: var(--htd-accent);
    border-color: var(--htd-accent);
    color: #fff;
}



/* Price range */
.htd-price-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.htd-price-inputs input {
    width: 80px;
    padding: 6px 8px;
    border: 1px solid var(--htd-border);
    border-radius: 4px;
    font-size: 0.85rem;
}

.htd-price-sep {
    color: var(--htd-muted);
}

/* Sort */
.htd-sort {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.htd-sort label {
    font-size: 0.85rem;
    color: var(--htd-text-secondary);
    font-weight: 500;
}

.htd-sort select {
    padding: 6px 10px;
    border: 1px solid var(--htd-border);
    border-radius: 4px;
    font-size: 0.85rem;
    background: var(--htd-bg);
    color: var(--htd-text);
}

/* Result count */
.htd-result-count {
    font-size: 0.85rem;
    color: var(--htd-text-secondary);
    margin-bottom: 12px;
}

/* --- Product Grid --- */
.htd-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--htd-gap);
}

/* --- Product Card --- */
.htd-card {
    position: relative;
    background: var(--htd-bg-card);
    border: 1px solid var(--htd-border);
    border-radius: var(--htd-radius);
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    display: flex;
    flex-direction: column;
}

.htd-card:hover {
    box-shadow: var(--htd-shadow-hover);
    transform: translateY(-2px);
}

.htd-card-oos {
    opacity: 0.6;
}

.htd-card[hidden] {
    display: none;
}

/* Discount badge */
.htd-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    color: #fff;
}

.htd-badge-hot {
    background: var(--htd-green);
}

.htd-badge-warm {
    background: var(--htd-yellow);
}

.htd-badge-mild {
    background: var(--htd-muted);
}

/* Card image */
.htd-card-image {
    aspect-ratio: 1;
    overflow: hidden;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.htd-card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    mix-blend-mode: multiply;
}

.htd-card-no-image {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #e5e7eb, #d1d5db);
}

/* Card body */
.htd-card-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.htd-vendor-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--htd-accent);
}

.htd-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.35;
}

.htd-card-title a {
    color: inherit;
    text-decoration: none;
}

.htd-card-title a:hover {
    color: var(--htd-accent);
}

/* Price block */
.htd-price-block {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.htd-price-current {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--htd-text);
}

.htd-price-compare {
    font-size: 0.9rem;
    color: var(--htd-muted);
    text-decoration: line-through;
}

/* Availability */
.htd-availability {
    font-size: 0.85rem;
}

.htd-in-stock {
    color: var(--htd-green);
}

.htd-out-of-stock {
    color: var(--htd-red);
}

/* CTA */
.htd-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background: var(--htd-accent);
    color: #fff !important;
    text-decoration: none !important;
    border-radius: var(--htd-radius);
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.15s ease;
    margin-top: auto;
}

.htd-cta:hover {
    background: var(--htd-accent-hover);
}

.htd-card-oos .htd-cta {
    background: var(--htd-muted);
}

/* Variant expander */
.htd-variant-toggle {
    background: none;
    border: none;
    padding: 6px 0;
    color: var(--htd-text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    text-align: left;
    transition: color 0.15s ease;
}

.htd-variant-toggle:hover {
    color: var(--htd-accent);
	
}

.htd-variant-toggle[aria-expanded="true"] {
    color: var(--htd-accent);
}

.htd-variants {
    border-top: 1px solid var(--htd-border);
    padding-top: 8px;
    margin-top: 4px;
}

.htd-variant-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.htd-variant-table td {
    padding: 4px 0;
    vertical-align: middle;
}

.htd-variant-name {
    font-weight: 500;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.htd-variant-price {
    text-align: right;
    white-space: nowrap;
}

.htd-variant-price .htd-price-compare {
    font-size: 0.75rem;
    margin-left: 4px;
}

.htd-variant-stock {
    text-align: right;
    width: 24px;
}

.htd-variant-oos {
    opacity: 0.5;
}

/* --- Pagination --- */
.htd-pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.htd-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 4px 10px;
    border: 1px solid var(--htd-border);
    border-radius: 4px;
    background: var(--htd-bg);
    color: var(--htd-text);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.htd-page-btn:hover {
    border-color: var(--htd-accent);
    color: var(--htd-accent);
}

.htd-page-btn.active {
    background: var(--htd-accent);
    border-color: var(--htd-accent);
    color: #fff;
}

/* --- Error state --- */
.htd-error {
    padding: 24px;
    background: var(--htd-red-bg);
    border: 1px solid var(--htd-red);
    border-radius: var(--htd-radius);
    color: var(--htd-red);
    text-align: center;
}

/* ================================================================
   Responsive
   ================================================================ */

/* Tablet: 2 columns */
@media (max-width: 1024px) {
    .htd-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile: filter drawer collapses, 1 column */
@media (max-width: 768px) {
    .htd-grid {
        grid-template-columns: 1fr;
    }

    .htd-filter-toggle {
        display: inline-flex;
    }

    .htd-filter-drawer {
        display: none;
        flex-direction: column;
        margin-top: 12px;
    }

    .htd-filter-drawer.htd-drawer-open {
        display: flex;
    }

    .htd-controls {
        flex-direction: column;
    }

    .htd-sort {
        width: 100%;
    }

    .htd-sort select {
        flex: 1;
    }

    .htd-change-card {
        flex: 0 0 220px;
    }
}
