/* ==========================================================================
   RESPONSIVE STYLES - Mobile First Approach
   ========================================================================== */

/* ==========================================================================
   BASE RESPONSIVE UTILITIES
   ========================================================================== */

* {
    box-sizing: border-box;
}

img, 
video, 
iframe {
    max-width: 100%;
    height: auto;
}

/* Responsive container */
.container-fluid {
    padding-right: 15px;
    padding-left: 15px;
}

/* Touch-friendly spacing */
.mobile-spacing {
    padding: 15px;
}

/* Hide/Show utilities */
.mobile-only {
    display: block !important;
}

.tablet-only,
.desktop-only {
    display: none !important;
}

/* ==========================================================================
   NAVIGATION - MOBILE
   ========================================================================== */

/* Mobile hamburger menu */
.navbar-toggler {
    border: none;
    padding: 10px;
    background: transparent;
    cursor: pointer;
}

.navbar-toggler-icon {
    display: block;
    width: 25px;
    height: 2px;
    background-color: #333;
    position: relative;
    transition: all 0.3s ease;
}

.navbar-toggler-icon::before,
.navbar-toggler-icon::after {
    content: '';
    display: block;
    width: 25px;
    height: 2px;
    background-color: #333;
    position: absolute;
    transition: all 0.3s ease;
}

.navbar-toggler-icon::before {
    top: -8px;
}

.navbar-toggler-icon::after {
    top: 8px;
}

.navbar-toggler.active .navbar-toggler-icon {
    background-color: transparent;
}

.navbar-toggler.active .navbar-toggler-icon::before {
    transform: rotate(45deg);
    top: 0;
}

.navbar-toggler.active .navbar-toggler-icon::after {
    transform: rotate(-45deg);
    top: 0;
}

/* Mobile navigation */
.navbar-collapse {
    background: white;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    z-index: 1000;
}

.navbar-collapse.show {
    max-height: 500px;
}

.navbar-nav {
    flex-direction: column;
    padding: 0;
}

.nav-item {
    border-bottom: 1px solid #f0f0f0;
}

.nav-link {
    padding: 15px 20px !important;
    display: block;
}

/* ==========================================================================
   HERO SECTION - MOBILE
   ========================================================================== */

.hero-section {
    min-height: 400px !important;
    padding: 60px 20px !important;
}

.hero-section h1 {
    font-size: 2rem !important;
    line-height: 1.2;
}

.hero-section p {
    font-size: 1rem !important;
}

.hero-search-form {
    flex-direction: column !important;
}

.hero-search-form input,
.hero-search-form select,
.hero-search-form button {
    width: 100% !important;
    margin: 5px 0 !important;
}

/* ==========================================================================
   CARDS - MOBILE
   ========================================================================== */

.card-grid,
.property-grid {
    grid-template-columns: 1fr !important;
    gap: 15px !important;
}

.card {
    margin-bottom: 20px;
}

.card-img-top {
    height: 200px;
    object-fit: cover;
}

/* Stat cards */
.stat-card {
    margin-bottom: 15px;
}

.stat-card h3 {
    font-size: 1.5rem;
}

/* ==========================================================================
   FORMS - MOBILE
   ========================================================================== */

.form-group {
    margin-bottom: 15px;
}

.form-control {
    font-size: 16px !important; /* Prevents zoom on iOS */
    padding: 12px;
}

.form-row {
    flex-direction: column;
}

.form-row .col,
.form-row [class*="col-"] {
    width: 100% !important;
    margin-bottom: 15px;
}

label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

/* Inline forms stack on mobile */
.form-inline {
    flex-direction: column;
}

.form-inline .form-control,
.form-inline .btn {
    width: 100%;
    margin: 5px 0;
}

/* Filter forms */
.filter-form {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* ==========================================================================
   BUTTONS - MOBILE
   ========================================================================== */

.btn {
    padding: 12px 20px;
    font-size: 14px;
    width: 100%;
    margin-bottom: 10px;
}

.btn-group {
    flex-direction: column;
}

.btn-group .btn {
    border-radius: 5px !important;
    margin: 5px 0;
}

/* Touch-friendly button spacing */
.btn + .btn {
    margin-left: 0 !important;
    margin-top: 10px;
}

/* ==========================================================================
   TABLES - MOBILE
   ========================================================================== */

.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    font-size: 14px;
}

/* Card-style tables for mobile */
.mobile-table-card {
    display: block;
}

.mobile-table-card thead {
    display: none;
}

.mobile-table-card tbody {
    display: block;
}

.mobile-table-card tr {
    display: block;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    background: white;
}

.mobile-table-card td {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border: none;
    border-bottom: 1px solid #f0f0f0;
}

