/* ===========================
   SWAPFACILE - STYLES (Craigslist theme)
   Craigslist colors:
     background: #fff
     text: #000
     links: #00c (visited: #551a8b)
     category headings: #800080
     borders: #000 (thin), #ccc/#ddd (light)
     footer links: #00c
   =========================== */

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: arial, helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #000;
    background: #fff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: #00c;
    text-decoration: none;
}
a:visited {
    color: #551a8b;
}
a:hover {
    text-decoration: underline;
}

/* ===========================
   HEADER (Craigslist style - minimal banner)
   =========================== */
#site-header {
    background: #800080;
    border-bottom: none;
    padding: 6px 0;
}
.header-inner {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo {
    text-decoration: none !important;
    margin-right: 20px;
}
.logo-cl {
    font-size: 24px;
    font-weight: bold;
    color: #fff;
    letter-spacing: -1px;
}
.header-left {
    display: flex;
    align-items: center;
}
.header-nav {
    display: flex;
    gap: 15px;
}
.header-nav .nav-link,
.auth-nav .nav-link {
    color: #ddb;
    font-size: 13px;
}
.header-nav .nav-link:hover,
.auth-nav .nav-link:hover {
    color: #fff;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.auth-nav {
    display: flex;
    gap: 12px;
    align-items: center;
}
.nav-username {
    color: #ff0;
    font-size: 13px;
    font-weight: bold;
}

/* ===========================
   MAIN CONTENT
   =========================== */
#app {
    max-width: 1000px;
    margin: 0 auto;
    padding: 10px 15px;
    width: 100%;
    flex: 1;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #888;
    font-style: italic;
}

/* ===========================
   HOMEPAGE
   =========================== */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    padding: 6px 0;
    background: transparent;
    border: none;
}
.search-bar input[type="text"] {
    flex: 1;
    padding: 4px 8px;
    font-size: 14px;
    border: 1px solid #000;
}
.search-bar button {
    padding: 4px 14px;
    background: #800080;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 14px;
}
.search-bar button:hover {
    background: #600060;
}

.categories-grid {
    display: flex;
    align-items: flex-start;
    border: 1px solid #000;
    background: #fff;
}
.categories-column {
    flex: 1;
    border-right: 1px solid #ccc;
    padding: 4px 0;
}
.categories-column:last-child {
    border-right: none;
}
.category-block {
    padding: 4px 10px;
    border-bottom: none;
}
.category-block h3 {
    font-size: 14px;
    margin-bottom: 2px;
    border-bottom: 1px solid #000;
    padding-bottom: 2px;
}
.category-block h3 a {
    color: #800080;
}
.category-block h3 a:visited {
    color: #800080;
}
.category-block ul {
    list-style: none;
    padding: 0;
}
.category-block ul li {
    font-size: 12px;
    line-height: 1.5;
}
.category-block ul li a {
    color: #00c;
}
.category-block ul li a:visited {
    color: #551a8b;
}
.category-block ul li a:hover {
    color: #00c;
}

/* ===========================
   LISTINGS PAGE
   =========================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #000;
}
.page-header h2 {
    font-size: 16px;
    font-weight: normal;
    color: #000;
}
.breadcrumb {
    font-size: 12px;
    color: #888;
    margin-bottom: 8px;
}
.breadcrumb a {
    color: #00c;
}
.breadcrumb span {
    margin: 0 4px;
    color: #aaa;
}

/* Filters bar */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 8px;
    background: #fff;
    border: 1px solid #ccc;
    margin-bottom: 12px;
    align-items: flex-end;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.filter-group label {
    font-size: 11px;
    color: #000;
    font-weight: bold;
    text-transform: uppercase;
}
.filter-group input,
.filter-group select {
    padding: 3px 6px;
    font-size: 13px;
    border: 1px solid #000;
    background: #fff;
}
.filter-group input[type="number"] {
    width: 100px;
}
.filters-bar .btn-filter {
    padding: 4px 12px;
    background: #800080;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 13px;
    align-self: flex-end;
}
.filters-bar .btn-filter:hover {
    background: #600060;
}

