/* Commrade Plaza — base styles (placeholder, refine later) */

:root {
    --color-primary: #1e7a4c;
    --color-primary-dark: #145c38;
    --color-bg: #f7f7f7;
    --color-border: #ddd;
    --color-text: #222;
    --color-muted: #666;
    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
}

.site-header {
    background: #fff;
    border-bottom: 1px solid var(--color-border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.logo {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--color-primary-dark);
    text-decoration: none;
}

.main-nav a {
    margin-left: 14px;
    text-decoration: none;
    color: var(--color-text);
    font-size: 0.95rem;
}

.main-nav a:hover { color: var(--color-primary); }

.nav-toggle-checkbox {
    /* visually hidden but still focusable/clickable via its label */
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text);
    padding: 4px 8px;
}

main { padding: 24px 16px; min-height: 60vh; }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.95rem;
}
.alert-success { background: #e6f4ea; color: #1e7a4c; border: 1px solid #b7ddc4; }
.alert-error   { background: #fdecea; color: #a1332a; border: 1px solid #f3c4c0; }

.site-footer {
    border-top: 1px solid var(--color-border);
    padding: 18px 0;
    color: var(--color-muted);
    font-size: 0.85rem;
    text-align: center;
}

.btn {
    display: inline-block;
    background: var(--color-primary);
    color: #fff;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    font-size: 0.95rem;
}
.btn:hover { background: var(--color-primary-dark); }

.card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

form label {
    display: block;
    margin: 12px 0 4px;
    font-weight: 600;
    font-size: 0.9rem;
}

form input, form select, form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
}

/* Product cards */
.product-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}
.product-card img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: #eee;
    display: block;
}
.product-card .product-card-body { padding: 10px 12px; }
.product-card .product-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin: 0 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.product-card .product-price {
    color: var(--color-primary-dark);
    font-weight: 700;
    margin: 0 0 4px;
}
.product-card .product-meta {
    color: var(--color-muted);
    font-size: 0.8rem;
    margin: 0;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}
.badge-success { background: #e6f4ea; color: #1e7a4c; }
.badge-warning { background: #fff6e0; color: #9a6b00; }
.badge-danger  { background: #fdecea; color: #a1332a; }
.badge-muted   { background: #eee; color: #666; }

/* Product detail gallery */
.gallery-main {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #f0f0f0;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.gallery-main img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.gallery-thumbs {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.gallery-thumbs img {
    width: 68px;
    height: 68px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    opacity: 0.75;
    transition: opacity 0.15s, border-color 0.15s;
}
.gallery-thumbs img:hover { opacity: 1; }
.gallery-thumbs img.active {
    border-color: var(--color-primary);
    opacity: 1;
}

/* Product/item detail meta list */
.detail-meta-list {
    list-style: none;
    padding: 0;
    margin: 14px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.detail-meta-list li {
    color: var(--color-text);
    font-size: 0.95rem;
    padding-bottom: 6px;
    border-bottom: 1px solid #f0f0f0;
}
.detail-meta-list li:last-child { border-bottom: none; }

/* Collapsible "Report this listing" disclosure */
.report-disclosure {
    margin-top: 24px;
    border-top: 1px solid var(--color-border);
    padding-top: 14px;
}
.report-disclosure summary {
    cursor: pointer;
    color: #a1332a;
    font-weight: 600;
    font-size: 0.9rem;
    list-style: none;
}
.report-disclosure summary::-webkit-details-marker { display: none; }
.report-disclosure summary::before {
    content: "\26A0  ";
}

.pagination {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.filter-bar a {
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    text-decoration: none;
    color: var(--color-text);
    font-size: 0.85rem;
}
.filter-bar a.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* Profile page */
.btn-secondary { background: #555; }
.btn-secondary:hover { background: #333; }

.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}
.avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 700;
    flex-shrink: 0;
}
.profile-header-info h1 {
    margin: 0 0 4px;
    font-size: 1.5rem;
}
.profile-actions {
    margin-top: 14px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.profile-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Collapsible search/filter panel — hidden until the search icon is
   clicked. Pure CSS via a checkbox, same pattern as the nav toggle. */
.search-toggle-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.search-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--color-text);
}
.search-panel {
    display: none;
    margin-top: 12px;
}
.search-toggle-checkbox:checked ~ .search-panel {
    display: block;
}

/* ==========================================
   Responsive — tablets and phones
   ========================================== */

/* Two-column layout that stacks to one column on small screens
   (product detail: image | info, lost&found detail: same). */
.detail-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .nav-toggle { display: block; }

    .main-nav {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        margin-top: 10px;
        border-top: 1px solid var(--color-border);
        padding-top: 10px;
    }
    /* Checkbox is a preceding sibling of nav in the header markup,
       so :checked ~ .main-nav shows the menu — no JS involved. */
    .nav-toggle-checkbox:checked ~ .main-nav { display: flex; }

    .main-nav a {
        margin-left: 0;
        padding: 10px 4px;
        width: 100%;
    }

    .header-inner { position: relative; }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .profile-columns {
        grid-template-columns: 1fr;
    }
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
    .profile-actions {
        justify-content: center;
    }

    /* Force a tight 2-column grid for listing cards (products & lost/found)
       on phones and small tablets, per the "2x2 grid, lots of products"
       requirement — overrides the auto-fill desktop behavior, including
       any inline grid-template-columns. */
    .grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .product-card img { height: 100px; }
    .product-card .product-card-body { padding: 8px; }
    .product-card .product-title { font-size: 0.82rem; }
    .product-card .product-price { font-size: 0.85rem; }
    .product-card .product-meta { font-size: 0.7rem; }
}

@media (max-width: 600px) {
    .container { padding: 0 12px; }
    main { padding: 16px 12px; }

    h1 { font-size: 1.4rem; }
    h2 { font-size: 1.15rem; }

    .card { padding: 12px; }

    .btn { padding: 9px 14px; font-size: 0.9rem; }

    .pagination {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
        text-align: center;
    }

    .filter-bar { gap: 6px; }
    .filter-bar a { padding: 5px 10px; font-size: 0.8rem; }

    table { font-size: 0.85rem; }
}
