/**
 * PCG Listings Plugin - Frontend Styles
 *
 * Colours come from the --pcg-* tokens below. Light values are the default;
 * the dark values switch on when the page is in dark mode. Dark mode is
 * detected from the theme itself (see PCG_Theme_Mode): html.pcg-dark is added
 * when the theme's page background is dark. Common dark-mode classes used by
 * other themes are honoured too. The OS light/dark setting is NOT used,
 * because the site's own toggle must win.
 */

:root,
html.pcg-light {
    --pcg-surface: #ffffff;
    --pcg-surface-2: #f8fafc;
    --pcg-border: #e2e8f0;
    --pcg-heading: #0f172a;
    --pcg-text: #1e293b;
    --pcg-muted: #64748b;
    --pcg-accent: #2563eb;
    --pcg-accent-hover: #1d4ed8;
    --pcg-price: #16a34a;
    --pcg-chip-bg: #eff6ff;
    --pcg-chip-text: #1d4ed8;
    --pcg-input-bg: #ffffff;
    --pcg-active-bg: #2563eb;
    --pcg-active-text: #ffffff;
    --pcg-cta: #16a34a;
    --pcg-cta-hover: #15803d;
    --pcg-cta-text: #ffffff;
    --pcg-danger: #dc2626;
    --pcg-warn-bg: #fff7e0;
    --pcg-warn-text: #8a5a00;
    --pcg-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
    --pcg-shadow-hover: 0 10px 28px rgba(15, 23, 42, .12);
}

html.pcg-dark,
html.dark, html.dark-mode, html.theme-dark,
html[data-theme="dark"], html[data-mode="dark"], html[data-color-scheme="dark"], html[data-bs-theme="dark"],
body.dark, body.dark-mode, body.theme-dark, body.wp-dark-mode,
body[data-theme="dark"], body[data-mode="dark"],
.is-dark-theme {
    --pcg-surface: #111a2e;
    --pcg-surface-2: #0c1425;
    --pcg-border: #1f2c47;
    --pcg-heading: #f8fafc;
    --pcg-text: #e2e8f0;
    --pcg-muted: #94a3b8;
    --pcg-accent: #3b82f6;
    --pcg-accent-hover: #60a5fa;
    --pcg-price: #34d399;
    --pcg-chip-bg: rgba(59, 130, 246, .16);
    --pcg-chip-text: #93c5fd;
    --pcg-input-bg: #0b1324;
    --pcg-active-bg: #2563eb;
    --pcg-active-text: #ffffff;
    --pcg-cta: #2ef59a;
    --pcg-cta-hover: #5dffb4;
    --pcg-cta-text: #04120b;
    --pcg-danger: #f87171;
    --pcg-warn-bg: rgba(250, 204, 21, .12);
    --pcg-warn-text: #fde68a;
    --pcg-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --pcg-shadow-hover: 0 10px 30px rgba(0, 0, 0, .5);
}

/* An explicit light signal from the detector beats the guessed classes above */
html.pcg-light,
html.pcg-light body {
    --pcg-surface: #ffffff;
    --pcg-surface-2: #f8fafc;
    --pcg-border: #e2e8f0;
    --pcg-heading: #0f172a;
    --pcg-text: #1e293b;
    --pcg-muted: #64748b;
    --pcg-accent: #2563eb;
    --pcg-accent-hover: #1d4ed8;
    --pcg-price: #16a34a;
    --pcg-chip-bg: #eff6ff;
    --pcg-chip-text: #1d4ed8;
    --pcg-input-bg: #ffffff;
    --pcg-cta: #16a34a;
    --pcg-cta-hover: #15803d;
    --pcg-cta-text: #ffffff;
    --pcg-danger: #dc2626;
    --pcg-warn-bg: #fff7e0;
    --pcg-warn-text: #8a5a00;
    --pcg-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
    --pcg-shadow-hover: 0 10px 28px rgba(15, 23, 42, .12);
}

/* ==========================================================================
   General Styles
   ========================================================================== */

.pcg-archive-wrapper,
.pcg-dashboard-wrapper,
.pcg-submission-form-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ==========================================================================
   Filter Form
   ========================================================================== */

.pcg-filter-wrapper {
    background: var(--pcg-surface-2);
    padding: 30px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.pcg-filter-form {
    display: block;
}

.pcg-filter-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.pcg-filter-field {
    flex: 1;
    min-width: 200px;
}

.pcg-filter-field-small {
    flex: 0 0 150px;
}

.pcg-filter-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--pcg-text);
}