/* Listings list */
.listings-list {
    list-style: none;
}
.listing-row .btn-share {
    border: 1px solid #ccc;
    border-radius: 0;
    padding: 2px 6px;
}
.listing-row .btn-share:hover {
    background: #eee;
    border-color: #00c;
    color: #00c;
    text-decoration: none;
}
.listing-row {
    display: flex;
    gap: 12px;
    padding: 4px 2px;
    border-bottom: 1px solid #e0e0e0;
    transition: background 0.1s;
}
.listing-row:hover {
    background: #f0f0ff;
}
.listing-thumb {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border: 1px solid #ccc;
    background: #eee;
    flex-shrink: 0;
}
.listing-thumb-placeholder {
    width: 80px;
    height: 60px;
    background: #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #999;
    flex-shrink: 0;
    border: 1px solid #ccc;
}
.listing-info {
    flex: 1;
    min-width: 0;
}
.listing-title {
    font-size: 14px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.listing-title a {
    color: #00c;
}
.listing-meta {
    font-size: 11px;
    color: #888;
}
.listing-price {
    font-weight: bold;
    color: #000;
    font-size: 14px;
    white-space: nowrap;
}
.listing-date {
    font-size: 11px;
    color: #888;
    white-space: nowrap;
    text-align: right;
    min-width: 80px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
    padding: 10px;
}
.pagination a,
.pagination span {
    padding: 4px 10px;
    border: 1px solid #ccc;
    color: #00c;
    font-size: 13px;
    text-decoration: none;
}
.pagination span.active {
    background: #800080;
    color: #fff;
    border-color: #800080;
}
.pagination a:hover {
    background: #f0f0ff;
    text-decoration: none;
}

/* No results */
.no-results {
    text-align: center;
    padding: 40px;
    color: #888;
    font-style: italic;
}

/* ===========================
   LISTING DETAIL PAGE (Craigslist style)
   =========================== */
.cl-detail-page {
    background: #fff;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0;
}

/* Breadcrumb */
.cl-breadcrumb {
    font-size: 12px;
    color: #888;
    padding: 4px 0;
    margin-bottom: 6px;
}
.cl-breadcrumb a {
    color: #00c;
    text-decoration: none;
}
.cl-breadcrumb a:hover {
    text-decoration: underline;
}

/* Top bar with actions + posted time */
.cl-detail-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 8px;
}
.cl-detail-actions-left {
    display: flex;
    gap: 10px;
}
.cl-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: #00c;
    padding: 2px 6px;
    position: relative;
}
.cl-action-btn:hover {
    text-decoration: underline;
}
.cl-detail-posted {
    font-size: 12px;
    color: #888;
}

/* Title */
.cl-detail-title {
    font-size: 22px;
    font-weight: bold;
    color: #000;
    margin: 6px 0 2px 0;
    line-height: 1.3;
}

/* Subtitle (author) */
.cl-detail-subtitle {
    font-size: 13px;
    color: #888;
    margin-bottom: 14px;
}

/* Body: content + sidebar */
.cl-detail-body {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
}
.cl-detail-content {
    flex: 1;
    min-width: 0;
}
.cl-detail-sidebar {
    width: 280px;
    flex-shrink: 0;
    font-size: 13px;
    padding-top: 4px;
}

/* Attributes in sidebar */
.cl-attr {
    margin-bottom: 4px;
    line-height: 1.6;
}
.cl-attr-label {
    font-weight: bold;
    color: #000;
}
.cl-attr-value {
    color: #000;
}
.cl-attr-value a {
    color: #00c;
}

/* Gallery (Craigslist style) */
.cl-gallery {
    margin-bottom: 16px;
}
.cl-gallery-main {
    max-width: 100%;
    max-height: 450px;
    object-fit: contain;
    background: #fff;
    border: 1px solid #ccc;
    margin-bottom: 6px;
    display: block;
}
.cl-gallery-thumbs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.cl-gallery-thumbs img {
    width: 60px;
    height: 50px;
    object-fit: cover;
    border: 2px solid #ccc;
    cursor: pointer;
}
.cl-gallery-thumbs img.active,
.cl-gallery-thumbs img:hover {
    border-color: #00c;
}

/* Description section */
.cl-detail-section {
    padding: 12px 0;
    border-top: 1px solid #e0e0e0;
}
.cl-detail-description {
    line-height: 1.7;
    white-space: pre-wrap;
    font-size: 14px;
    color: #000;
}

/* Contact box */
.cl-detail-contact {
    border-top: 1px solid #e0e0e0;
    padding: 14px 0;
}
.cl-detail-contact h3 {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 6px;
    color: #000;
}
.cl-contact-name {
    font-size: 13px;
    color: #000;
    margin-bottom: 4px;
}
.cl-contact-info {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 13px;
    color: #000;
}
.cl-contact-info li {
    margin-bottom: 2px;
}
.cl-contact-info a {
    color: #00c;
}

/* Footer */
.cl-detail-footer {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #888;
    padding: 10px 0;
    border-top: 1px solid #e0e0e0;
    margin-top: 10px;
}

/* ===========================
   SHARE BUTTON
   =========================== */
.btn-share {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: #00c;
    white-space: nowrap;
    position: relative;
    align-self: center;
    flex-shrink: 0;
    padding: 2px 6px;
}
.btn-share:hover {
    text-decoration: underline;
}

