/**
 * Mobile Responsive Styles
 * Professional mobile optimization for all devices
 * Breakpoints: 320px (small phones), 480px (phones), 768px (tablets), 1024px (small laptops)
 */

/* ═══════════════════════════════════════════════════════════
   GLOBAL MOBILE FIXES
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    /* Better touch targets */
    button, a, input, select, textarea {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Prevent text size adjustment */
    html {
        -webkit-text-size-adjust: 100%;
        -moz-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
    
    /* Smooth scrolling */
    * {
        -webkit-overflow-scrolling: touch;
    }
}

/* ═══════════════════════════════════════════════════════════
   TABLET STYLES (768px - 1024px)
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .section {
        padding: 60px 24px !important;
    }
    
    .section-title {
        font-size: 32px !important;
    }
    
    .section-subtitle {
        font-size: 16px !important;
    }
    
    /* Stats Grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 24px !important;
    }
    
    /* Features Grid */
    .features-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
    }
    
    /* Form Rows */
    .form-row {
        grid-template-columns: 1fr !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE STYLES (max-width: 768px)
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    /* Container Padding */
    .section {
        padding: 48px 16px !important;
    }
    
    .section-inner {
        padding: 0 !important;
    }
    
    /* Typography */
    .section-title {
        font-size: 28px !important;
        line-height: 1.3 !important;
    }
    
    .section-subtitle {
        font-size: 15px !important;
    }
    
    /* Hero Section */
    .hero {
        min-height: auto !important;
        padding: 100px 16px 60px !important;
    }
    
    .hero h1 {
        font-size: 32px !important;
        line-height: 1.2 !important;
    }
    
    .hero p {
        font-size: 16px !important;
        margin-bottom: 32px !important;
    }
    
    .hero-buttons {
        flex-direction: column !important;
        width: 100%;
    }
    
    .btn-hero {
        width: 100%;
        justify-content: center !important;
        padding: 14px 24px !important;
    }
    
    /* Navigation */
    .navbar-inner {
        padding: 12px 16px !important;
    }
    
    .navbar-brand span {
        font-size: 18px !important;
    }
    
    .navbar-brand img {
        height: 32px !important;
        width: 32px !important;
    }
    
    /* Mobile Menu */
    .navbar-links {
        display: none;
    }
    
    .navbar-links.open {
        display: flex !important;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #fff;
        padding: 16px;
        gap: 8px;
        border-bottom: 1px solid var(--border);
        box-shadow: 0 8px 24px rgba(0,0,0,0.1);
        z-index: 999;
    }
    
    .navbar-links.open a {
        width: 100%;
        text-align: center;
        padding: 12px 16px !important;
    }
    
    .mobile-toggle {
        display: block !important;
    }
    
    /* Stats Bar */
    .stats-bar {
        padding: 32px 16px !important;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 20px !important;
    }
    
    .stat-item .stat-number {
        font-size: 28px !important;
    }
    
    .stat-item .stat-label {
        font-size: 13px !important;
    }
    
    /* Features */
    .features-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    .feature-card {
        padding: 24px 20px !important;
    }
    
    /* Steps/How It Works */
    .steps-grid {
        grid-template-columns: 1fr !important;
        gap: 24px !important;
    }
    
    .steps-grid::before {
        display: none !important;
    }
    
    /* Testimonials */
    .testimonials-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    .testimonial-card {
        padding: 24px 20px !important;
    }
    
    /* CTA Section */
    .cta h2 {
        font-size: 28px !important;
    }
    
    .cta p {
        font-size: 16px !important;
    }
    
    .cta-buttons {
        flex-direction: column !important;
        width: 100%;
    }
    
    .btn-cta {
        width: 100%;
        justify-content: center !important;
    }
    
    /* Footer */
    .footer {
        padding: 48px 16px 24px !important;
    }
    
    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 32px !important;
    }
    
    .footer-bottom {
        flex-direction: column;
        text-align: center;
    }
    
    /* Forms */
    .form-row {
        grid-template-columns: 1fr !important;
    }
    
    .comment-form-section {
        padding: 28px 20px !important;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
}

/* ═══════════════════════════════════════════════════════════
   DASHBOARD MOBILE STYLES
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    /* Sidebar becomes overlay */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    /* Main content full width */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    /* Mobile Header */
    .mobile-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        background: var(--white);
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        z-index: 999;
    }
    
    .menu-toggle {
        display: block !important;
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
        padding: 8px;
    }
    
    /* Dashboard Cards */
    .dashboard-stats {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
    }
    
    .stat-card {
        padding: 16px !important;
    }
    
    .stat-card h3 {
        font-size: 13px !important;
    }
    
    .stat-card .number {
        font-size: 24px !important;
    }
}