.pcg-input,
.pcg-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--pcg-border);
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.pcg-input:focus,
.pcg-select:focus {
    outline: none;
    border-color: #0073aa;
}

/* ==========================================================================
   Listings Grid
   ========================================================================== */

.pcg-listings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
    align-items: stretch;
}

.pcg-listings-grid > * {
    height: 100%;
}

.pcg-listing-card {
    background: var(--pcg-surface);
    border: 1px solid var(--pcg-border);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 380px;
}

.pcg-listing-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.pcg-listing-card.featured {
    border: 2px solid #ffc107;
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.3);
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.05) 0%, rgba(255, 152, 0, 0.05) 100%);
    position: relative;
}

.pcg-listing-card.featured::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #ffc107 0%, #ff9800 100%);
    z-index: 5;
}

.pcg-listing-card.featured:hover {
    box-shadow: 0 8px 25px rgba(255, 193, 7, 0.4);
    transform: translateY(-8px);
}

.pcg-featured-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    color: #fff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: featured-pulse 2s ease-in-out infinite;
}

@keyframes featured-pulse {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(255, 152, 0, 0.4);
    }
    50% {
        box-shadow: 0 4px 15px rgba(255, 152, 0, 0.6);
    }
}

.pcg-featured-badge .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.pcg-listing-image {
    position: relative;
    height: 220px;
    min-height: 220px;
    max-height: 220px;
    overflow: hidden;
    background: var(--pcg-surface-2);
    flex-shrink: 0;
}

.pcg-listing-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.pcg-listing-card:hover .pcg-listing-image img {
    transform: scale(1.05);
}

.pcg-no-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--pcg-muted);
    font-size: 14px;
}

.pcg-listing-content {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.pcg-listing-title {
    margin: 0 0 10px 0;
    font-size: 18px;
    line-height: 1.4;
    min-height: 50px;
    max-height: 50px;
    overflow: hidden;
}

.pcg-listing-title a {
    color: var(--pcg-text);
    text-decoration: none;
    transition: color 0.3s;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pcg-listing-title a:hover {
    color: #0073aa;
}

.pcg-listing-meta {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--pcg-muted);
    min-height: 20px;
    flex-wrap: wrap;
}

.pcg-location .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    vertical-align: middle;
}

.pcg-listing-price {
    font-size: 24px;
    font-weight: bold;
    color: #0073aa;
    margin-top: auto;
    padding-top: 10px;
}

.pcg-negotiable-badge {
    display: inline-block;
    margin-left: 10px;
    padding: 3px 8px;
    background: var(--pcg-chip-bg);
    color: #0073aa;
    font-size: 12px;
    border-radius: 3px;
    font-weight: normal;
}

/* ==========================================================================
   Listing Card Specific Styles (Homepage & AJAX loaded)
   These classes ensure consistent card sizing across all pages
   ========================================================================== */

.pcg-listing-card-image {
    position: relative;
    width: 100%;
    height: 200px;
    min-height: 200px;
    max-height: 200px;
    overflow: hidden;
    background: var(--pcg-surface-2);
    flex-shrink: 0;
}

.pcg-listing-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.pcg-listing-card:hover .pcg-listing-card-image img {
    transform: scale(1.05);
}

.pcg-listing-card-content {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.pcg-listing-card-title {
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    min-height: 44px;
    max-height: 44px;
    overflow: hidden;
}

.pcg-listing-card-title a {
    color: var(--pcg-text);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pcg-listing-card-title a:hover {
    color: #0073aa;
}

.pcg-listing-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--pcg-muted);
    min-height: 24px;
}

.pcg-meta-location {
    display: flex;
    align-items: center;
    gap: 3px;
}

.pcg-meta-location .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.pcg-meta-condition {
    padding: 2px 8px;
    background: var(--pcg-surface-2);
    border-radius: 3px;
}

.pcg-listing-card-price {
    font-size: 20px;
    font-weight: 700;
    color: #28a745;
    margin-top: auto;
    padding-top: 10px;
}

.pcg-negotiable-tag {
    font-size: 11px;
    font-weight: 400;
    color: var(--pcg-muted);
    margin-left: 6px;
}

/* ==========================================================================
   Single Listing
   ========================================================================== */

.pcg-single-listing {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px 40px;
    color: var(--pcg-text);
}

