/* ------------------------------------------------
   Base & Layout
------------------------------------------------ */
:root {
    --primary: #0a1430;
    --primary-dark: #050b18;
    --accent: #f7a705;
    --accent-dark: #d98800;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --radius-lg: 28px;
    --shadow-lg: 0 30px 50px -28px rgba(15, 23, 42, 0.45);
    --shadow-md: 0 20px 35px -25px rgba(15, 23, 42, 0.35);
    --shadow-sm: 0 10px 25px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

img {
    max-width: 100%;
    display: block;
}

a {
    text-decoration: none;
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

ul {
    list-style: none;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.container {
    width: min(1200px, 100%);
    margin: 0 auto;
    padding: 0 1.5rem;
}

footer {
    text-align: center;
    padding: 2rem 1rem 3rem;
    color: var(--muted);
    font-size: 0.9rem;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ------------------------------------------------
   Header & Navigation
------------------------------------------------ */
.main-header {
    background: var(--surface);
    padding: 1rem clamp(1.5rem, 4vw, 4rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}

.logo {
    font-weight: 900;
    font-size: 1.45rem;
    letter-spacing: 0.18rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-weight: 600;
    position: relative;
}

.nav-links.is-open {
    display: flex;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.nav-toggle {
    display: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.45rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.nav-toggle:hover {
    box-shadow: var(--shadow-sm);
}

.nav-toggle-icon {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.nav-toggle-bar {
    width: 26px;
    height: 3px;
    background: var(--text);
    border-radius: 999px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
    opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

.nav-item {
    color: var(--text);
    font-size: 0.95rem;
    padding: 0.35rem 0;
    position: relative;
    transition: color 0.2s ease, transform 0.2s ease;
}

.nav-item::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -6px;
    width: 100%;
    height: 2px;
    background: var(--accent);
    transform-origin: left;
    transform: scaleX(0);
    transition: transform 0.2s ease;
}

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

.nav-item:hover::after {
    transform: scaleX(1);
}

.caret {
    font-size: 0.7rem;
    margin-left: 4px;
    transition: transform 0.2s ease;
}

.dropdown.is-open .caret {
    transform: rotate(180deg);
}

.dropdown {
    position: relative;
    padding-bottom: 12px;
    margin-bottom: -12px;
}

.dropdown > .nav-item,
.btn-profile {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dropdown-toggle {
    border: none;
    background: none;
    font: inherit;
    color: inherit;
    padding: 0;
    cursor: pointer;
    text-align: left;
}

.dropdown-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
}

.dropdown-content {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 220px;
    background: var(--surface);
    border-radius: 18px;
    padding: 0.75rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 200;
}

.dropdown-content a {
    display: block;
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    color: var(--text);
    font-weight: 500;
}

.dropdown-content a:hover {
    background: #f8fafc;
    color: var(--primary);
}

.dropdown:hover .dropdown-content,
.dropdown:focus-within .dropdown-content,
.dropdown-content:hover,
.dropdown.is-open .dropdown-content {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.btn-profile {
    background: #eef2ff;
    color: var(--primary);
    padding: 0.45rem 1.25rem;
    border-radius: 999px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid rgba(99, 102, 241, 0.25);
}

@media (max-width: 900px) {
    .main-header {
        flex-wrap: wrap;
        gap: 0.75rem;
        align-items: center;
        padding: 0.85rem clamp(1rem, 4vw, 2rem);
    }

    .nav-toggle {
        display: inline-flex;
    }

    .nav-links {
        width: 100%;
        display: none;
        flex-direction: column;
        gap: 0.5rem;
        padding-top: 0.75rem;
        border-top: 1px solid rgba(226, 232, 240, 0.6);
    }

    .nav-links.is-open {
        display: flex;
    }

    .nav-item {
        width: 100%;
    }

    .dropdown {
        width: 100%;
    }

    .dropdown-toggle {
        justify-content: space-between;
        width: 100%;
    }

    .dropdown-content {
        position: static;
        opacity: 1;
        pointer-events: auto;
        transform: none;
        box-shadow: none;
        border: none;
        padding: 0.35rem 0 0;
        display: none;
    }

    .dropdown.is-open .dropdown-content {
        display: block;
    }

    .btn-profile {
        width: 100%;
        justify-content: center;
    }
}

/* ------------------------------------------------
   Hero & Search
------------------------------------------------ */
.hero {
    background: radial-gradient(circle at 20% 20%, #122248 0%, #050b1f 55%);
    color: white;
    padding: clamp(3rem, 8vw, 6rem) 1rem clamp(6rem, 11vw, 8rem);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::after {
    content: '';
    position: absolute;
    inset: 20% auto auto 55%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.18), transparent 65%);
    filter: blur(4px);
    opacity: 0.7;
    pointer-events: none;
}

.hero .container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.hero h1 {
    font-size: clamp(2.4rem, 4vw, 3.75rem);
    font-weight: 900;
    letter-spacing: -1px;
}

.hero p {
    font-size: 1.2rem;
    opacity: 0.85;
    max-width: 620px;
}

.search-container {
    width: 100%;
    max-width: 760px;
    background: var(--surface);
    border-radius: 999px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.5rem 0.5rem 1.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.15);
    position: relative;
    z-index: 15;
    margin-bottom: clamp(1.25rem, 3vw, 2.75rem);
}

.search-container input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--primary);
    font-size: 1.05rem;
    padding: 0.75rem 0;
    outline: none;
}

.search-container input::placeholder {
    color: #94a3b8;
}

.btn-search {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.9rem 2.25rem;
    border-radius: 999px;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 12px 20px rgba(247, 167, 5, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-search:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 28px rgba(247, 167, 5, 0.45);
}

/* ------------------------------------------------
   Filter Bar
------------------------------------------------ */
.filter-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr) auto;
    gap: 1.2rem;
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 24px;
    margin: -40px auto 2.8rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    align-items: end;
    position: relative;
    z-index: 10;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    min-width: 0;
}

.filter-group label {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08rem;
    color: var(--muted);
}

.filter-group select,
.filter-group input {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.85rem 1rem;
    background: #f8fafc;
    font-weight: 600;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.filter-group select:focus,
.filter-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(247, 167, 5, 0.2);
}

.price-range-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.price-range-inputs span {
    color: var(--muted);
    font-weight: 800;
    font-size: 0.8rem;
}

.price-range-inputs input {
    min-width: 0;
}

.btn-filter {
    height: 48px;
    border-radius: 16px;
    border: none;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.btn-filter:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* ------------------------------------------------
   Listing Grid
------------------------------------------------ */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, 0.8);
    display: flex;
    flex-direction: column;
    min-height: 100%;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-md);
    border-color: #cbd5f5;
}

.card-img {
    height: 240px;
    background: #e2e8f0;
    position: relative;
    overflow: hidden;
}

.card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.card:hover .card-img img {
    transform: scale(1.04);
}

.price-tag {
    position: absolute;
    right: 20px;
    bottom: 20px;
    background: var(--primary);
    color: #fff;
    padding: 0.6rem 1rem;
    border-radius: 16px;
    font-weight: 900;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    box-shadow: 0 12px 25px -10px rgba(15, 23, 42, 0.7);
}

.price-unit {
    font-size: 0.65rem;
    opacity: 0.8;
    text-transform: uppercase;
}

.card-content {
    padding: 1.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
}

.card-title {
    font-size: 1.35rem;
    font-weight: 900;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.card-meta {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.92rem;
    color: var(--muted);
    font-weight: 600;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.card-meta span {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.rating {
    color: var(--accent);
    font-weight: 700;
}

.no-rating {
    font-size: 0.8rem;
    font-weight: 500;
    color: #94a3b8;
}

/* ------------------------------------------------
   Responsive Tweaks
------------------------------------------------ */
@media (min-width: 1280px) {
    .grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 1024px) {
    .filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-top: -40px;
    }
}

@media (max-width: 768px) {
    .hero h1 {
        font-size: 2.4rem;
    }

    .search-container {
        flex-direction: column;
        border-radius: 32px;
        padding: 1rem;
    }

    .btn-search {
        width: 100%;
    }

    .filter-bar {
        grid-template-columns: 1fr;
        margin-top: 1.5rem;
    }

    .btn-filter {
        width: 100%;
    }
}

@media (max-width: 540px) {
    .main-header {
        padding: 0.85rem 1rem;
    }
}

/* ------------------------------------------------
   Generic Tables & Forms (secondary pages)
------------------------------------------------ */
form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

form label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

form input,
form textarea,
form select,
form button {
    border-radius: 12px;
    border: 1px solid var(--border);
    font-size: 1rem;
}

form input,
form textarea,
form select {
    padding: 0.85rem 1rem;
    background: var(--surface);
    color: var(--text);
}

form textarea {
    min-height: 140px;
    resize: vertical;
}

form button {
    background: var(--primary);
    color: #fff;
    padding: 0.9rem 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

form button:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background: var(--surface);
    border-radius: 18px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

th,
td {
    padding: 0.9rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

th {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: var(--muted);
    background: #f8fafc;
    font-weight: 700;
}

tr:last-child td {
    border-bottom: none;
}

.alert {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 1.25rem;
    font-size: 0.92rem;
}

.alert-error {
    background: #fdf2f4;
    color: #b42318;
    border: 1px solid #fecdd3;
}

.alert-success {
    background: #f2fbf4;
    color: #167e31;
    border: 1px solid #c5f0d1;
}

/* ------------------------------------------------
   Auth / Registration
------------------------------------------------ */
.login-container,
.form-container {
    background: var(--surface);
    width: min(500px, 100%);
    margin: 4rem auto;
    padding: 2.5rem;
    border-radius: 24px;
    box-shadow: var(--shadow-sm);
}

.login-container h2,
.form-container h2 {
    color: var(--primary);
    margin-bottom: 1.5rem;
    text-align: center;
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 700;
    color: #374151;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    background: #fff;
}

.form-group textarea {
    min-height: 150px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(247, 167, 5, 0.2);
}

.btn-submit {
    width: 100%;
    background-color: var(--accent);
    color: #fff;
    padding: 0.9rem;
    border: none;
    border-radius: 999px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
}

.btn-submit:hover {
    background-color: var(--accent-dark);
    transform: translateY(-1px);
}

.signup-link,
.login-link {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: #666;
}

.signup-link a,
.login-link a {
    color: var(--accent);
    font-weight: 700;
    text-decoration: underline;
}

.account-type-toggle {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.type-option {
    flex: 1;
    text-align: center;
    position: relative;
}

.type-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.type-label {
    display: block;
    padding: 0.8rem;
    background-color: #f8f9fa;
    border: 2px solid #eee;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    color: #555;
    transition: all 0.2s ease;
}

.type-option input[type="radio"]:checked ~ .type-label {
    background-color: #fffaf0;
    border-color: var(--accent);
    color: var(--accent-dark);
}

#company_fields {
    display: none;
}

.name-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

/* ------------------------------------------------
   Listing Creation / Media Upload
------------------------------------------------ */
.page-header {
    width: min(1100px, 100%);
    margin: 2.5rem auto 1.25rem;
    padding: 0 1.5rem;
}

.page-header h1 {
    font-size: 2.4rem;
    font-weight: 900;
    color: var(--primary);
}

.listing-shell {
    width: min(1100px, 100%);
    margin: 0 auto 4rem;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: minmax(0, 2.6fr) minmax(260px, 1fr);
    gap: 2rem;
    align-items: flex-start;
}

.listing-main.form-container {
    width: 100%;
    margin: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

.listing-main form {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 2rem;
    box-shadow: var(--shadow-sm);
}

.section-heading {
    margin-bottom: 1.5rem;
}

.section-label {
    font-size: 0.72rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 800;
    margin-bottom: 0.35rem;
    display: inline-block;
}

.section-heading h3 {
    font-size: 1.4rem;
    color: var(--primary);
    margin-bottom: 0.4rem;
}

.section-heading p {
    color: var(--muted);
    font-size: 0.95rem;
}

.multi-col-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
}

.input-with-symbol {
    position: relative;
}

.input-with-symbol span {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-weight: 700;
}

.input-with-symbol input {
    padding-left: 2.1rem;
}

.listing-aside {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 6rem;
}

.tip-card + .tip-card {
    margin-top: 1.5rem;
}

.tip-card h4 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--primary);
}

.tip-card ul {
    list-style: disc;
    padding-left: 1.2rem;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.tip-card p {
    color: var(--muted);
    font-size: 0.95rem;
}

.photo-uploader {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.photo-slot {
    aspect-ratio: 1;
    border-radius: 18px;
    border: 2px dashed var(--border);
    background: #f8fafc;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1rem;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.photo-slot-placeholder {
    cursor: pointer;
    flex-direction: column;
    gap: 0.35rem;
    font-weight: 700;
}

.photo-slot-placeholder:hover {
    border-color: var(--accent);
    background: #fff8ec;
    color: var(--accent);
}

.photo-slot-filled {
    border: 1px solid var(--border);
    background: #fff;
    padding: 0;
}

.photo-slot-filled img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-remove {
    position: absolute;
    top: 12px;
    right: 12px;
    border: none;
    background: rgba(15, 23, 42, 0.78);
    color: #fff;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    cursor: pointer;
}

.photo-remove:hover {
    background: rgba(239, 68, 68, 0.9);
}

.main-badge {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(15, 23, 42, 0.85);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.photo-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.btn-add-photo {
    align-self: flex-start;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 0.85rem 1.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.btn-add-photo:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.photo-hint {
    font-size: 0.9rem;
    color: var(--muted);
}

.visually-hidden-inputs {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.form-actions {
    display: flex;
    justify-content: center;
}

.form-section-divider {
    display: none;
}

@media (max-width: 1024px) {
    .listing-shell {
        grid-template-columns: 1fr;
    }

    .listing-aside {
        position: static;
    }
}