/* Edit action link on detail page */
.cl-action-edit {
    color: #00c;
    text-decoration: none;
    font-weight: bold;
}
.cl-action-edit:hover {
    text-decoration: underline;
}
.cl-action-edit:visited {
    color: #00c;
}

/* Edit button in my-listings table */
.btn-edit-listing {
    background: #800080;
    color: #fff !important;
    text-decoration: none !important;
}
.btn-edit-listing:hover {
    background: #600060;
}
.btn-edit-listing:visited {
    color: #fff !important;
}

/* Print button */
.btn-print {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: #00c;
    white-space: nowrap;
    padding: 2px 6px;
}
.btn-print:hover {
    text-decoration: underline;
}

.share-tooltip {
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    animation: shareTooltipFade 2s ease forwards;
    z-index: 100;
}
.share-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
}
@keyframes shareTooltipFade {
    0%   { opacity: 1; }
    70%  { opacity: 1; }
    100% { opacity: 0; }
}

/* ===========================
   FORMS (Post, Login, Register)
   =========================== */
.form-page {
    max-width: 550px;
    margin: 0 auto;
}
.form-page h2 {
    font-size: 18px;
    font-weight: normal;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #000;
}
.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: bold;
    color: #000;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 6px 8px;
    font-size: 14px;
    border: 1px solid #000;
    font-family: inherit;
}
.form-group .city-autocomplete-wrapper input {
    width: 100%;
}
.form-group textarea {
    min-height: 120px;
    resize: vertical;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #00c;
    box-shadow: none;
}
.form-group small {
    font-size: 11px;
    color: #888;
}
.form-group .image-preview-container {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.image-preview-wrapper {
    position: relative;
    display: inline-block;
}
.form-group .image-preview {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border: 1px solid #ccc;
    display: block;
}
.image-preview-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #c00;
    color: #fff;
    border: none;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    padding: 0;
}
.image-preview-remove:hover {
    background: #900;
}

.btn {
    display: inline-block;
    padding: 6px 16px;
    font-size: 14px;
    border: none;
    cursor: pointer;
    text-decoration: none;
}
.btn-primary {
    background: #800080;
    color: #fff;
}
.btn-primary:hover {
    background: #600060;
}
.btn-danger {
    background: #c00;
    color: #fff;
}
.btn-danger:hover {
    background: #a00;
}
.btn-secondary {
    background: #888;
    color: #fff;
}
.btn-secondary:hover {
    background: #666;
}
.btn-small {
    padding: 3px 8px;
    font-size: 12px;
}

/* Alert messages */
.alert {
    padding: 10px 15px;
    margin-bottom: 15px;
    font-size: 13px;
    border: 1px solid;
}
.alert-error {
    background: #fdd;
    border-color: #c99;
    color: #900;
}
.alert-success {
    background: #dfd;
    border-color: #9c9;
    color: #060;
}
.alert-info {
    background: #def;
    border-color: #9ce;
    color: #036;
}

/* ===========================
   MY LISTINGS / ACCOUNT
   =========================== */
.my-listings-table {
    width: 100%;
    border-collapse: collapse;
}
.my-listings-table th,
.my-listings-table td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid #ccc;
    font-size: 13px;
}
.my-listings-table th {
    background: #f0f0f0;
    font-size: 11px;
    text-transform: uppercase;
    color: #000;
}
.my-listings-table tr:hover {
    background: #f0f0ff;
}
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 3px;
    font-weight: bold;
}
.status-active {
    background: #dfd;
    color: #060;
}
.status-expired {
    background: #ffd;
    color: #960;
}
.actions-cell {
    display: flex;
    gap: 5px;
}

/* ===========================
   FOOTER
   =========================== */
#site-footer {
    background: #fff;
    border-top: 1px solid #ccc;
    padding: 10px 0;
    margin-top: auto;
}
.footer-inner {
    max-width: 1000px;
    margin: 0 auto;
    text-align: center;
    font-size: 11px;
    color: #888;
}

/* ===========================
   CITY AUTOCOMPLETE
   =========================== */
.city-autocomplete-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}
.filter-group-city {
    min-width: 180px;
}
#filter-location {
    padding-right: 24px;
}
.city-suggestions {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #000;
    border-top: none;
    list-style: none;
    margin: 0;
    padding: 0;
    z-index: 1000;
    max-height: 240px;
    overflow-y: auto;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.city-suggestion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 8px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid #eee;
    transition: background 0.1s;
}
.city-suggestion-item:last-child {
    border-bottom: none;
}
.city-suggestion-item:hover {
    background: #f0f0ff;
}
.city-suggestion-item .city-name {
    font-weight: bold;
    color: #000;
}
.city-suggestion-item .city-dept {
    font-size: 11px;
    color: #888;
    margin-left: 8px;
    white-space: nowrap;
}

