:root {
    /* Core Colors from Theme */
    --primary-color-rgb: 106, 116, 211;
    --primary-color: rgb(var(--primary-color-rgb));

    --text-primary: rgba(234, 235, 238, 0.98);
    --text-secondary: rgba(234, 235, 238, 0.8);
    --text-disabled: rgba(234, 235, 238, 0.45);

    --bg-base: rgba(30, 30, 30, 1);
    --card-bg: rgba(30, 30, 30, 0.1);
    /* The theme uses a very transparent card bg because the glass effect does the heavy lifting */

    /* Glass Effect Tokens */
    --glass-tint: rgba(28, 29, 33, 0.18);
    --glass-blur: blur(10px) saturate(1.2);
    --glass-border-color: rgba(234, 235, 238, 0.1);
    --glass-border-width: 0.5px;

    --glass-inset-shadow:
        3px 3px 0.5px -3.5px rgba(255, 255, 255, 0.15) inset,
        -2px -2px 0.5px -2px rgba(255, 255, 255, 0.1) inset,
        0 0 8px 1px rgba(255, 255, 255, 0.06) inset,
        0 0 2px 0 rgba(0, 0, 0, 0.18);

    --card-shadow: 0 12px 20px rgba(0, 0, 0, 0.28);
    --card-radius: 18px;

    /* Status Colors */
    --status-vacant: rgb(78, 183, 128);
    /* label-badge-green */
    --status-occupied: rgb(234, 114, 135);
    /* label-badge-red */

    /* Background Image */
    --bg-image: url('https://cdn.jsdelivr.net/gh/wessamlauf/homeassistant-frosted-glass-themes@refs/heads/main/themes/frosted-glass-dark-background.jpg');
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-image) no-repeat center center fixed;
    background-size: cover;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Base Layout */
.dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    margin-bottom: 3rem;
    padding: 1.5rem;
    border-radius: var(--card-radius);

    /* App Header Style from Theme */
    background-color: rgba(30, 30, 30, 0.01);
    backdrop-filter: blur(8px) saturate(1.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

header h1 {
    font-weight: 500;
    /* ha-font-weight-heading */
    font-size: 2.5rem;
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
    color: var(--text-secondary);
}

/* Controls Bar */
.controls-bar {
    display: flex;
    gap: 1.5rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.search-wrapper {
    position: relative;
    flex-grow: 1;
    max-width: 500px;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

/* Inputs - Matches Theme Input Styles */
input,
select {
    background: rgba(30, 33, 54, 0.7) !important;
    backdrop-filter: blur(6px);
    border-radius: 10px;
    /* token-size-radius-small */
    border: none !important;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.09) !important;
    color: var(--text-primary);
    padding: 1rem 1.5rem 1rem 3rem;
    width: 100%;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: box-shadow 0.2s;
}

#status-filter {
    padding-left: 1.5rem;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23eaeaee' opacity='0.8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

input:focus,
select:focus {
    box-shadow: inset 0 0 0 2px var(--primary-color) !important;
}

/* Grid */
.masonry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 17px;
    /* ha-view-sections-column-gap */
}

/* Card Implementation - The "Frosted Glass" Core */
/* Card Implementation - The "Frosted Glass" Core */
.property-card {
    position: relative;
    background: transparent;
    border-radius: var(--card-radius);
    padding: 1.5rem;
    /* Moved padding here from inner */
    box-shadow: var(--card-shadow);
    transition: transform 0.2s;
    cursor: pointer;
    overflow: hidden;
    border: var(--glass-border-width) solid var(--glass-border-color);

    /* Flex layout for uniform height */
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* The Glass Layer - Exact match to YAML 'card-mod-card' */
.property-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--glass-tint);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    z-index: -1;
    pointer-events: none;
    border-radius: inherit;
    box-shadow: var(--glass-inset-shadow);
}

.property-card:hover {
    transform: translateY(-4px);
}

.card-content-inner {
    display: contents;
}

/* Card Elements */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.property-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.property-title {
    font-size: 20px;
    font-weight: 500;
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);

    /* Line clamp */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.property-city {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Status Badges - Using Label Badge Styles */
.status-badge {
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 0.5rem;

    background-color: rgba(60, 60, 78, 0.28);
    backdrop-filter: blur(10px) saturate(1.1);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.10);
    border: 0.5px solid rgba(234, 235, 238, 0.22);
    color: rgba(234, 235, 238, 0.85);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: currentColor;
    box-shadow: 0 0 6px currentColor;
}

.status-vacant {
    color: var(--status-vacant);
}

.status-occupied {
    color: var(--status-occupied);
}

/* Buttons */
.quick-action-btn {
    margin-top: auto;
    /* Pushes button to bottom */
    width: 100%;
    /* ... rest ... */
    background: rgba(234, 235, 238, 0.18);
    color: var(--text-primary);
    border: none;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.quick-action-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* Modal - Matching Dialog Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;

    /* mdc-dialog-scrim-color */
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    /* ha-dialog-surface-backdrop-filter */

    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
    padding: 2rem;
}

.modal.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    /* ha-dialog-surface-background */
    background: rgba(30, 30, 30, 0.85);
    border: 1px solid var(--glass-border-color);
    color: var(--text-primary);
    width: 100%;
    max-width: 1000px;
    height: 85vh;
    border-radius: var(--card-radius);
    overflow: hidden;
    position: relative;
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.25);
    animation: slideUp 0.4s ease-out;
}

/* Important: Replicating the glass effect on the modal too */
.modal-content::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--glass-tint);
    backdrop-filter: var(--glass-blur);
    z-index: -1;
    pointer-events: none;
    box-shadow: var(--glass-inset-shadow);
}

#modal-body {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

