/* ==========================================================================
   Modern Theme for PGForMe - "MagicBricks" Aesthetic
   ========================================================================== */

:root {
    /* Color Palette */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    
    --secondary: #ec4899;
    --secondary-hover: #db2777;

    --dark: #0f172a;
    --dark-muted: #334155;
    --gray: #64748b;
    --light-gray: #e2e8f0;
    --bg-color: #f8fafc;
    --surface: #ffffff;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* Typography */
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    
    /* Spacing */
    --container-max: 1280px;
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2.5rem;
    --spacing-2xl: 4rem;

    /* Styling */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--dark-muted);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

ul {
    list-style: none;
}

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

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

/* ==========================================================================
   Layout
   ========================================================================== */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.grid {
    display: grid;
    gap: var(--spacing-lg);
}

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (min-width: 768px) {
    .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }
.wrap { flex-wrap: wrap; }

/* ==========================================================================
   Components
   ========================================================================== */

/* Navbar */
.navbar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
    padding: var(--spacing-md) 0;
}

.navbar .brand {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.025em;
}

.navbar .brand span {
    color: var(--dark);
}

.nav-links {
    display: none;
    gap: var(--spacing-lg);
}

@media (min-width: 768px) {
    .nav-links {
        display: flex;
        align-items: center;
    }
}

.nav-link {
    color: var(--dark-muted);
    font-weight: 500;
}

.nav-link:hover {
    color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    border: none;
    gap: var(--spacing-sm);
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

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

/* Hero Section */
.hero {
    position: relative;
    padding: var(--spacing-2xl) 0;
    background: linear-gradient(to right, rgba(15, 23, 42, 0.8), rgba(15, 23, 42, 0.5)), url('https://images.unsplash.com/photo-1555854877-bab0e564b8d5?ixlib=rb-4.0.3&auto=format&fit=crop&w=1920&q=80') center/cover;
    color: white;
    text-align: center;
    min-height: 500px;
    display: flex;
    align-items: center;
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: var(--spacing-md);
    line-height: 1.2;
}

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

.hero p {
    font-size: 1.125rem;
    margin-bottom: var(--spacing-xl);
    opacity: 0.9;
}

/* Search Box */
.search-box {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-xl);
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

@media (min-width: 768px) {
    .search-box {
        flex-direction: row;
        border-radius: var(--radius-full);
        padding: var(--spacing-xs);
    }
}

.search-input-group {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--bg-color);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--light-gray);
}

@media (min-width: 768px) {
    .search-input-group {
        border: none;
        background: transparent;
        border-right: 1px solid var(--light-gray);
        border-radius: 0;
    }
    .search-input-group:last-of-type {
        border-right: none;
    }
}

.search-input-group i {
    color: var(--primary);
    margin-right: var(--spacing-sm);
}

.search-input-group input, 
.search-input-group select {
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
    font-size: 1rem;
    color: var(--dark);
}

.search-btn {
    padding: 1rem 2rem;
    border-radius: var(--radius-md);
}

@media (min-width: 768px) {
    .search-btn {
        border-radius: var(--radius-full);
    }
}


/* PG Cards */
.pg-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    border: 1px solid var(--light-gray);
    position: relative;
    display: flex;
    flex-direction: column;
}

.pg-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.pg-card-img-wrapper {
    position: relative;
    height: 200px;
    overflow: hidden;
}

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

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

.badge {
    position: absolute;
    top: var(--spacing-sm);
    left: var(--spacing-sm);
    background: var(--warning);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    box-shadow: var(--shadow-sm);
}

.pg-card-content {
    padding: var(--spacing-lg);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.pg-card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: var(--spacing-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pg-card-location {
    font-size: 0.875rem;
    color: var(--gray);
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.pg-card-features {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    font-size: 0.875rem;
    flex-wrap: wrap;
}

/* PG Type Badges */
.pg-type-badge {
    background: var(--surface);
    color: var(--dark);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 600;
}
.pg-type-badge.boys {
    color: #3b82f6; /* Blue */
}
.pg-type-badge.girls {
    color: #ec4899; /* Pink */
}
.pg-type-badge.coed {
    color: #8b5cf6; /* Purple */
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--dark-muted);
}

.pg-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--light-gray);
    margin-top: auto;
}