/* City selector (homepage) */
.city-selector {
    margin-bottom: 10px;
    padding: 6px 8px;
    background: #fff;
    border: 1px solid #ccc;
}
.city-selector-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 400px;
}
.city-selector-icon {
    font-size: 16px;
    color: #800080;
}
.city-selector-inner .city-autocomplete-wrapper {
    flex: 1;
}
.city-selector-inner input {
    width: 100%;
    padding: 4px 8px;
    font-size: 14px;
    border: 1px solid #000;
}
.city-selector-inner input:focus {
    outline: none;
    border-color: #00c;
    box-shadow: none;
}

/* Homepage city indicator */
.homepage-city {
    text-align: center;
    padding: 6px 0;
    font-size: 13px;
    color: #000;
}
.homepage-city-icon {
    color: #800080;
    margin-right: 4px;
}
.homepage-city strong {
    color: #800080;
}

/* Location indicator on listings page */
.location-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    margin-bottom: 8px;
    font-size: 12px;
    color: #000;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 0;
}
.location-indicator-icon {
    color: #800080;
    font-size: 14px;
}
.location-indicator strong {
    color: #800080;
}
.remove-location-filter {
    color: #c00;
    font-size: 14px;
    font-weight: bold;
    text-decoration: none !important;
    cursor: pointer;
    margin-left: 2px;
}
.remove-location-filter:hover {
    color: #f00;
}
.all-cities-link {
    color: #00c;
    font-size: 12px;
    margin-left: 6px;
    text-decoration: underline;
}
.all-cities-link:hover {
    color: #00f;
}

/* Clear location button in filter */
.btn-clear-location {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.btn-clear-location:hover {
    color: #c00;
}
.filter-group-city .city-autocomplete-wrapper {
    position: relative;
}

/* Language switcher */
.lang-switcher {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-right: 10px;
}
.lang-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.4);
    color: #ddb;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 7px;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.15s, color 0.15s;
}
.lang-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}
.lang-btn.lang-active {
    background: #ff0;
    color: #000;
    border-color: #ff0;
}
.lang-sep {
    color: rgba(255,255,255,0.4);
    font-size: 12px;
    margin: 0 1px;
}

/* Header city display */
.header-city {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #ddb;
    margin-right: 10px;
}
.header-city-icon {
    color: #ff0;
    font-size: 14px;
}
.header-city strong {
    color: #ff0;
}
.header-city a {
    color: #ddb;
    font-size: 11px;
    text-decoration: underline;
}
.header-city a:hover {
    color: #fff;
}

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 768px) {
    .categories-grid {
        flex-wrap: wrap;
    }
    .categories-column {
        flex: 1 1 50%;
        min-width: 50%;
    }
    .header-inner {
        flex-direction: column;
        gap: 8px;
    }
    .header-left {
        flex-direction: column;
        gap: 5px;
    }
    .filters-bar {
        flex-direction: column;
    }
    .listing-row {
        flex-wrap: wrap;
    }
    .listing-date {
        width: 100%;
        text-align: left;
    }
    .cl-detail-body {
        flex-direction: column;
    }
    .cl-detail-sidebar {
        width: 100%;
    }
    .cl-detail-topbar {
        flex-direction: column;
        gap: 6px;
    }
    .cl-gallery-main {
        max-height: 50vh;
    }
}
@media (max-width: 480px) {
    .categories-column {
        flex: 1 1 100%;
        min-width: 100%;
    }
    .search-bar {
        flex-direction: column;
    }
    .cl-gallery-main {
        max-height: 40vh;
    }
}

/* ===========================
   PRINT STYLES
   =========================== */
@media print {
    /* Hide non-essential elements */
    #site-header,
    #site-footer,
    .cl-breadcrumb,
    .breadcrumb,
    .search-bar,
    .filters-bar,
    .pagination,
    .btn-share,
    .btn-print,
    .cl-action-btn,
    .cl-detail-actions-left,
    .lang-switcher,
    .city-selector {
        display: none !important;
    }

    /* Reset layout for print */
    body {
        background: #fff;
        color: #000;
        font-size: 12pt;
    }
    #app {
        max-width: 100%;
        padding: 0;
        margin: 0;
    }

    /* Listing detail print-friendly */
    .cl-detail-page {
        padding: 0;
    }
    .cl-detail-title {
        font-size: 18pt;
        color: #000;
    }
    .cl-gallery-main {
        max-height: none;
        max-width: 100%;
    }
    .cl-gallery-thumbs {
        display: none;
    }
    .cl-detail-contact {
        border: 1px solid #ccc;
        padding: 10px;
    }

    /* Avoid page breaks inside elements */
    .cl-detail-page,
    .cl-detail-contact,
    .cl-detail-description {
        page-break-inside: avoid;
    }
}
