/* style.css - Complete Professional UI */

/* ------------------------- */
/* --- Design System: Root Variables --- */
/* ------------------------- */
:root {
    --primary-color: #007aff;
    --primary-color-light: #e5f2ff;
    --secondary-color: #34c759;
    --background-color: #f2f5f9;
    --card-background-color: #ffffff;
    --text-color-primary: #1c1c1e;
    --text-color-secondary: #636366;
    --border-color: #e5e5ea;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --border-radius: 12px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* ------------------------- */
/* --- Global Styles & Resets --- */
/* ------------------------- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    background-color: var(--background-color);
    font-family: var(--font-family);
    color: var(--text-color-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app-container {
    height: 100%;
    max-width: 500px;
    margin: 0 auto;
    background-color: var(--card-background-color);
    position: relative;
    box-shadow: var(--shadow-md);
    display: flex; /* Helps page fill height */
    flex-direction: column;
}

.page {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background-color: var(--card-background-color);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

#header-title {
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    flex-grow: 1;
}

.header-back-btn {
    position: absolute;
    left: 8px;
    color: var(--primary-color);
    font-size: 1.8rem;
    padding: 8px;
}

.content {
    flex-grow: 1;
    overflow-y: auto;
    background-color: var(--background-color);
    padding: 16px;
    padding-bottom: 80px; /* Space for tab bar */
}

/* ------------------------- */
/* --- Tab Bar --- */
/* ------------------------- */
.tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 500px;
    margin: 0 auto;
    height: 65px;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-color-secondary);
    text-decoration: none;
    font-size: 0.7rem;
    gap: 4px;
    transition: color 0.2s ease;
}

.tab-item ion-icon {
    font-size: 1.5rem;
}

.tab-item.active {
    color: var(--primary-color);
}

/* ------------------------- */
/* --- Generic Components (Buttons, Inputs) --- */
/* ------------------------- */
.btn {
    display: inline-block;
    padding: 12px 20px;
    border-radius: var(--border-radius);
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.2s ease, transform 0.1s ease;
}
.btn:active {
    transform: scale(0.98);
}
.btn-primary {
    background-color: var(--primary-color);
    color: white;
}
.btn-secondary {
    background-color: var(--border-color);
    color: var(--text-color-primary);
}
.btn-whatsapp {
    background-color: var(--secondary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 16px 0 56px 0;
}
.input-field, .select-field {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background-color: #f9f9f9;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input-field:focus, .select-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color-light);
}

/* ------------------------- */
/* --- Login Page --- */
/* ------------------------- */
.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 24px;
}
.login-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 40px;
}
.form-group {
    width: 100%;
    margin-bottom: 20px;
}
#login-button {
    width: 100%;
    margin-top: 10px;
}


/* ------------------------- */
/* --- Property Card --- */
/* ------------------------- */
.property-card {
    background-color: var(--card-background-color);
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    cursor: pointer;
}

.card-gallery-wrapper {
    position: relative;
    cursor: pointer;
}

.card-gallery-scroll {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}
.card-gallery-scroll::-webkit-scrollbar {
    display: none;
}

.gallery-item {
    flex: 0 0 100%;
    width: 100%;
    aspect-ratio: 16 / 10;
    scroll-snap-align: start;
    position: relative;
}

.gallery-item img, .gallery-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-icon {
    position: absolute;
    top: 12px;
    right: 12px;
    background-color: rgba(0,0,0,0.5);
    color: white;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.gallery-dots {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
}

.gallery-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.6);
    transition: background-color 0.2s ease;
}

.gallery-dot.active {
    background-color: white;
}

.card-content {
    padding: 16px;
}
.card-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 4px;
}
.card-subtitle {
    font-size: 0.9rem;
    color: var(--text-color-secondary);
    margin-bottom: 12px;
}
.society-name {
    font-weight: 500;
}
.key-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-color-secondary);
    margin-bottom: 12px;
}
.key-info span {
    background-color: var(--background-color);
    padding: 4px 8px;
    border-radius: 6px;
}
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    margin-top: 12px;
}
.price {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}
.price span {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-color-secondary);
}
.specs {
    display: flex;
    gap: 16px;
    color: var(--text-color-secondary);
}
.specs span {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1rem;
}

