/* ========================================================
   My Capetown - Base Stylesheet
   Light theme, mobile-first, card-based listing grid
   ======================================================== */

:root {
    --primary: #1E3A5F;       /* navy - header, nav, headings */
    --primary-dark: #142940;  /* darker navy for hover states */
    --accent: #56CFE1;        /* cyan - active chips, highlights */
    --cta: #FF7F50;           /* orange - primary action buttons */
    --cta-dark: #e6653a;      /* darker orange for hover */
    --bg: #FAFAFA;            /* very light, near-white page background */
    --card-bg: #FFFFFF;       /* white card background */
    --text: #333333;
    --text-muted: #6b6b63;
    --border: #e7e2d6;
    --danger: #b3261e;
    --danger-bg: #fce8e6;
    --success: #2e7d5b;
    --success-bg: #e8f5e9;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding-bottom: 84px; /* space for taller fixed bottom nav */
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Top header --- */
.site-header {
    background: #FFFFFF;
    color: var(--primary);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border);
}
.site-header .brand {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.site-header .brand:hover { text-decoration: none; }

/* --- Page container --- */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
}

/* --- Category chips / filter --- */
.category-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
}
.category-chips::-webkit-scrollbar { display: none; }
.chip {
    flex: 0 0 auto;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 7px 14px;
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
}
.chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--primary-dark);
    font-weight: 600;
}
.chip:hover { text-decoration: none; }

/* --- Listing grid --- */
.listing-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
@media (min-width: 480px) {
    .listing-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
}
@media (min-width: 700px) {
    .listing-grid { grid-template-columns: 1fr 1fr 1fr; }
}

.listing-card {
    background: linear-gradient(180deg, #FFFFFF 0%, #FBFBFD 100%);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    display: block;
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.listing-card:hover {
    text-decoration: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06), 0 8px 20px rgba(0,0,0,0.06);
    transform: translateY(-2px);
}
.listing-card .thumb {
    width: 100%;
    aspect-ratio: 25 / 12;
    background: #eef1f0;
    overflow: hidden;
}
.listing-card .thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.listing-card .info { padding: 10px; }
.listing-card .name {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 2px;
    line-height: 1.3;
}
.listing-card .snippet {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

/* --- Premium/Featured listing badge --- */
.premium-card {
    position: relative;
}
.premium-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--cta);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 12px;
    z-index: 2;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* --- Listing detail page --- */
.detail-gallery {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
}
.detail-gallery img {
    width: 240px;
    height: 180px;
    object-fit: cover;
    border-radius: 12px;
    flex: 0 0 auto;
}
.detail-title { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.detail-category {
    display: inline-block;
    background: #e8f5ee;
    color: var(--primary-dark);
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 12px;
}
.detail-description {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-line;
    margin-bottom: 20px;
}

@media (min-width: 1024px) {
    .detail-layout {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 40px;
        align-items: start;
    }
    .detail-gallery {
        flex-direction: column;
        overflow-x: visible;
        margin-bottom: 0;
    }
    .detail-gallery img {
        width: 100%;
        height: 340px;
    }
    .detail-info { padding-top: 4px; }
    .detail-title { font-size: 28px; }
}
.whatsapp-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #25D366;
    color: #fff;
    padding: 12px 20px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 15px;
}
.whatsapp-btn:hover { text-decoration: none; opacity: 0.92; }

/* --- Forms (shared across login/setup/post-ad/admin) --- */
.box {
    max-width: 440px;
    margin: 24px auto;
    background: linear-gradient(180deg, #FFFFFF 0%, #FBFBFD 100%);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 14px rgba(0,0,0,0.04);
}
.box h1 { font-size: 20px; margin-top: 0; }
.box label { display: block; margin-top: 14px; font-size: 14px; color: var(--text); }
.box input, .box select, .box textarea {
    width: 100%;
    padding: 10px;
    margin-top: 4px;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 15px;
    font-family: inherit;
}
.box button {
    margin-top: 20px;
    width: 100%;
    padding: 12px;
    background: linear-gradient(180deg, #FF8F65 0%, var(--cta) 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(255,127,80,0.3);
}
.box button:hover { background: var(--cta-dark); }
.error {
    color: var(--danger);
    background: var(--danger-bg);
    padding: 10px;
    border-radius: 8px;
    margin-top: 14px;
    font-size: 14px;
}
.success {
    color: var(--success);
    background: var(--success-bg);
    padding: 10px;
    border-radius: 8px;
    margin-top: 14px;
    font-size: 14px;
}
.hint { font-size: 13px; color: var(--text-muted); margin-top: 10px; }

/* --- Fixed mobile bottom nav --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 20;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 0 8px;
    font-size: 13px;
    color: var(--text-muted);
    gap: 3px;
    min-height: 56px;
}
.bottom-nav a:hover { text-decoration: none; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav .icon { font-size: 24px; line-height: 1; }
.whatsapp-nav-link span:last-child { color: #25D366; font-weight: 600; }

/* --- Desktop top navigation (hidden on mobile, shown at desktop breakpoint) --- */
.desktop-nav {
    display: none;
    align-items: center;
    gap: 24px;
}
.desktop-nav a {
    color: var(--primary);
    font-size: 15px;
    font-weight: 500;
    opacity: 0.75;
}
.desktop-nav a:hover { opacity: 1; text-decoration: none; }
.desktop-nav a.active { opacity: 1; font-weight: 700; }
.desktop-nav .nav-cta {
    background: var(--cta);
    color: #fff;
    padding: 8px 18px;
    border-radius: 20px;
    font-weight: 600;
    opacity: 1;
}
.desktop-nav .nav-cta:hover { background: var(--cta-dark); opacity: 1; }
.desktop-nav .nav-pill {
    background: rgba(30,58,95,0.08);
    padding: 8px 16px;
    border-radius: 20px;
}

/* --- Desktop layout: wider container, more grid columns, top nav instead of bottom nav --- */
@media (min-width: 1024px) {
    body { padding-bottom: 0; }

    .container { max-width: 1140px; padding: 24px; }

    .site-header { padding: 16px 32px; }
    .site-header .brand { font-size: 22px; }

    .bottom-nav { display: none; }
    .desktop-nav { display: flex; }

    .listing-grid { grid-template-columns: repeat(4, 1fr); gap: 20px; }

    .category-chips { margin-bottom: 24px; }

    .box { max-width: 520px; }

    .owner-subnav { display: none; }
}