.pg-price {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary);
}

.pg-price span {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--gray);
}

/* Sections */
.section {
    padding: var(--spacing-2xl) 0;
}

.section-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--dark);
    margin-bottom: var(--spacing-sm);
    text-align: center;
}

.section-subtitle {
    text-align: center;
    color: var(--gray);
    margin-bottom: var(--spacing-xl);
}

/* Detail Page */
.detail-header {
    background: var(--surface);
    padding: var(--spacing-lg) 0;
    border-bottom: 1px solid var(--light-gray);
    margin-bottom: var(--spacing-lg);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-sm);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: var(--spacing-lg);
}

.gallery-main {
    grid-column: span 4;
    height: 300px;
}

@media (min-width: 768px) {
    .gallery-main {
        grid-column: span 2;
        grid-row: span 2;
        height: 400px;
    }
}

.gallery-sub {
    height: 196px;
    grid-column: span 2;
}

.gallery-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: var(--transition);
}

.gallery-img:hover {
    opacity: 0.9;
}

/* Map Container */
#map {
    height: 400px;
    width: 100%;
    border-radius: var(--radius-lg);
    z-index: 1; /* Fix for leaflet */
}

/* Utilities */
.text-center { text-align: center; }
.mt-4 { margin-top: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-md); }
.mb-8 { margin-bottom: var(--spacing-2xl); }
.w-full { width: 100%; }
.block { display: block; }
.hidden { display: none; }
.rounded-full { border-radius: 9999px; }
.bg-white { background: #fff; }

/* Mobile Menu Toggle */
.mobile-toggle {
    display: block;
    font-size: 1.5rem;
    color: var(--dark);
    cursor: pointer;
}

@media (min-width: 768px) {
    .mobile-toggle {
        display: none;
    }
}

/* Advanced Search Box */
.search-box-advanced {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 900px;
    margin: 0 auto;
    overflow: hidden;
}

.search-tabs {
    display: flex;
    background: var(--light-gray);
    border-bottom: 1px solid var(--light-gray);
}

.search-tabs li {
    flex: 1;
    text-align: center;
    padding: 1rem;
    font-weight: 600;
    color: var(--dark-muted);
    cursor: pointer;
    transition: var(--transition);
}

.search-tabs li:hover {
    background: rgba(255, 255, 255, 0.5);
}

.search-tabs li.active {
    background: var(--surface);
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

.search-form-advanced {
    padding: var(--spacing-lg);
}

.search-fields-grid {
    display: grid;
    gap: var(--spacing-md);
    align-items: end;
}

@media (min-width: 768px) {
    .search-fields-grid {
        grid-template-columns: 2fr 1.5fr auto;
    }
}

.search-field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.search-field .input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-color);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--light-gray);
    transition: var(--transition);
}

.search-field .input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-field .input-wrapper i {
    color: var(--primary);
    font-size: 1.25rem;
    margin-right: 0.5rem;
}

.search-field .input-wrapper input,
.search-field .input-wrapper select {
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
    font-size: 1rem;
    color: var(--dark);
    font-weight: 500;
}