/* ------------------------- */
/* --- Filters Page --- */
/* ------------------------- */
.filter-section {
    background: var(--card-background-color);
    padding: 16px;
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.filter-header {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
}
.price-range-inputs, .filter-location-inputs {
    display: flex;
    gap: 12px;
}
.filter-location-inputs {
    flex-direction: column;
}

.segmented-control {
    display: flex;
    width: 100%;
    background-color: var(--background-color);
    border-radius: 8px;
    padding: 4px;
}

.segmented-button {
    flex: 1;
    padding: 8px;
    border: none;
    background-color: transparent;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.segmented-button.active {
    background-color: var(--card-background-color);
    color: var(--primary-color);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.amenities-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.amenity-chip {
    display: block;
    cursor: pointer;
}
.amenity-chip input {
    display: none;
}
.amenity-chip span {
    display: block;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}
.amenity-chip input:checked + span {
    background-color: var(--primary-color-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 500;
}

.filter-actions {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 500px;
    margin: 0 auto;
    background: var(--card-background-color);
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    z-index: 20;
}
.filter-actions .btn {
    flex: 1;
}

/* ------------------------- */
/* --- Property Detail Page --- */
/* ------------------------- */
.content.detail-page {
    padding: 0;
}

.detail-gallery {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}
.detail-gallery::-webkit-scrollbar {
    display: none;
}
.detail-gallery-item {
    flex: 0 0 100%;
    width: 100%;
    aspect-ratio: 16 / 10;
    scroll-snap-align: start;
}
.detail-gallery-item img, .detail-gallery-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.detail-content-wrapper {
    padding: 20px;
    background-color: var(--card-background-color);
}

.detail-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.detail-location {
    font-size: 1rem;
    color: var(--text-color-secondary);
    margin-bottom: 16px;
}

.detail-section {
    background: var(--background-color);
    padding: 16px;
    border-radius: var(--border-radius);
    margin: 16px 0;
}

.detail-section-header {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
}
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
    font-size: 0.95rem;
}
.detail-grid > div {
    line-height: 1.5;
}
.detail-grid > div strong {
    color: var(--text-color-secondary);
    font-weight: 500;
    display: block;
    font-size: 0.85rem;
}
.detail-description {
    line-height: 1.6;
    color: var(--text-color-secondary);
}
.detail-amenities-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.amenity-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}
.amenity-item ion-icon {
    color: var(--primary-color);
    font-size: 1.2rem;
}
.collapsible-trigger {
    width: 100%;
    padding: 12px;
    background-color: transparent;
    border: none;
    color: var(--primary-color);
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s ease;
    font-size: 1rem;
}
.collapsible-trigger ion-icon {
    transition: transform 0.3s ease;
}
.collapsible-trigger.expanded ion-icon {
    transform: rotate(180deg);
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding-top 0.3s ease-out;
}
.collapsible-content.expanded {
    max-height: 500px; /* Adjust as needed */
    padding-top: 12px;
}
.agent-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background-color: var(--card-background-color);
    border-radius: 8px;
}
.agent-photo {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
}
.agent-info {
    flex-grow: 1;
}
.agent-name {
    font-weight: 600;
}
.agent-contact {
    color: var(--text-color-secondary);
    font-size: 0.9rem;
}
.btn-call {
    font-size: 1.5rem;
    color: var(--secondary-color);
    padding: 8px;
}
.loading-text {
    text-align: center;
    padding: 40px;
    color: var(--text-color-secondary);
}

/* ------------------------- */
/* --- Fullscreen Gallery Modal --- */
/* ------------------------- */
.fullscreen-gallery-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.fullscreen-gallery-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.gallery-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    font-size: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1002;
}

.gallery-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.3);
    border: none;
    color: white;
    font-size: 2.5rem;
    width: 50px;
    height: 80px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1002;
    transition: background-color 0.2s;
}
.gallery-nav-btn:hover {
    background: rgba(0, 0, 0, 0.6);
}

.gallery-nav-btn.prev {
    left: 20px;
}

.gallery-nav-btn.next {
    right: 20px;
}

.gallery-content-wrapper {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.gallery-content {
    display: flex;
    height: 100%;
    transition: transform 0.3s ease-in-out;
}

.gallery-slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.gallery-slide img,
.gallery-slide video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.gallery-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 1rem;
    z-index: 1002;
}