.pcg-featured-banner {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    color: #000;
    text-align: center;
    padding: 12px;
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 20px;
    border-radius: 12px;
}

.pcg-featured-star {
    font-size: 20px;
    margin-right: 8px;
}

.pcg-listing-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 30px;
    margin-bottom: 30px;
    align-items: start;
}

.pcg-listing-gallery {
    position: sticky;
    top: 90px;
    min-width: 0;
}

.pcg-main-image {
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 12px;
    background: var(--pcg-surface-2);
    border: 1px solid var(--pcg-border);
}

.pcg-main-image img {
    width: 100%;
    height: auto;
    max-height: 640px;
    object-fit: contain;
    display: block;
}

.pcg-no-image-large {
    background: var(--pcg-surface-2);
    border: 1px solid var(--pcg-border);
    padding: 80px 20px;
    text-align: center;
    border-radius: 12px;
    color: var(--pcg-muted);
}

.pcg-thumbnail-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
}

.pcg-thumbnail {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border: 2px solid var(--pcg-border);
    border-radius: 8px;
    cursor: pointer;
    opacity: .7;
    transition: border-color .2s, opacity .2s;
}

.pcg-thumbnail:hover,
.pcg-thumbnail.active {
    border-color: var(--pcg-accent);
    opacity: 1;
}

/* Cards */
.pcg-single-listing .pcg-listing-details,
.pcg-single-listing .pcg-description-section {
    background: var(--pcg-surface);
    color: var(--pcg-text);
    border: 1px solid var(--pcg-border);
    border-radius: 12px;
    box-shadow: var(--pcg-shadow);
}

.pcg-single-listing .pcg-listing-details {
    padding: 24px;
}

.pcg-single-listing .pcg-listing-details .pcg-listing-title {
    font-size: clamp(22px, 2.4vw, 28px);
    line-height: 1.25;
    font-weight: 700;
    margin: 0 0 16px;
    min-height: 0;
    max-height: none;
    overflow: visible;
    color: var(--pcg-heading);
}

.pcg-single-listing .pcg-price-section {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 12px;
    margin-bottom: 6px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--pcg-border);
}

.pcg-single-listing .pcg-price {
    font-size: clamp(26px, 3vw, 34px);
    font-weight: 800;
    line-height: 1.1;
    color: var(--pcg-price);
}

.pcg-single-listing .pcg-negotiable-text {
    display: inline-block;
    margin: 0;
    padding: 4px 11px;
    background: var(--pcg-chip-bg);
    color: var(--pcg-chip-text);
    font-size: 13px;
    font-weight: 600;
    border-radius: 999px;
}

.pcg-single-listing .pcg-meta-info {
    margin: 0;
}

.pcg-single-listing .pcg-meta-item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 13px 0;
    border-bottom: 1px solid var(--pcg-border);
    font-size: 15px;
    color: var(--pcg-text);
}

.pcg-single-listing .pcg-meta-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.pcg-single-listing .pcg-meta-item strong {
    display: inline-block;
    min-width: 110px;
    font-weight: 500;
    color: var(--pcg-muted);
}

.pcg-single-listing .pcg-meta-item .dashicons {
    color: var(--pcg-muted);
    font-size: 17px;
    width: 17px;
    height: 17px;
}

/* Description */
.pcg-single-listing .pcg-description-section {
    padding: 28px 30px;
}

.pcg-single-listing .pcg-description-section h2 {
    margin: 0 0 16px;
    font-size: 24px;
    color: var(--pcg-heading);
}

.pcg-description-content {
    font-size: 15px;
    line-height: 1.65;
    color: var(--pcg-text);
    overflow-wrap: anywhere;
}

/* Descriptions pasted from shops/other sites often arrive with every line
   as its own paragraph, heading or bold block. Keep them compact. */
.pcg-description-content p,
.pcg-description-content div {
    margin: 0 0 .5em;
    color: inherit;
}

.pcg-description-content p:empty {
    display: none;
}

.pcg-description-content h1,
.pcg-description-content h2,
.pcg-description-content h3,
.pcg-description-content h4,
.pcg-description-content h5,
.pcg-description-content h6 {
    font-size: 16px;
    line-height: 1.4;
    margin: 1em 0 .3em;
    color: var(--pcg-heading);
}

.pcg-description-content ul,
.pcg-description-content ol {
    margin: 0 0 .8em 1.3em;
    padding: 0;
}

