:root {
    --bg: #f4e8c8;
    --surface: #f8efda;
    --surface-strong: #e7d9b2;
    --text: #263022;
    --muted: #646f53;
    --primary: #4b6f37;
    --primary-dark: #364e29;
    --accent: #8c9f67;
    --danger: #a03a2b;
    --border: #d9c8a5;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
}
header {
    background: var(--primary);
    color: #fff;
    padding: 24px 20px 14px;
    text-align: center;
}
.top-menu {
    max-width: 1100px;
    margin: 0 auto 12px;
    padding: 0 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}
.menu-item {
    color: #fff;
    text-decoration: none;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
    transition: background 0.2s ease, color 0.2s ease;
}
.menu-item:hover,
.menu-item.active {
    background: rgba(255,255,255,0.2);
}
header a {
    color: #f4f0e7;
    text-decoration: none;
}
.filter-panel,
.admin-form,
#results,
.detail-page,
.contact-page {
    max-width: 1100px;
    margin: 20px auto;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(83, 88, 76, 0.08);
}

.admin-editor-tile {
    max-width: 1100px;
    margin: 20px auto;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 10px 30px rgba(83, 88, 76, 0.08);
    overflow: hidden;
}

.admin-toggle-button {
    width: 100%;
    text-align: left;
    border-radius: 0;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.admin-toggle-label {
    flex: 1;
}

.admin-toggle-icon {
    display: inline-block;
    transition: transform 0.2s ease;
    font-size: 1.2rem;
    line-height: 1;
}

.admin-editor-tile.is-open .admin-toggle-icon {
    transform: rotate(180deg);
}

.admin-editor-content {
    padding: 20px 24px 24px;
}

.admin-editor-tile.is-collapsed .admin-editor-content {
    display: none;
}
.filter-panel label,
.admin-form label {
    display: block;
    margin-bottom: 14px;
}
.filter-panel input,
.admin-form input,
.admin-form textarea,
.filter-panel textarea {
    width: 100%;
    padding: 12px;
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
}
button {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 14px 22px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}
button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}
.carousel {
    position: relative;
    overflow: hidden;
    border-radius: 18px;
    margin-bottom: 22px;
    background: #fff;
    border: 1px solid var(--border);
}
.carousel-track {
    display: flex;
    transition: transform 0.5s ease;
}
.carousel-slide {
    min-width: 100%;
    opacity: 0;
    transition: opacity 0.6s ease;
    position: absolute;
    inset: 0;
}
.carousel-slide.active {
    opacity: 1;
    position: relative;
}
.carousel-slide img {
    width: 100%;
    height: 320px;
    object-fit: cover;
    display: block;
}
.carousel-caption {
    position: absolute;
    left: 50%;
    bottom: 54px;
    transform: translateX(-50%);
    width: calc(100% - 48px);
    background: rgba(255, 255, 255, 0.85);
    color: var(--text);
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    text-align: center;
    box-sizing: border-box;
}
.carousel-dots {
    position: absolute;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
}
.carousel-dot {
    width: 4px !important;
    height: 4px !important;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.7);
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}
.carousel-dot.active,
.carousel-dot:hover {
    background: var(--primary);
    transform: scale(1.1);
}
.button-link {
    display: inline-block;
    margin-left: 12px;
    padding: 12px 20px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    transition: background 0.2s ease;
}
.button-link:hover {
    background: #6d8751;
}
.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    align-items: end;
}
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}
.card {
    display: block;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
    background: #fff;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 30px rgba(71, 83, 61, 0.14);
}
.house-card-bouncy {
    cursor: pointer;
    user-select: none;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}
.card-content {
    padding: 22px;
}
.card-content h3 {
    margin: 0 0 10px;
}
.card-content p {
    margin: 8px 0;
}
.card-content .price {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
}
.card-content .location {
    color: var(--muted);
}
.detail-card,
.admin-card,
.contact-card {
    display: grid;
    gap: 24px;
}
.detail-card img,
.admin-card img {
    width: 100%;
    border-radius: 16px;
    object-fit: cover;
}
.detail-gallery {
    position: relative;
    display: grid;
    grid-template-columns: 48px 1fr 48px;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}