@media (max-width: 768px) {
    /* Sidebar Header */
    .sidebar-header {
        padding: 16px !important;
        min-height: auto !important;
    }
    
    .sidebar-header .logo {
        min-height: 60px !important;
    }
    
    .sidebar-header .logo img {
        max-height: 60px !important;
        min-height: 60px !important;
    }
    
    /* Navigation Items */
    .nav-item {
        padding: 14px 16px !important;
        font-size: 14px !important;
    }
    
    .nav-item .icon {
        font-size: 20px !important;
    }
    
    /* Dashboard Stats - Stack on small phones */
    .dashboard-stats {
        grid-template-columns: 1fr !important;
    }
    
    /* Tables */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
    }
    
    /* Property Cards */
    .properties-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    .property-card {
        padding: 16px !important;
    }
    
    .property-card-image {
        height: 200px !important;
    }
    
    /* Buttons */
    .btn-group {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .btn-group button,
    .btn-group a {
        width: 100% !important;
        justify-content: center !important;
    }
    
    /* Modals */
    .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        margin: 20px auto !important;
    }
    
    /* Messages/Chat */
    .messages-container {
        flex-direction: column !important;
    }
    
    .conversations-list {
        width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color);
        max-height: 200px;
        overflow-y: auto;
    }
    
    .chat-area {
        width: 100% !important;
        height: calc(100vh - 300px) !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   PROPERTY DETAILS MOBILE
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .property-details-container {
        padding: 16px !important;
    }
    
    .property-gallery {
        height: 250px !important;
        border-radius: 12px !important;
    }
    
    .property-info-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    .property-sidebar {
        position: static !important;
        width: 100% !important;
    }
    
    .price-card {
        position: sticky !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        border-radius: 16px 16px 0 0 !important;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15) !important;
        z-index: 100;
    }
    
    .amenities-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
    }
    
    .amenity-item {
        font-size: 13px !important;
        padding: 8px 12px !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   FORMS MOBILE OPTIMIZATION
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .form-container {
        padding: 20px 16px !important;
    }
    
    .form-section {
        padding: 20px 16px !important;
        margin-bottom: 16px !important;
    }
    
    .form-section h3 {
        font-size: 18px !important;
    }
    
    /* File Upload */
    .file-upload-area {
        padding: 32px 16px !important;
    }
    
    /* Image Preview Grid */
    .image-preview-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    
    /* Multi-step Forms */
    .form-steps {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    
    .form-step {
        flex: 1 1 calc(50% - 8px) !important;
        font-size: 12px !important;
        padding: 8px !important;
    }
    
    /* Action Buttons */
    .form-actions {
        flex-direction: column-reverse !important;
        gap: 12px !important;
    }
    
    .form-actions button {
        width: 100% !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   APPLICATIONS & NOTIFICATIONS MOBILE
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .applications-grid {
        grid-template-columns: 1fr !important;
    }
    
    .application-card {
        padding: 16px !important;
    }
    
    .application-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }
    
    .notifications-list {
        padding: 0 !important;
    }
    
    .notification-item {
        padding: 16px !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   PROFILE & SETTINGS MOBILE
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .profile-container {
        padding: 16px !important;
    }
    
    .profile-header {
        flex-direction: column !important;
        text-align: center !important;
    }
    
    .profile-avatar {
        width: 100px !important;
        height: 100px !important;
    }
    
    .profile-tabs {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
    }
    
    .profile-tab {
        flex-shrink: 0 !important;
        font-size: 14px !important;
        padding: 10px 16px !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   AI FEATURES MOBILE
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .ai-recommendations-grid {
        grid-template-columns: 1fr !important;
    }
    
    .ai-match-score {
        font-size: 32px !important;
    }
    
    .price-predictor-form {
        padding: 20px 16px !important;
    }
    
    .prediction-result {
        padding: 24px 16px !important;
    }
    
    .prediction-chart {
        height: 200px !important;
    }
    
    /* Chatbot */
    .chatbot-container {
        bottom: 70px !important;
        right: 16px !important;
        left: 16px !important;
        width: auto !important;
        max-height: 500px !important;
    }
    
    .chatbot-toggle {
        bottom: 16px !important;
        right: 16px !important;
        width: 56px !important;
        height: 56px !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   SMALL PHONES (max-width: 480px)
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    .section {
        padding: 40px 12px !important;
    }
    
    .section-title {
        font-size: 24px !important;
    }
    
    .hero h1 {
        font-size: 28px !important;
    }
    
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    .btn-hero,
    .btn-cta {
        padding: 12px 20px !important;
        font-size: 15px !important;
    }
    
    .feature-icon-wrap {
        width: 48px !important;
        height: 48px !important;
        font-size: 22px !important;
    }
    
    .testimonial-card {
        padding: 20px 16px !important;
    }
    
    /* Dashboard */
    .stat-card .number {
        font-size: 20px !important;
    }
    
    .property-card-image {
        height: 180px !important;
    }
    
    /* Forms */
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 10px 14px !important;
    }
    
    .image-preview-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   LANDSCAPE ORIENTATION
   ═══════════════════════════════════════════════════════════ */

@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: auto !important;
        padding: 80px 16px 40px !important;
    }
    
    .sidebar {
        width: 200px !important;
    }
    
    .sidebar-header .logo img {
        max-height: 50px !important;
    }
    
    .nav-item {
        padding: 8px 12px !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   TOUCH IMPROVEMENTS
   ═══════════════════════════════════════════════════════════ */

@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .feature-card:hover,
    .testimonial-card:hover,
    .property-card:hover {
        transform: none !important;
    }
    
    /* Larger tap targets */
    button,
    a,
    input[type="checkbox"],
    input[type="radio"] {
        min-height: 48px;
        min-width: 48px;
    }
    
    /* Better active states for touch */
    button:active,
    a:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

/* ═══════════════════════════════════════════════════════════
   ACCESSIBILITY IMPROVEMENTS
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    /* Focus visible for keyboard navigation */
    *:focus-visible {
        outline: 3px solid var(--primary-color);
        outline-offset: 2px;
    }
    
    /* Skip to content link */
    .skip-to-content {
        position: absolute;
        top: -40px;
        left: 0;
        background: var(--primary-color);
        color: white;
        padding: 8px 16px;
        text-decoration: none;
        z-index: 10000;
    }
    
    .skip-to-content:focus {
        top: 0;
    }
}

/* ═══════════════════════════════════════════════════════════
   PRINT STYLES
   ═══════════════════════════════════════════════════════════ */

@media print {
    .navbar,
    .sidebar,
    .mobile-header,
    .footer,
    .btn,
    button {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    * {
        background: white !important;
        color: black !important;
    }
}