.pcg-description-content li {
    margin: 0 0 .25em;
}

.pcg-description-content a {
    color: var(--pcg-accent);
}

.pcg-description-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 1em;
}

.pcg-description-content th,
.pcg-description-content td {
    border: 1px solid var(--pcg-border);
    padding: 8px 10px;
    text-align: left;
}

.pcg-description-content > :first-child {
    margin-top: 0;
}

.pcg-description-content > :last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   Phone Reveal
   ========================================================================== */

.pcg-phone-reveal {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pcg-reveal-phone-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    background: #25D366;
    color: #fff !important;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.pcg-reveal-phone-btn:hover {
    background: #1ebe5b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.pcg-reveal-phone-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.pcg-phone-link {
    font-size: 16px;
    font-weight: 600;
    color: #22c55e;
    text-decoration: none;
    transition: color 0.3s;
}

.pcg-phone-link:hover {
    color: #005a87;
    text-decoration: underline;
}

/* ==========================================================================
   Auth Modal
   ========================================================================== */

.pcg-auth-required {
    max-width: 600px;
    margin: 40px auto;
    text-align: center;
}

.pcg-auth-notice {
    background: var(--pcg-surface);
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.pcg-auth-notice p {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--pcg-text);
}

.pcg-auth-step {
    margin-top: 20px;
}

.pcg-auth-step p {
    color: var(--pcg-muted);
    margin-bottom: 20px;
}

.pcg-button-secondary {
    background: #6c757d;
    color: #fff;
    margin-top: 10px;
}

.pcg-button-secondary:hover {
    background: #5a6268;
}

#verify_code {
    text-align: center;
    font-size: 24px;
    letter-spacing: 4px;
    font-weight: 600;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.pcg-button {
    display: inline-block;
    padding: 12px 24px;
    background: var(--pcg-surface-2);
    color: var(--pcg-text);
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
}

.pcg-button:hover {
    background: var(--pcg-surface-2);
    transform: translateY(-2px);
}

.pcg-button-primary {
    background: #0073aa;
    color: #fff;
}

.pcg-button-primary:hover {
    background: #005a87;
}

.pcg-button-danger {
    background: #dc3545;
    color: #fff;
}

.pcg-button-danger:hover {
    background: #c82333;
}

.pcg-button-large {
    width: 100%;
    padding: 15px 24px;
    font-size: 17px;
}

.pcg-button-small {
    padding: 6px 12px;
    font-size: 13px;
}

.pcg-button .dashicons {
    vertical-align: middle;
    margin-right: 5px;
}

/* ==========================================================================
   Modal
   ========================================================================== */

.pcg-modal {
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    overflow: auto;
}

.pcg-modal-content {
    background-color: var(--pcg-surface);
    margin: 5% auto;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    position: relative;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.pcg-modal-close {
    color: var(--pcg-muted);
    float: right;
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    transition: color 0.3s;
}

.pcg-modal-close:hover {
    color: #000;
}

.pcg-modal-content h2 {
    margin-top: 0;
    margin-bottom: 25px;
}

/* Edit Warning Box */
.pcg-edit-warning {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-left: 4px solid #f39c12;
    color: #856404;
    padding: 12px 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pcg-edit-warning .dashicons {
    color: #f39c12;
    font-size: 20px;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.pcg-edit-warning strong {
    font-weight: 600;
}

/* ==========================================================================
   Form Styles
   ========================================================================== */

.pcg-form-group {
    margin-bottom: 20px;
}

.pcg-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--pcg-text);
}

.pcg-form-group .required {
    color: #dc3545;
}

.pcg-input,
.pcg-select,
.pcg-input-file {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--pcg-border);
    border-radius: 4px;
    font-size: 15px;
    background-color: var(--pcg-surface) !important;
    color: var(--pcg-text) !important;
}

/* Force visible text in all inputs regardless of theme */
.pcg-input:focus,
.pcg-select:focus,
.pcg-input-file:focus,
input[type="text"].pcg-input,
input[type="number"].pcg-input,
input[type="email"].pcg-input,
input[type="tel"].pcg-input,
textarea.pcg-input,
select.pcg-select {
    background-color: var(--pcg-surface) !important;
    color: var(--pcg-text) !important;
}

textarea.pcg-input {
    resize: vertical;
    min-height: 100px;
}

.pcg-help-text {
    font-size: 13px;
    color: var(--pcg-muted);
    margin-top: 5px;
}