.gallery-stage {
    position: relative;
    width: 100%;
    min-height: 260px;
    border-radius: 16px;
    overflow: hidden;
    background: #f3f1ed;
}
.gallery-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    display: none;
    transition: opacity 0.2s ease;
    border-radius: 16px;
}
.gallery-image.active {
    opacity: 1;
    position: relative;
    display: block;
    z-index: 1;
}
.gallery-arrow {
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    cursor: pointer;
    font-size: 1.2rem;
    transform: translateY(-10px);
}
.gallery-counter {
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 8px;
}
.detail-content,
.admin-card-body {
    line-height: 1.7;
}
.detail-price,
.admin-card-body .price {
    font-weight: 700;
    color: var(--primary);
    margin: 14px 0;
}
.detail-location {
    font-size: 1rem;
    color: var(--muted);
    margin-bottom: 10px;
}
.back-link,
.admin-action-link,
.contact-card a {
    display: inline-block;
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}
.back-link:hover,
.admin-action-link:hover,
.contact-card a:hover {
    text-decoration: underline;
    color: var(--primary-dark);
}
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
}
.admin-card {
    border: 1px solid var(--border);
    background: var(--surface-strong);
}
.admin-card-body {
    padding: 18px;
}
.admin-card-body h3 {
    margin: 0 0 10px;
}
.admin-card-body p {
    margin: 8px 0;
    color: var(--muted);
}
.admin-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 14px;
}
.admin-delete-form {
    display: grid;
    gap: 10px;
}
.admin-delete-form input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
}
.admin-action-button {
    background: var(--danger);
    padding: 12px;
    border: none;
    border-radius: 10px;
    color: white;
    cursor: pointer;
}
.admin-action-button:hover {
    background: #7c2e24;
}
/* card-item wraps the clickable card and optional admin actions */
.card-item {
    position: relative;
}
.card-admin-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    align-items: center;
}
.card-admin-actions .admin-action-link {
    background: rgba(255,255,255,0.9);
    padding: 8px 10px;
    border-radius: 8px;
}
.card-admin-actions .admin-delete-form button.admin-action-button {
    padding: 8px 10px;
    border-radius: 8px;
}

/* wider layout on very large monitors */
@media (min-width: 1400px) {
    .filter-panel,
    .admin-form,
    #results,
    .detail-page,
    .contact-page {
        max-width: 2000px;
    }
}

/* increase card image height on large screens */
@media (min-width: 1600px) {
    .card img {
        height: 320px;
    }
}

/* On very large monitors expand the main containers to use more viewport space
   so tiles become wider (approx 70% of viewport). */
@media (min-width: 1600px) {
    .filter-panel,
    .admin-form,
    #results,
    .detail-page,
    .contact-page {
        max-width: 70vw;
    }
}

/* Slightly increase tile image height on ultra-wide screens */
@media (min-width: 2200px) {
    .card img {
        height: 380px;
    }
}

/* ensure Bootstrap overrides play nicely */
.form-control {
    border-radius: 10px;
}
.contact-card h2 {
    margin-top: 0;
}
.contact-card p {
    margin: 14px 0;
}
.map-frame iframe {
    border-radius: 16px;
    width: 100%;
    min-height: 450px;
}
.message {
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 20px;
}
.message.success {
    background: #eaf5de;
    border: 1px solid #c8dcb0;
    color: #2f4f1b;
}
.message.error {
    background: #f6e2d9;
    border: 1px solid #d7b2a3;
    color: #7c2e24;
}
.contact-card h2 {
    margin-top: 0;
}
.contact-card p {
    margin: 12px 0;
    line-height: 1.6;
}
.contact-card a {
    color: #004080;
    text-decoration: none;
}
.contact-card a:hover {
    text-decoration: underline;
}
.map-frame iframe {
    border-radius: 8px;
    width: 100%;
    min-height: 450px;
}
.map-editor {
    margin: 18px 0 24px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255,255,255,0.5);
}
.map-editor-header {
    margin-bottom: 12px;
    color: var(--primary-dark);
}
.map-editor-map {
    width: 100%;
    height: 320px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #eae5d6;
}
.map-editor-note {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}
.map-editor-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 24px;
    text-align: center;
    color: var(--danger);
    font-weight: 600;
}
.pagination-wrapper {
    max-width: 1100px;
    margin: 20px auto 0;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(83, 88, 76, 0.08);
}

.pagination-wrapper-top {
    margin-bottom: 20px;
}

.pagination {
    margin-top: 0;
    text-align: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.pagination .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    text-decoration: none;
}

.pagination .page-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.pagination button {
    margin: 0 6px;
}
.message {
    background: #e6ffe6;
    border: 1px solid #88cc88;
    padding: 12px;
    margin-bottom: 20px;
}

/* status badges */
.status-badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.85rem;
    margin-top: 8px;
}
.status-sprzedane { background: #f8d7da; color: #a03a2b; }
.status-rezerwacja { background: #fff3cd; color: #856404; }
.status-dostepne { background: #e6f4ea; color: #225522; }
.status-nieaktywne { background: #e9ecef; color: #000000; }
.status-default { background: #f0f0f0; color: #333; }

/* admin action variants inside tiles */
.card-admin-actions .admin-action-button {
    border: none;
    color: #fff;
    padding: 6px 8px;
}
.card-admin-actions .admin-edit {
    background: #f0ad4e; /* yellow */
}
.card-admin-actions .admin-delete {
    background: var(--danger);
}
.card-admin-actions .admin-action-button:hover {
    opacity: 0.9;
}

/* ensure admin page containers are widened like index */
@media (min-width: 1600px) {
    .admin-form, .admin-list {
        max-width: 70vw;
        margin-left: auto;
        margin-right: auto;
    }
}