.modal-image-col {
    background-color: rgba(0, 0, 0, 0.3);
    height: 350px;
    width: 100%;
    flex-shrink: 0;
    position: relative;
}

.modal-cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-info-col {
    padding: 2rem 3rem;
    display: flex;
    flex-direction: column;
}

/* Close Button */
.close-button {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 20;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(4px);
}

.close-button:hover {
    background: var(--primary-color);
}

/* Typography in Modal */
.modal-title {
    font-size: 2.25rem;
    font-weight: 500;
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}

.modal-location {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2.5rem;
    padding: 1.5rem;

    /* Inner container styling */
    background: rgba(30, 30, 30, 0.3);
    border-radius: 12px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Amenities Chips */
.amenities-section h4 {
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
}

.amenity-chip {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: inline-block;
    transition: 0.2s;
}

.amenity-chip:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

/* Responsive */
@media (max-width: 900px) {
    .modal-content {
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .modal-image-col {
        height: 250px;
    }

    .modal-info-col {
        padding: 1.5rem;
    }
}

/* Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.6s ease-out forwards;
    opacity: 0;

    /* Info Sections */
    .info-section {
        margin-bottom: 2rem;
        padding-bottom: 2rem;
        border-bottom: 1px solid var(--glass-border-color);
    }

    .info-section h4 {
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.1em;
        margin-bottom: 1rem;
    }

    .summary-text {
        font-size: 1.1rem;
        line-height: 1.6;
        margin-bottom: 1rem;
    }

    .desc-text {
        font-size: 0.95rem;
        color: var(--text-secondary);
        line-height: 1.6;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 4;
        -webkit-box-orient: vertical;
        mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
        transition: max-height 0.3s ease;
    }

    .desc-text.expanded {
        -webkit-line-clamp: unset;
        mask-image: none;
    }

    .show-more-btn {
        color: var(--primary-color);
        font-size: 0.9rem;
        font-weight: 500;
        cursor: pointer;
        display: inline-block;
        margin-top: 0.5rem;
    }

    .show-more-btn:hover {
        text-decoration: underline;
    }

    /* Room & Rules Grids */
    .room-grid,
    .rules-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    .room-item,
    .rule-item {
        background: rgba(255, 255, 255, 0.03);
        padding: 0.75rem;
        border-radius: 8px;
        font-size: 0.9rem;
        display: flex;
        flex-direction: column;
    }

    .room-item strong {
        color: var(--primary-color);
        margin-bottom: 0.25rem;
    }

    /* Gallery Thumbnails */
    .gallery-strip {
        position: absolute;
        bottom: 20px;
        left: 20px;
        right: 20px;
        display: flex;
        gap: 10px;
        background: rgba(0, 0, 0, 0.6);
        padding: 10px;
        border-radius: 12px;
        overflow-x: auto;
        backdrop-filter: blur(5px);
    }

    .gallery-thumb {
        width: 60px;
        height: 40px;
        flex-shrink: 0;
        cursor: pointer;
        border-radius: 6px;
        overflow: hidden;
        border: 2px solid transparent;
        transition: 0.2s;
    }

    .gallery-thumb:hover {
        border-color: var(--primary-color);
    }

    .gallery-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* Gallery Overlay */
    .gallery-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.95);
        z-index: 2000;
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;
        animation: fadeIn 0.3s ease;
    }

    .gallery-overlay img {
        max-width: 90%;
        max-height: 80vh;
        border-radius: 4px;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    }

    .gallery-nav {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        background: transparent;
        border: none;
        color: white;
        font-size: 3rem;
        cursor: pointer;
        padding: 0 2rem;
        opacity: 0.7;
        transition: 0.2s;
    }

    .gallery-nav:hover {
        opacity: 1;
    }

    .gallery-nav.prev {
        left: 0;
    }

    .gallery-nav.next {
        right: 0;
    }

    .gallery-close {
        position: absolute;
        top: 20px;
        right: 30px;
        background: transparent;
        border: none;
        color: white;
        font-size: 3rem;
        cursor: pointer;
    }

    .gallery-counter {
        margin-top: 1rem;
        color: var(--text-secondary);
        font-size: 1rem;
        letter-spacing: 2px;
    }

    /* Calendar Styles */
    .calendar-container {
        padding: 1rem;
        background: rgba(30, 30, 30, 0.2);
        border-radius: 16px;
        border: 1px solid var(--glass-border-color);
    }

    .calendar-grid-header {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        margin-bottom: 0.5rem;
        text-align: center;
    }

    .header-day {
        color: var(--text-secondary);
        font-size: 0.8rem;
        font-weight: 600;
        text-transform: uppercase;
        padding: 0.5rem;
    }

    .calendar-grid {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        gap: 8px;
    }

    .calendar-day {
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.05);
        border-radius: 8px;
        min-height: 80px;
        padding: 0.5rem;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        transition: all 0.2s ease;
        position: relative;
        cursor: default;
    }

    .calendar-day:hover {
        background: rgba(255, 255, 255, 0.08);
    }

    .calendar-day.available {
        border-color: rgba(78, 183, 128, 0.3);
    }

    .calendar-day.available .day-price {
        color: var(--status-vacant);
        font-weight: 700;
    }

    .calendar-day.occupied {
        background: rgba(234, 114, 135, 0.05);
        opacity: 0.7;
    }

    .calendar-day.occupied .day-number {
        color: var(--text-disabled);
        text-decoration: line-through;
    }

    .calendar-day.occupied .day-price {
        display: none;
    }

    .day-number {
        font-size: 0.9rem;
        font-weight: 500;
        color: var(--text-primary);
    }

    .day-price {
        font-size: 0.8rem;
        align-self: flex-end;
    }