.pcg-form-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.pcg-col-6 {
    flex: 1;
    min-width: 250px;
}

/* ==========================================================================
   Dashboard
   ========================================================================== */

.pcg-dashboard-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--pcg-border);
}

.pcg-tab {
    padding: 12px 20px;
    background: var(--pcg-surface-2);
    border: none;
    border-radius: 4px 4px 0 0;
    color: var(--pcg-muted);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
}

.pcg-tab:hover {
    background: var(--pcg-surface-2);
    color: var(--pcg-text);
}

.pcg-tab.active {
    background: #0073aa;
    color: #fff;
}

.pcg-listings-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--pcg-surface);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden;
}

.pcg-listings-table thead {
    background: var(--pcg-surface-2);
}

.pcg-listings-table th,
.pcg-listings-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--pcg-border);
}

.pcg-listings-table th {
    font-weight: 600;
    color: var(--pcg-muted);
    font-size: 14px;
}

.pcg-listings-table tr:last-child td {
    border-bottom: none;
}

.pcg-listings-table tbody tr:hover {
    background: var(--pcg-surface-2);
}

.pcg-listing-image img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
}

.pcg-no-image {
    width: 60px;
    height: 60px;
    background: var(--pcg-surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: var(--pcg-muted);
}

.pcg-listing-actions {
    white-space: nowrap;
}

.pcg-listing-actions .pcg-button {
    margin-right: 5px;
    margin-bottom: 5px;
}

/* ==========================================================================
   Notices
   ========================================================================== */

.pcg-notice {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    border-left: 4px solid;
}

.pcg-notice-success {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.pcg-notice-error {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.pcg-notice-info {
    background: #d1ecf1;
    border-color: #17a2b8;
    color: #0c5460;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.pcg-pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 30px;
}

.pcg-page-btn {
    padding: 8px 14px;
    background: var(--pcg-surface);
    border: 1px solid var(--pcg-border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.pcg-page-btn:hover {
    background: var(--pcg-surface-2);
}

.pcg-page-btn.active {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.pcg-listings-loading {
    text-align: center;
    padding: 40px;
    font-size: 18px;
    color: var(--pcg-muted);
}

.pcg-no-results {
    text-align: center;
    padding: 60px 20px;
    font-size: 18px;
    color: var(--pcg-muted);
    background: var(--pcg-surface-2);
    border-radius: 8px;
}

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

@media (max-width: 768px) {
    .pcg-listing-container {
        grid-template-columns: 1fr;
    }
    
    /* Remove sticky positioning on mobile to prevent content scrolling under images */
    .pcg-listing-gallery {
        position: static !important;
        top: auto !important;
    }
    
    .pcg-filter-row {
        flex-direction: column;
    }
    
    .pcg-filter-field,
    .pcg-filter-field-small {
        width: 100%;
        min-width: 100%;
    }
    
    .pcg-listings-grid {
        grid-template-columns: 1fr;
    }
    
    .pcg-dashboard-tabs {
        flex-wrap: wrap;
    }
    
    .pcg-listings-table {
        font-size: 14px;
    }
    
    .pcg-listings-table th,
    .pcg-listings-table td {
        padding: 10px;
    }
}

/* ==========================================================================
   Theme-aware overrides for older rules
   ========================================================================== */

/* Inputs follow the tokens instead of being forced white */
.pcg-input,
.pcg-select,
.pcg-input-file,
input[type="text"].pcg-input,
input[type="number"].pcg-input,
input[type="email"].pcg-input,
input[type="tel"].pcg-input,
textarea.pcg-input,
select.pcg-select {
    background-color: var(--pcg-input-bg) !important;
    color: var(--pcg-text) !important;
    border-color: var(--pcg-border);
}

/* Login / edit modals */
.pcg-modal-content {
    background: var(--pcg-surface);
    color: var(--pcg-text);
    border: 1px solid var(--pcg-border);
    border-radius: 14px;
}

.pcg-modal-content h2,
.pcg-modal-content h3,
.pcg-modal .pcg-auth-header h2 {
    color: var(--pcg-heading) !important;
}

.pcg-modal .pcg-auth-subtitle,
.pcg-modal-content p,
.pcg-modal-content label {
    color: var(--pcg-muted);
}

.pcg-modal-close {
    color: var(--pcg-muted);
}

.pcg-modal-close:hover {
    color: var(--pcg-heading);
}

.pcg-modal .pcg-back-to-methods {
    background: none;
    border: none;
    color: var(--pcg-muted);
    cursor: pointer;
    padding: 0;
    margin-bottom: 10px;
}

@media (max-width: 768px) {
    .pcg-single-listing .pcg-listing-details,
    .pcg-single-listing .pcg-description-section {
        padding: 20px;
    }
}

/* ==========================================================================
   1.8.0 — Submit form, image picker, edit modal (theme tokens, mobile-first)
   ========================================================================== */

.pcg-sf {
    max-width: 760px;
    padding: 12px 0 40px;
}

.pcg-sf .pcg-form-group { margin-bottom: 16px; }
.pcg-sf .pcg-sf-card > .pcg-form-group:last-child { margin-bottom: 0; }
.pcg-sf .pcg-form-row { margin-bottom: 0; }
.pcg-sf .pcg-form-row > .pcg-form-group { margin-bottom: 16px; }

.pcg-sf-card {
    background: var(--pcg-surface);
    border: 1px solid var(--pcg-border);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: var(--pcg-shadow);
}

.pcg-sf-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 14px !important;
    font-size: 17px !important;
    line-height: 1.3;
    color: var(--pcg-heading) !important;
}

.pcg-sf-step {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--pcg-chip-bg);
    color: var(--pcg-chip-text);
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.pcg-sf label,
.pcg-modal-content .pcg-form-group > label {
    color: var(--pcg-text) !important;
    font-weight: 600;
    font-size: 14px;
}

.pcg-optional {
    font-weight: 400;
    color: var(--pcg-muted);
    font-size: 13px;
}

/* Inputs: one look for every field (no white boxes in dark mode) */
.pcg-sf .pcg-input,
.pcg-sf .pcg-select,
.pcg-modal-content .pcg-input,
.pcg-modal-content .pcg-select {
    width: 100%;
    min-height: 46px;
    padding: 11px 14px;
    border: 1px solid var(--pcg-border) !important;
    border-radius: 10px;
    background-color: var(--pcg-input-bg) !important;
    color: var(--pcg-text) !important;
    font-size: 16px; /* 16px stops iOS zooming into the field */
    line-height: 1.4;
    box-sizing: border-box;
    box-shadow: none;
    transition: border-color .15s, box-shadow .15s;
}

.pcg-sf .pcg-input::placeholder,
.pcg-modal-content .pcg-input::placeholder {
    color: var(--pcg-muted);
    opacity: .75;
}

.pcg-sf .pcg-input:focus,
.pcg-sf .pcg-select:focus,
.pcg-modal-content .pcg-input:focus,
.pcg-modal-content .pcg-select:focus {
    outline: none;
    border-color: var(--pcg-accent) !important;
    box-shadow: 0 0 0 3px var(--pcg-chip-bg);
}

.pcg-sf .pcg-input.pcg-invalid,
.pcg-sf .pcg-select.pcg-invalid {
    border-color: var(--pcg-danger) !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .15);
}

.pcg-sf textarea.pcg-input,
.pcg-modal-content textarea.pcg-input {
    font-family: inherit;
    min-height: 150px;
    resize: vertical;
}

.pcg-input-prefix {
    position: relative;
}

.pcg-input-prefix > span {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--pcg-muted);
    font-size: 15px;
    pointer-events: none;
}

.pcg-sf .pcg-input-prefix .pcg-input {
    padding-left: 44px;
}

.pcg-check {
    display: inline-flex !important;
    align-items: center;
    gap: 10px;
    margin: 10px 0 0 !important;
    font-weight: 500 !important;
    cursor: pointer;
    min-height: 32px;
}

.pcg-check input {
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--pcg-cta);
}

.pcg-sf .pcg-help-text {
    margin: 6px 0 0;
    font-size: 13px;
    color: var(--pcg-muted);
}

.pcg-char-count { float: right; }

.pcg-sf-actions {
    text-align: center;
}

.pcg-sf-submit,
.pcg-modal-content .pcg-button-primary {
    background: var(--pcg-cta) !important;
    color: var(--pcg-cta-text) !important;
    border: 0 !important;
    border-radius: 10px !important;
    font-weight: 700;
}

.pcg-sf-submit {
    width: 100%;
    min-height: 52px;
    font-size: 17px !important;
}

.pcg-sf-submit:hover,
.pcg-modal-content .pcg-button-primary:hover {
    background: var(--pcg-cta-hover) !important;
}

.pcg-sf-submit:disabled {
    opacity: .6;
    cursor: wait;
    transform: none;
}

.pcg-sf .pcg-notice,
.pcg-modal-content .pcg-notice {
    border-radius: 10px;
}

.pcg-notice-actions {
    margin-top: 10px;
}

/* Image picker ------------------------------------------------------------ */

.pcg-picker-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.pcg-picker-item,
.pcg-picker-add {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    overflow: hidden;
}

.pcg-picker-item {
    background: var(--pcg-surface-2);
    border: 1px solid var(--pcg-border);
}

.pcg-picker-item.is-cover {
    border: 2px solid var(--pcg-cta);
}

.pcg-picker-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pcg-picker-item.is-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 3px solid var(--pcg-border);
    border-top-color: var(--pcg-accent);
    animation: pcg-picker-spin .8s linear infinite;
}

@keyframes pcg-picker-spin { to { transform: rotate(360deg); } }

.pcg-picker-badge {
    position: absolute;
    left: 6px;
    bottom: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--pcg-cta);
    color: var(--pcg-cta-text);
    font-size: 11px;
    font-weight: 700;
}

