@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;800&family=Poppins:wght@400;600;800&display=swap');

:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --accent-color: #3b82f6;
    --accent-hover: #60a5fa;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --danger-gradient: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    --muted-color: #94a3b8;
    --success-color: #4ade80;
    --warning-color: #fbbf24;
    --info-color: #60a5fa;
    --danger-color: #f87171;

    /* Fallback used until header-scroll.js measures the real, rendered
       header height (which varies with viewport width / nav wrapping) and
       overrides this. Keeps `body`'s padding-top roughly correct for the
       first paint so content doesn't briefly render under the header. */
    --header-height: 84px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    /* header is position: fixed, so reserve space for it here instead. */
    padding-top: var(--header-height);
}

/* ── Global link colours (dark background) ──────────────────────────────────
   Browser defaults (dark blue / purple) are illegible on --bg-color (#0f172a).
   Scope to `body a` so the cascade doesn't fight button/nav overrides, and use
   :not() guards to leave button-shaped elements alone. */
body a:not([class*="bb-btn"]):not([class*="bb-brand"]):not([class*="bb-nav"]) {
    color: #60a5fa;               /* --accent-hover: light blue, WCAG AA on dark */
    text-decoration: none;
    transition: color 0.2s ease;
}
body a:not([class*="bb-btn"]):not([class*="bb-brand"]):not([class*="bb-nav"]):visited {
    color: #a78bfa;               /* light lavender — readable, distinct from unvisited */
}
body a:not([class*="bb-btn"]):not([class*="bb-brand"]):not([class*="bb-nav"]):hover,
body a:not([class*="bb-btn"]):not([class*="bb-brand"]):not([class*="bb-nav"]):focus-visible {
    color: #bfdbfe;               /* even lighter blue on hover */
    text-decoration: underline;
}

/* Background Animation */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.15) 0%, transparent 40%),
                radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.15) 0%, transparent 40%);
    z-index: -1;
    animation: rotateBg 30s linear infinite;
}

@keyframes rotateBg {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

header {
    padding: 20px 50px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 100;
    transition: transform 0.3s ease;
}

/* Auto-hide header: header-scroll.js toggles this class while scrolling
   down (and removes it on scroll-up / near the top of the page), so the
   header slides away instead of permanently occupying screen space - see
   the @media (max-width: 768px) block for why that matters on phones.
   Shared between the main site (`header`) and the marketplace
   (`.bb-header`, defined in bb/static/bb/style.css which imports this
   file). */
header.header--hidden,
.bb-header.header--hidden {
    transform: translateY(-100%);
}

@media (prefers-reduced-motion: reduce) {
    header,
    .bb-header {
        transition: none;
    }
}

/* Upload-in-progress overlay - see static/js/upload-spinner.js.
   Shown whenever a multipart form with selected files is submitted, to
   block double-submits while bytes are in flight. */
.upload-spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    z-index: 1100;
}
.upload-spinner {
    width: 56px;
    height: 56px;
    border: 5px solid rgba(255, 255, 255, 0.12);
    border-top-color: #60a5fa;
    border-radius: 50%;
    animation: upload-spin 0.75s linear infinite;
}
@keyframes upload-spin {
    to { transform: rotate(360deg); }
}
.upload-spinner-label {
    color: #cbd5e1;
    font-size: 1rem;
    letter-spacing: 0.03em;
}

/* Themed yes/no confirmation dialog - see static/js/confirm-dialog.js.
   Shared between the main site and the marketplace (bb/static/bb/style.css
   imports this file). */
.confirm-dialog-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.confirm-dialog {
    width: 100%;
    max-width: 380px;
    background: var(--bg-color);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
    padding: 24px;
}

.confirm-dialog-message {
    margin: 0 0 20px 0;
    color: var(--text-color);
}

.confirm-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.logo {
    font-family: 'Poppins', sans-serif;
    font-size: 1.8rem;
    font-weight: 800;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.05);
}

nav a {
    color: var(--text-color);
    text-decoration: none;
    margin-left: 30px;
    font-weight: 600;
    transition: color 0.3s ease;
    position: relative;
}

nav a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -5px;
    left: 0;
    background: var(--gradient);
    transition: width 0.3s ease;
}

nav a:hover {
    color: var(--accent-hover);
}

nav a:hover::after {
    width: 100%;
}

main {
    flex: 1;
    padding: 50px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    animation: fadeIn 1s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

h1, h2, h3 {
    font-family: 'Poppins', sans-serif;
    margin-bottom: 20px;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--glass-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin-bottom: 30px;
}

.glass-panel:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
}

.btn {
    display: inline-block;
    padding: 12px 28px;
    border-radius: 30px;
    background: var(--gradient);
    color: white;
    text-decoration: none;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.btn:active {
    transform: translateY(1px);
}

/* Dashboard specific */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 30px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 30px;
}