.mobile-table-card td:last-child {
    border-bottom: none;
}

.mobile-table-card td::before {
    content: attr(data-label);
    font-weight: bold;
    margin-right: 10px;
}

/* ==========================================================================
   PROPERTY DETAILS - MOBILE
   ========================================================================== */

.property-header {
    flex-direction: column;
}

.property-title h1 {
    font-size: 1.75rem !important;
}

.property-price {
    font-size: 1.5rem !important;
    margin: 10px 0;
}

.property-gallery {
    margin-bottom: 20px;
}

.property-gallery img {
    width: 100%;
    height: auto;
}

.property-features {
    flex-direction: column;
}

.feature-item {
    width: 100%;
    margin-bottom: 10px;
    padding: 10px;
}

.property-sidebar {
    margin-top: 30px;
}

/* ==========================================================================
   DASHBOARD - MOBILE
   ========================================================================== */

.dashboard-header {
    flex-direction: column;
    text-align: center;
}

.dashboard-stats {
    grid-template-columns: 1fr !important;
}

.quick-actions {
    flex-direction: column;
}

.quick-actions .btn {
    width: 100%;
    margin: 5px 0;
}

/* ==========================================================================
   FOOTER - MOBILE
   ========================================================================== */

.footer-content {
    flex-direction: column;
    text-align: center;
}

.footer-column {
    width: 100%;
    margin-bottom: 30px;
}

.footer-social {
    justify-content: center;
}

/* ==========================================================================
   MODALS - MOBILE
   ========================================================================== */

.modal-dialog {
    margin: 10px;
    max-width: calc(100% - 20px);
}

.modal-content {
    border-radius: 8px;
}

/* ==========================================================================
   MAPS - MOBILE
   ========================================================================== */

#map,
#propertyMap,
.map-container {
    height: 300px !important;
    margin: 20px 0;
}

.leaflet-popup-content {
    width: 200px !important;
}

/* ==========================================================================
   TYPOGRAPHY - MOBILE
   ========================================================================== */

h1 {
    font-size: 1.75rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

h4 {
    font-size: 1.1rem;
}

p {
    font-size: 14px;
    line-height: 1.6;
}

/* ==========================================================================
   SPACING - MOBILE
   ========================================================================== */

.section {
    padding: 40px 15px;
}

.container {
    padding-right: 15px;
    padding-left: 15px;
}

/* ==========================================================================
   TABLET DEVICES (768px - 1023px)
   ========================================================================== */

@media (min-width: 768px) {
    
    /* Show tablet elements */
    .mobile-only {
        display: none !important;
    }
    
    .tablet-only {
        display: block !important;
    }
    
    /* Navigation */
    .navbar-collapse {
        position: static;
        box-shadow: none;
        max-height: none;
        overflow: visible;
    }
    
    .navbar-nav {
        flex-direction: row;
    }
    
    .nav-item {
        border-bottom: none;
    }
    
    .nav-link {
        padding: 10px 15px !important;
    }
    
    /* Hero section */
    .hero-section {
        min-height: 500px !important;
        padding: 80px 40px !important;
    }
    
    .hero-section h1 {
        font-size: 3rem !important;
    }
    
    .hero-section p {
        font-size: 1.25rem !important;
    }
    
    .hero-search-form {
        flex-direction: row !important;
    }
    
    .hero-search-form input,
    .hero-search-form select {
        width: auto !important;
        flex: 1;
        margin: 0 5px !important;
    }
    
    .hero-search-form button {
        width: auto !important;
        margin: 0 !important;
    }
    
    /* Cards */
    .card-grid,
    .property-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
    }
    
    .card-img-top {
        height: 250px;
    }
    
    /* Forms */
    .form-row {
        flex-direction: row;
    }
    
    .form-row .col-md-6 {
        width: 50% !important;
        padding-right: 10px;
    }
    
    .form-row .col-md-4 {
        width: 33.333% !important;
        padding-right: 10px;
    }
    
    /* Buttons */
    .btn {
        width: auto;
        display: inline-block;
    }
    
    .btn-group {
        flex-direction: row;
    }
    
    .btn-group .btn {
        margin: 0 5px;
    }
    
    /* Tables */
    .mobile-table-card thead {
        display: table-header-group;
    }
    
    .mobile-table-card tbody {
        display: table-row-group;
    }
    
    .mobile-table-card tr {
        display: table-row;
        border: none;
        padding: 0;
        margin: 0;
    }
    
    .mobile-table-card td {
        display: table-cell;
        padding: 12px;
        border-bottom: 1px solid #ddd;
    }
    
    .mobile-table-card td::before {
        content: none;
    }
    
    /* Dashboard */
    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .dashboard-header {
        flex-direction: row;
        text-align: left;
    }
    
    /* Property details */
    .property-features {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .feature-item {
        width: 50%;
    }
    
    /* Maps */
    #map,
    #propertyMap,
    .map-container {
        height: 400px !important;
    }
    
    /* Typography */
    h1 {
        font-size: 2.5rem;
    }
    
    h2 {
        font-size: 2rem;
    }
    
    h3 {
        font-size: 1.75rem;
    }
    
    /* Spacing */
    .section {
        padding: 60px 30px;
    }
    
    .container {
        max-width: 720px;
        margin: 0 auto;
    }
}

/* ==========================================================================
   DESKTOP DEVICES (1024px and above)
   ========================================================================== */

@media (min-width: 1024px) {
    
    /* Show desktop elements */
    .tablet-only {
        display: none !important;
    }
    
    .desktop-only {
        display: block !important;
    }
    
    /* Hero section */
    .hero-section {
        min-height: 600px !important;
        padding: 100px 40px !important;
    }
    
    .hero-section h1 {
        font-size: 3.5rem !important;
    }
    
    /* Cards */
    .card-grid,
    .property-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 30px !important;
    }
    
    .card-img-top {
        height: 280px;
    }
    
    /* Dashboard */
    .dashboard-stats {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 25px;
    }
    
    /* Property details */
    .property-sidebar {
        position: sticky;
        top: 20px;
        margin-top: 0;
    }
    
    .feature-item {
        width: 33.333%;
    }
    
    /* Maps */
    #map,
    #propertyMap,
    .map-container {
        height: 450px !important;
    }
    
    /* Container */
    .container {
        max-width: 1140px;
    }
    
    /* Forms */
    .form-inline {
        flex-direction: row;
    }
    
    .form-inline .form-control,
    .form-inline .btn {
        width: auto;
        margin: 0 5px;
    }
}