.pcg-picker-btn {
    position: absolute;
    top: 6px;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .6) !important;
    color: #fff !important;
    font-size: 18px;
    line-height: 30px;
    text-align: center;
    cursor: pointer;
}

.pcg-picker-remove { right: 6px; }
.pcg-picker-make-cover { left: 6px; font-size: 14px; }
.pcg-picker-btn:hover { background: rgba(0, 0, 0, .85) !important; }

.pcg-picker-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 100%;
    padding: 0;
    border: 2px dashed var(--pcg-border) !important;
    background: var(--pcg-input-bg) !important;
    color: var(--pcg-muted) !important;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}

.pcg-picker-add:hover,
.pcg-picker-add:focus-visible {
    border-color: var(--pcg-accent) !important;
    color: var(--pcg-accent) !important;
}

.pcg-picker-plus {
    font-size: 28px;
    line-height: 1;
    font-weight: 400;
}

.pcg-picker-msg {
    margin: 8px 0 0;
    font-size: 13px;
    color: var(--pcg-danger);
}

/* Edit Listing modal (My Classifieds) ------------------------------------- */

#pcg-edit-modal {
    z-index: 1000000;
}

#pcg-edit-modal,
#pcg-edit-modal * {
    box-sizing: border-box;
}

#pcg-edit-modal .pcg-modal-content {
    max-width: 640px;
    padding: 22px;
    margin: 4vh auto;
}