.stat-card .value {
    font-size: 3rem;
    font-weight: 800;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

.stat-card .label {
    font-size: 1.1rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Homepage "Browse by Topic" quick-start widget */
.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 30px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.95rem;
    transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.chip:hover {
    transform: translateY(-2px);
    border-color: rgba(59, 130, 246, 0.6);
    color: #fff;
}

.chip .count {
    color: #94a3b8;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 2px 8px;
}

/* ==========================================================================
   Shared design-system components
   These tokens/classes are reused by the marketplace app's stylesheet
   (bb/static/bb/style.css, imported on top of this file) so every view in
   Romp - homepage, auth pages, and the marketplace - shares one visual
   language.
   ========================================================================== */

/* Button variants (base .btn is defined above) */
.btn-secondary {
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--glass-border);
    box-shadow: none;
}

.btn-secondary:hover {
    border-color: var(--accent-hover);
    color: var(--accent-hover);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--danger-gradient);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.35);
}

.btn-danger:hover {
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.55);
}

.btn-sm {
    padding: 8px 18px;
    font-size: 0.85rem;
}

/* Status / count badges - generic palette, reused for announcement, offer
   and deal statuses across the marketplace. */
.badge {
    display: inline-block;
    text-transform: uppercase;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--muted-color);
    white-space: nowrap;
}

.badge-success { color: var(--success-color); border-color: rgba(74, 222, 128, 0.4); background: rgba(74, 222, 128, 0.1); }
.badge-info    { color: var(--info-color);    border-color: rgba(96, 165, 250, 0.4); background: rgba(96, 165, 250, 0.1); }
.badge-warning { color: var(--warning-color); border-color: rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.1); }
.badge-danger  { color: var(--danger-color);  border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.1); }

/* Auth forms (login / signup) - wrap Django's {{ form.as_p }} output in a
   <div class="auth-form"> to pick up glass-themed inputs. */
.auth-form {
    max-width: 420px;
    margin: 0 auto;
    text-align: left;
}

.auth-form p {
    margin: 0 0 18px 0;
}

.auth-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #cbd5e1;
}

.auth-form input,
.auth-form select,
.auth-form textarea {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-color);
    font: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-form input:focus,
.auth-form select:focus,
.auth-form textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.auth-form .helptext {
    display: block;
    font-size: 0.8rem;
    color: var(--muted-color);
    margin-top: 4px;
}

.auth-form ul.errorlist {
    color: var(--danger-color);
    font-size: 0.85rem;
    list-style: none;
    padding: 0;
    margin: 4px 0 0 0;
}

/* Recent-listings preview grid (used on the homepage) */
.listing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.listing-card {
    display: block;
    text-align: left;
    text-decoration: none;
    color: var(--text-color);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    transition: transform 0.25s ease, border-color 0.25s ease;
}

.listing-card:hover {
    transform: translateY(-4px);
    border-color: rgba(59, 130, 246, 0.5);
}

.listing-card .listing-title {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    margin-bottom: 8px;
}

.listing-card .listing-meta {
    font-size: 0.8rem;
    color: var(--muted-color);
}

.listing-card .listing-price {
    margin-top: 12px;
    font-weight: 800;
    font-size: 1.1rem;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

footer {
    text-align: center;
    padding: 30px;
    border-top: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: #94a3b8;
    font-size: 0.9rem;
}

/* ------------------------------------------------------------------ */
/* Responsive layout (tablets and phones)                              */
/*                                                                      */
/* The header is `position: fixed` (auto-hiding on scroll, see above)  */
/* on all viewport sizes. On narrow screens its nav wraps onto two     */
/* rows and gets taller, so we shrink things down and adjust the       */
/* reserved --header-height to match.                                  */
/* ------------------------------------------------------------------ */
@media (max-width: 768px) {
    /* The compact header still wraps onto two rows here, so it's taller
       than the desktop fallback above - update the reserved space to
       match (header-scroll.js fine-tunes this further once it measures
       the actual rendered height). */
    :root {
        --header-height: 96px;
    }

    header {
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px;
        padding: 16px 20px;
        text-align: center;
    }

    .logo {
        font-size: 1.5rem;
    }

    nav {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 16px;
        width: 100%;
    }

    nav a {
        margin-left: 0;
    }

    main {
        padding: 30px 20px;
    }

    .glass-panel {
        padding: 24px;
    }

    /* Hero/section headings use large inline font-sizes; !important is
       needed to override those for narrow viewports. */
    h1 {
        font-size: 2rem !important;
    }

    h2 {
        font-size: 1.5rem !important;
    }

    h3 {
        font-size: 1.2rem;
    }

    footer {
        padding: 20px;
    }
}