.search-btn-advanced {
    padding: 0.875rem 2rem;
    font-size: 1.125rem;
    border-radius: var(--radius-md);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Forms & Grid System (Bootstrap Compatibility for Dashboard Forms) */
.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--dark-muted);
}
.form-control, .form-select {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.5;
    color: var(--dark);
    background-color: white;
    background-clip: padding-box;
    border: 1px solid #d1d5db;
    appearance: none;
    border-radius: var(--radius-md);
    transition: var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    outline: none;
}
.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #dc3545;
}
.row {
    display: flex;
    flex-wrap: wrap;
    margin-top: -1rem;
    margin-right: -0.75rem;
    margin-left: -0.75rem;
}
.row > * {
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    padding-right: 0.75rem;
    padding-left: 0.75rem;
    margin-top: 1rem;
}
@media (min-width: 768px) {
    .col-md-6 {
        flex: 0 0 auto;
        width: 50%;
    }
}
.mb-3 { margin-bottom: 1.5rem !important; }
.form-check {
    display: block;
    min-height: 1.5rem;
    padding-left: 1.5em;
    margin-bottom: 0.125rem;
}
.form-check-inline {
    display: inline-block;
    margin-right: 1.5rem;
    margin-top: 0.5rem;
}
.form-check-input {
    float: left;
    margin-left: -1.5em;
    width: 1.25em;
    height: 1.25em;
    margin-top: 0.125em;
    vertical-align: top;
    background-color: white;
    border: 1px solid #9ca3af;
    appearance: none;
    cursor: pointer;
}
.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}
.form-check-input[type="radio"] {
    border-radius: 50%;
}
.form-check-label {
    cursor: pointer;
    color: var(--dark);
    font-weight: 500;
}

/* Extended Grid & Utility Classes for Dashboard Forms */
@media (min-width: 768px) {
    .col-md-12 { flex: 0 0 auto; width: 100%; }
    .col-md-4 { flex: 0 0 auto; width: 33.33333333%; }
    .col-md-3 { flex: 0 0 auto; width: 25%; }
    .col-md-2 { flex: 0 0 auto; width: 16.66666667%; }
    .col-md-1 { flex: 0 0 auto; width: 8.33333333%; }
}

.align-items-center { align-items: center !important; }
.justify-content-center { justify-content: center !important; }
.text-center { text-align: center !important; }

.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }

.d-none { display: none !important; }
.text-danger { color: #dc3545 !important; }

.btn-secondary { 
    background-color: #6c757d; 
    color: white; 
    border: none; 
    padding: 0.75rem 1.5rem; 
    border-radius: var(--radius-md); 
    font-weight: 600; 
    cursor: pointer; 
    transition: all 0.2s ease; 
    display: inline-block;
    text-align: center;
}
.btn-secondary:hover { background-color: #5a6268; color: white; }

/* Table styling for rent details */
.table { 
    width: 100%; 
    margin-bottom: 1rem; 
    color: var(--dark); 
    vertical-align: top; 
    border-collapse: collapse;
}
.table th, .table td { 
    padding: 0.75rem; 
    border-bottom: 1px solid var(--light-gray); 
    text-align: left;
}
.table thead th { 
    vertical-align: bottom; 
    border-bottom: 2px solid var(--gray); 
    font-weight: 600;
    color: var(--dark-muted);
}
.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0,0,0,0.02);
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal {
    display: none; 
    position: fixed;
    z-index: 1050;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: rgba(15, 23, 42, 0.6); /* Backdrop color */
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.modal-dialog {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 1.75rem auto;
    pointer-events: none;
    transform: translateY(-50px);
    transition: transform 0.3s ease-out;
}

.modal.show .modal-dialog {
    transform: translateY(0);
}

.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    background-color: var(--surface);
    background-clip: padding-box;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    outline: 0;
    border: 1px solid var(--light-gray);
}

.modal-header {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid var(--light-gray);
    border-top-left-radius: calc(var(--radius-lg) - 1px);
    border-top-right-radius: calc(var(--radius-lg) - 1px);
}

.modal-title {
    margin-bottom: 0;
    line-height: 1.5;
    font-weight: 700;
    color: var(--dark);
    font-size: 1.25rem;
}

.modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: 1.5rem;
}

.btn-close {
    box-sizing: content-box;
    width: 1em;
    height: 1em;
    padding: 0.25em 0.25em;
    color: var(--dark-muted);
    background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23334155'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg>") center/1em auto no-repeat;
    border: 0;
    border-radius: var(--radius-sm);
    opacity: 0.7;
    cursor: pointer;
}

.btn-close:hover {
    opacity: 1;
}