/* ==========================================================================
   LARGE DESKTOP (1440px and above)
   ========================================================================== */

@media (min-width: 1440px) {
    .container {
        max-width: 1320px;
    }
    
    .card-grid,
    .property-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .navbar,
    .footer,
    .btn,
    .filter-form {
        display: none !important;
    }
    
    .container {
        max-width: 100%;
    }
    
    * {
        color: #000 !important;
        background: #fff !important;
    }
}

/* ==========================================================================
   IMAGE OPTIMIZATION
   ========================================================================== */

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Responsive images */
.img-fluid {
    max-width: 100%;
    height: auto;
}

/* Property card images - consistent aspect ratio */
.property-card img,
.card-img-top {
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

/* ==========================================================================
   ACCESSIBILITY IMPROVEMENTS
   ========================================================================== */

/* Focus styles for keyboard navigation */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Focus visible for better accessibility */
*:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* Skip to content link */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #667eea;
    color: white;
    padding: 8px 15px;
    text-decoration: none;
    z-index: 100;
}

.skip-to-content:focus {
    top: 0;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   TOUCH IMPROVEMENTS
   ========================================================================== */

/* Larger touch targets (minimum 44x44 pixels for WCAG AA) */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .nav-link,
    a {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Increase form control touch targets */
    input[type="checkbox"],
    input[type="radio"] {
        min-width: 24px;
        min-height: 24px;
    }
    
    /* Better spacing for touch */
    .btn + .btn {
        margin-top: 10px !important;
    }
    
    /* Remove hover effects on touch devices */
    *:hover {
        background-color: inherit;
    }
}

/* ==========================================================================
   ORIENTATION SPECIFIC
   ========================================================================== */

@media (orientation: landscape) and (max-height: 500px) {
    .hero-section {
        min-height: 300px !important;
        padding: 40px 20px !important;
    }
    
    .modal-dialog {
        margin: 5px;
    }
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

/* Text utilities */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Scrollable containers */
.scrollable-x {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.scrollable-y {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Loading states */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Error states */
.is-invalid {
    border-color: #dc3545 !important;
}

.invalid-feedback {
    display: block;
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.is-valid {
    border-color: #28a745 !important;
}

.valid-feedback {
    display: block;
    color: #28a745;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* ==========================================================================
   PERFORMANCE OPTIMIZATIONS
   ========================================================================== */

/* Lazy loading placeholder */
.lazy-loading {
    background: #f0f0f0;
    min-height: 200px;
}

/* Optimize animations */
@media (prefers-reduced-motion: no-preference) {
    .smooth-scroll {
        scroll-behavior: smooth;
    }
}

/* GPU acceleration for transforms */
.card:hover,
.property-card:hover,
.btn:hover {
    will-change: transform;
    transform: translateZ(0);
}
