/* ============================================================
   Apple Refurb Tracker — Custom Styles
   Built on top of Pico CSS
   ============================================================ */

/* ---- Layout ---- */
nav {
    border-bottom: 1px solid var(--pico-muted-border-color);
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.nav-brand {
    text-decoration: none;
    font-size: 1.1rem;
}

.nav-logout-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--pico-color);
    cursor: pointer;
    font-size: 1rem;
    text-align: left;
    width: 100%;
}

footer.container {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--pico-muted-border-color);
    color: var(--pico-muted-color);
}

main.container {
    padding-top: 2rem;
}

/* ---- Page Headers ---- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.page-header hgroup {
    margin-bottom: 0;
}

.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* ---- Stats Grid ---- */
.stats-grid {
    --pico-grid-column-min: 160px;
    margin-bottom: 1.5rem;
}

.stat-card {
    text-align: center;
}

.stat-card header {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--pico-muted-color);
    padding-bottom: 0.25rem;
    margin-bottom: 0;
    border-bottom: none;
}

.stat-card footer {
    font-size: 0.75rem;
    color: var(--pico-muted-color);
    padding-top: 0.25rem;
    border-top: none;
    margin-top: 0;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.1;
    padding: 0.5rem 0;
}

.stat-number-sm {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.1;
    padding: 0.5rem 0;
}

.stat-card-success {
    border-color: var(--pico-color-green-500, #22c55e);
}

.stat-card-target {
    border-color: var(--pico-color-blue-500, #3b82f6);
}

/* ---- Scrape Status ---- */
.scrape-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 0.15em 0.55em;
    border-radius: 0.75em;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    vertical-align: middle;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-error {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-muted {
    background: var(--pico-muted-background-color, #f3f4f6);
    color: var(--pico-muted-color);
}

.badge-discord {
    background: #e9d5ff;
    color: #5b21b6;
}

.badge-email {
    background: #dbeafe;
    color: #1e40af;
}

.badge-category {
    background: #f3f4f6;
    color: #374151;
}

.badge-admin {
    background: #fef3c7;
    color: #92400e;
}

/* ---- Alerts ---- */
.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
    border-radius: var(--pico-border-radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

/* ---- Buttons ---- */
.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.85rem;
    border-radius: var(--pico-border-radius);
    cursor: pointer;
}

.btn-primary {
    /* uses Pico's primary button styles via role="button" */
}

.btn-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-copy {
    background: none;
    border: none;
    padding: 0 0.25rem;
    cursor: pointer;
    font-size: 0.9rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.btn-copy:hover {
    opacity: 1;
}

/* ---- Contact Cards ---- */
.card-grid {
    --pico-grid-column-min: 280px;
}

.contact-card {
    transition: border-color 0.2s;
}

.contact-inactive {
    opacity: 0.65;
}

.contact-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contact-target {
    word-break: break-all;
    color: var(--pico-muted-color);
}

/* ---- Wishlist Cards ---- */
.wish-card {
    transition: border-color 0.2s;
}

.wish-inactive {
    opacity: 0.65;
}

.wish-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.keyword-tag {
    display: inline-block;
    background: #f1f5f9;
    color: #475569;
    padding: 0.1em 0.4em;
    border-radius: 0.3em;
    font-size: 0.8rem;
    margin: 0.1em;
}

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

.product-card {
    display: flex;
    flex-direction: column;
}

.product-out-of-stock {
    opacity: 0.65;
}

.product-img {
    width: 100%;
    height: 160px;
    object-fit: contain;
    background: #f8f9fa;
    border-radius: var(--pico-border-radius);
    margin-bottom: 0.75rem;
}

.product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.product-name a {
    text-decoration: none;
    color: inherit;
}

.product-name a:hover {
    text-decoration: underline;
}

.product-meta {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.product-price-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.current-price {
    font-size: 1.3rem;
    font-weight: 700;
}

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

.savings-badge {
    background: #dcfce7;
    color: #166534;
    padding: 0.1em 0.4em;
    border-radius: 0.3em;
    font-size: 0.8rem;
    font-weight: 600;
}

.product-part {
    color: var(--pico-muted-color);
}

.product-card-footer {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

/* ---- Product Search Form ---- */
.search-form {
    margin-bottom: 1.5rem;
}

.search-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.search-row input,
.search-row select,
.search-row button {
    margin-bottom: 0;
}

/* ---- Price History ---- */
.breadcrumbs {
    margin-bottom: 1rem;
}

.breadcrumbs a {
    color: var(--pico-muted-color);
    text-decoration: none;
    font-size: 0.9rem;
}

.breadcrumbs a:hover {
    color: var(--pico-primary);
}

.range-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.range-btn {
    padding: 0.3rem 0.9rem;
    border-radius: 2em;
    border: 1px solid var(--pico-muted-border-color);
    background: transparent;
    color: var(--pico-color);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.15s;
}

.range-btn:hover {
    border-color: var(--pico-primary);
    color: var(--pico-primary);
}

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

.chart-container {
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

/* ---- Product Specs ---- */
.product-specs {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.35rem 1.5rem;
}

.product-specs dt {
    font-weight: 600;
    color: var(--pico-muted-color);
    font-size: 0.9rem;
}

.product-specs dd {
    margin: 0;
}

/* ---- Filter Tabs ---- */
.filter-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--pico-muted-border-color);
}

.filter-tabs a {
    padding: 0.3rem 0.9rem;
    border-radius: 2em;
    border: 1px solid var(--pico-muted-border-color);
    background: transparent;
    text-decoration: none;
    color: var(--pico-muted-color);
    font-size: 0.9rem;
    transition: all 0.15s;
}

.filter-tabs a:hover {
    border-color: var(--pico-primary);
    color: var(--pico-primary);
}

.filter-tabs a.active {
    background: var(--pico-primary);
    border-color: var(--pico-primary);
    color: #fff;
}

/* ---- Matches list ---- */
.matches-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.match-item {
    padding: 0.75rem;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
}

.match-price {
    font-size: 1.1rem;
    font-weight: 600;
    margin-right: 0.5rem;
}

/* ---- Empty States ---- */
.empty-state {
    color: var(--pico-muted-color);
    text-align: center;
    padding: 1rem 0;
}

.empty-state-card {
    text-align: center;
    padding: 2rem;
}

/* ---- Text utilities ---- */
.muted {
    color: var(--pico-muted-color);
}

.text-success {
    color: #166534;
}

.text-error {
    color: #991b1b;
}

.warning-text {
    color: #92400e;
}

.error-text {
    color: #991b1b;
}

/* ---- Code / Error ---- */
.error-pre {
    background: #fee2e2;
    color: #991b1b;
    padding: 0.75rem;
    border-radius: var(--pico-border-radius);
    font-size: 0.85rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ---- Admin table copy ---- */
code {
    font-family: ui-monospace, monospace;
    font-size: 0.85rem;
    background: var(--pico-code-background-color, #f3f4f6);
    padding: 0.1em 0.4em;
    border-radius: 0.25em;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .search-row {
        flex-direction: column;
    }

    .search-row select {
        width: 100%;
    }

    .stats-grid {
        --pico-grid-column-min: 130px;
    }
}