#pcg-edit-modal .pcg-edit-warning {
    background: var(--pcg-warn-bg);
    color: var(--pcg-warn-text);
    border: 1px solid transparent;
    border-left: 4px solid #f59e0b;
    border-radius: 10px;
    font-size: 14px;
}

#pcg-edit-modal .pcg-edit-actions {
    display: flex;
    gap: 10px;
}

#pcg-edit-modal .pcg-edit-actions .pcg-button {
    flex: 1;
    min-height: 46px;
    border-radius: 10px;
}

body.pcg-modal-open { overflow: hidden; }

/* Mobile ------------------------------------------------------------------ */

@media (max-width: 600px) {
    .pcg-sf { padding: 4px 0 90px; }

    .pcg-sf-card {
        padding: 14px;
        border-radius: 12px;
        margin-bottom: 12px;
    }

    .pcg-sf .pcg-form-row,
    .pcg-modal-content .pcg-form-row {
        flex-direction: column;
        gap: 0;
    }

    .pcg-sf .pcg-col-6,
    .pcg-modal-content .pcg-col-6 {
        min-width: 0;
        width: 100%;
        margin-bottom: 16px;
    }

    .pcg-picker-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    /* Submit stays reachable at the bottom of the screen */
    .pcg-sf-actions {
        position: sticky;
        bottom: 0;
        z-index: 5;
        margin: 0 -4px;
        padding: 10px 4px calc(10px + env(safe-area-inset-bottom));
        background: linear-gradient(to top, var(--pcg-surface-2) 70%, transparent);
    }

    .pcg-sf-actions .pcg-help-text { display: none; }

    /* Edit modal becomes a full-height bottom sheet */
    #pcg-edit-modal .pcg-modal-content {
        width: 100%;
        max-width: none;
        min-height: 100%;
        margin: 0;
        border-radius: 0;
        padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    }
}
