/* Mobile-specific styles for the dashboard */

/* Desktop styles FIRST - for screens 769px and larger */
@media (min-width: 769px) {
    /* WIDER TABLE LAYOUT FOR DESKTOP - 95% width */
    .container {
        max-width: 95% !important;
        width: 95% !important;
        margin: 0 auto;
    }
    
    /* Ensure reports table uses full width */
    .reports-table {
        width: 100%;
        max-width: none;
    }
    
    .table-wrapper {
        width: 100%;
        overflow-x: auto;
    }
    
    .reports-table table {
        width: 100%;
        min-width: 100%;
    }
    
    /* Dashboard controls full width */
    .dashboard-controls {
        width: 100%;
        max-width: none;
        gap: 2rem;
    }
    
    /* Filters column with reasonable max width */
    .filters-column {
        flex: 1;
        max-width: 400px;
    }
    
    /* Calendar column fixed width */
    .calendar-column {
        flex: 0 0 300px;
    }
    
    /* Today column fixed width */
    .today-column {
        flex: 0 0 250px;
    }
    
    /* Stats grid full width */
    .stats-grid {
        width: 100%;
        max-width: none;
        margin-bottom: 2rem;
    }
    
    /* Ensure all columns are visible on desktop */
    .reports-table thead tr th,
    .reports-table tbody tr td {
        display: table-cell !important;
    }
    
    /* Hide ALL mobile-specific elements on desktop */
    .mobile-menu-btn {
        display: none !important;
    }
    
    .mobile-actions-row {
        display: none !important;
    }
    
    .mobile-thumbnails-row {
        display: none !important;
    }
    
    .mobile-top-row {
        display: none !important;
    }
    
    .mobile-property-info {
        display: none !important;
    }
    
    .mobile-pictures-section {
        display: none !important;
    }
    
    /* Show user info normally on desktop */
    .user-info {
        display: flex !important;
        position: static;
        flex-direction: row;
        gap: 10px;
        background: none;
        box-shadow: none;
        padding: 0;
    }
    
    /* Ensure owner info is visible on desktop */
    .owner-info,
    .editing-indicator {
        display: inline !important;
    }
    
    /* Keep hideformobile items visible on desktop */
    .hideformobile {
        display: block !important;
    }
}

/* MOBILE STYLES - for screens 768px and smaller */
@media (max-width: 768px) {
    /* Hide desktop-only elements */
    .stats-grid {
        display: none !important;
    }
    
    /* Hide elements with hideformobile class on mobile */
    .hideformobile {
        display: none !important;
    }
    
    /* Hide Status and Sort By filters on mobile */
    #statusFilter,
    #sortBy,
    label[for="statusFilter"],
    label[for="sortBy"] {
        display: none !important;
    }
    
    /* Adjust filter layout for mobile */
    .dashboard-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .filters-column {
        width: 100%;
    }
    
    .filter-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .filter-group {
        width: 100%;
    }
    
    /* Hide calendar on mobile */
    .calendar-column {
        display: none !important;
    }
    
    /* Hide today's appointments column on mobile */
    .today-column {
        display: none !important;
    }
    
    /* Table adjustments for mobile */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .reports-table table {
        min-width: auto;
        width: 100%;
    }
    
    /* Adjust columns for mobile */
    .reports-table thead tr th:nth-child(1),
    .reports-table tbody tr td:nth-child(1) {
        width: 100%;
        padding: 8px 5px;
    }
    
    /* Hide owner information on mobile */
    .owner-info {
        display: none !important;
    }
    
    /* Hide editing indicator on mobile */
    .editing-indicator {
        display: none !important;
    }
    
    /* Mobile-optimized property cell */
    .property-address {
        font-size: 14px;
        line-height: 1.2;
        margin: 2px 0;
    }
    
    /* Make property cell more compact */
    .property-cell-wrapper {
        display: flex;
        flex-direction: column;
        gap: 6px;
        width: 100%;
        position: relative;
    }
    
    /* Reduce padding on property cells */
    td[data-label="Property"] {
        padding: 8px 5px !important;
    }
    
    /* Comments textarea more compact */
    .comments-textarea {
        font-size: 12px !important;
        min-height: 40px !important;
        padding: 3px !important;
        line-height: 1.2;
    }
    
    /* More compact table rows */
    .reports-table tbody tr {
        border-bottom: 1px solid #eee;
    }
    
    .reports-table tbody tr td {
        padding: 6px 4px !important;
    }
    
    /* Search input mobile optimization */
    .search-group {
        width: 100%;
    }
    
    /* Make the search container use full width and stack vertically */
    .filter-group.search-group > div {
        flex-direction: column !important;
        gap: 10px !important;
        width: 100%;
    }
    
    #searchInput {
        width: 100% !important;
        font-size: 16px !important;
        padding: 12px !important;
        margin-bottom: 0 !important;
    }
    
    /* Search button takes full width on mobile */
    .search-group .btn-primary {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 16px !important;
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 8px;
    }
    
    /* Header mobile optimizations */
    .header {
        position: relative;
    }
    
    .header-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px;
        position: relative;
    }
    
    .header-content img {
        height: 45px !important;
        max-width: 150px;
        object-fit: contain;
    }
    
    /* Mobile menu button - SHOW on mobile */
    .mobile-menu-btn {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 40px;
        height: 40px;
        padding: 0;
        background: none;
        border: none;
        cursor: pointer;
        position: relative;
        z-index: 101;
    }
    
    .mobile-menu-btn span {
        display: block;
        width: 25px;
        height: 3px;
        background-color: #333;
        margin: 5px auto;
        transition: all 0.3s ease;
        position: relative;
    }
    
    /* Animate hamburger to X when active */
    .mobile-menu-btn.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .mobile-menu-btn.active span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-btn.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
    
    /* Hide desktop user info by default on mobile */
    .user-info {
        display: none !important;
    }
    
    /* Show user info when active on mobile */
    .user-info.active {
        display: flex !important;
        position: absolute;
        top: 100%;
        right: 0;
        background: white;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        border-radius: 4px;
        padding: 15px;
        flex-direction: column;
        gap: 10px;
        min-width: 200px;
        z-index: 1000;
        margin-top: 10px;
    }
    
    /* Style the user email in mobile menu */
    .user-email {
        font-size: 14px;
        color: #666;
        padding-bottom: 10px;
        border-bottom: 1px solid #eee;
        margin-bottom: 5px;
    }
    
    /* Style buttons in mobile menu */
    .user-info .btn {
        width: 100%;
        text-align: center;
        padding: 10px;
    }
    
    /* Empty state mobile optimization */
    .empty-state {
        padding: 40px 20px;
    }
    
    .empty-state p {
        font-size: 16px;
    }
    
    /* Loading state mobile optimization */
    .loading p {
        font-size: 14px;
    }
    
    /* Modal adjustments for mobile */
    .login-modal {
        width: 95%;
        margin: 10px;
        padding: 20px;
    }
}

/* Very small screens adjustments */
@media (max-width: 480px) {
    /* Even more aggressive hiding on very small screens */
    .reports-table {
        font-size: 12px;
    }
    
    .property-address {
        font-size: 13px;
    }
    
    small {
        font-size: 10px !important;
    }
    
    /* Even tighter spacing */
    .property-cell-wrapper {
        gap: 4px;
    }
}

/* Additional mobile-specific utilities */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none !important;
    }
}

/* Improve touch targets for mobile */
@media (max-width: 768px) {
    button, 
    .btn, 
    input[type="button"], 
    input[type="submit"],
    .clickable-edit {
        min-height: 44px;
        min-width: 44px;
    }
    
    input[type="text"],
    input[type="email"],
    input[type="password"],
    select,
    textarea {
        min-height: 44px;
        font-size: 16px !important;
    }
}

/* Landscape mode adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .header {
        position: sticky;
        top: 0;
        z-index: 100;
        background: white;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .reports-table {
        margin-top: 10px;
    }
}

/* Animation for loading spinner */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* New wrapper to hold the two containers side-by-side */
.page-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 1rem;
    width: 100%;
}

/* Container for the content */
.container {
    width: 100%;
    max-width: 45rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 1px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

/* Desktop-specific width adjustments */
@media (min-width: 769px) {
    .page-wrapper {
        gap: 2rem; /* More gap on desktop */
        max-width: 100%;
    }
    
    .page-wrapper .container {
        flex: 1;
        max-width: calc(50% - 1rem); /* Two containers side by side with gap */
    }
    
    /* For single container in page wrapper */
    .page-wrapper:has(.container:only-child) .container {
        max-width: 100%;
    }
    
    /* Better spacing for desktop */
    .address-col {
        padding-left: 1rem;
    }
    
    .car-col {
        padding-right: 1rem;
        gap: 0.75rem;
    }
    
    .full-width-row {
        padding: 0.5rem 1rem;
    }
    
    .comments-textarea {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Maximize main dropzone on desktop */
    .middle-row {
        height: 160px; /* Slightly taller on desktop */
    }
    
    .main-pic-col {
        padding: 0.15rem; /* Minimal padding to maximize dropzone */
    }
    
    .main-pic-col .thumbnail-dropzone {
        width: calc(100% - 2px);
        height: calc(100% - 2px);
        min-height: 150px; /* Larger minimum on desktop */
    }
}

/* Very large screens (1920px and up) */
@media (min-width: 1920px) {
    /* On very large screens, cap the maximum width */
    body > .container,
    .dashboard-content > .container {
        max-width: 1800px !important;
        width: 95% !important;
        margin: 0 auto;
    }
}

/* General styling for all flex rows */
.flex-row {
    display: flex;
    width: 100%;
    border-bottom: 1px solid #e5e7eb;
}
.flex-row:last-child {
    border-bottom: none;
}

/* General styling for columns */
.flex-col {
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* --- Top Row: 50px tall --- */
.top-row {
    height: 50px;
}
.address-col {
    flex-grow: 1;
    background-color: #ffffff;
    justify-content: flex-start;
    cursor: pointer;
}
.address-col:hover {
    background-color: #f9fafb;
}
.car-col {
    width: auto;
    display: flex;
    gap: 0.5rem;
    padding-right: 0.5rem;
}

/* --- Middle Row: 140px tall --- */
.middle-row {
    height: 140px;
}
.main-pic-col {
    width: 65%;
    background-color: #ffffff;
    padding: 0.25rem; /* Reduced padding to maximize dropzone size */
}
.side-pics-container {
    width: 35%;
    display: flex;
    flex-direction: column;
    padding: 0.25rem 0.25rem 0.25rem 0; /* Reduced padding */
}
.pic-dropzone {
    height: 50%;
    width: 100%;
    background-color: #ffffff;
    padding: 0.15rem; /* Reduced padding */
}
.pic-dropzone:first-child {
    margin-bottom: 0.25rem; /* Reduced margin */
}

/* --- Bottom Row: 100px tall --- */
.bottom-row {
    height: 100px;
    background-color: #ffffff;
}
.comments-col {
    width: 100%;
    justify-content: flex-start;
    align-items: flex-start;
}

/* New full-width row */
.full-width-row {
    width: 100%;
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.5rem;
    box-sizing: border-box;
    border-bottom: 1px solid #f3f4f6;
}
.full-width-row:last-child {
    border-bottom: none;
}

/* Half-width columns inside rows */
.half-width-col {
    width: 50%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.25rem;
}

.half-width-col:first-child {
    margin-right: 4px;
}

/* Thumbnail Dropzone Styling - Improved from existing styles */
.thumbnail-dropzone {
    width: 100%;
    height: 100%;
    min-height: 100%; /* Ensure it fills the height */
    border: 2px dashed #e5e7eb;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to bottom, #ffffff, #f9fafb);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Special styling for main dropzone to maximize its size */
.main-pic-col .thumbnail-dropzone {
    width: calc(100% - 4px); /* Account for border */
    height: calc(100% - 4px); /* Account for border */
    min-height: 120px; /* Ensure minimum height */
}

/* Make the main pic col use all available space */
.mobile-main-thumbnail {
    width: 100%;
    height: 100%;
    display: flex;
}

.mobile-main-thumbnail .thumbnail-dropzone {
    width: 100%;
    height: 100%;
}

.thumbnail-dropzone:hover {
    border-color: #4CAF50;
    background: linear-gradient(to bottom, #f0fdf4, #dcfce7);
    transform: scale(1.02);
}

.thumbnail-dropzone.dragover {
    border-color: #4CAF50;
    background: linear-gradient(to bottom, #dcfce7, #bbf7d0);
    transform: scale(1.05);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Icon styling */
.thumbnail-dropzone .dropzone-icon {
    font-size: 32px;
    color: #9ca3af;
    transition: all 0.3s ease;
}

.thumbnail-dropzone:hover .dropzone-icon {
    color: #4CAF50;
    transform: scale(1.1);
}

/* Different sizes for different dropzones */
.main-pic-col .thumbnail-dropzone .dropzone-icon {
    font-size: 40px;
}

.pic-dropzone .thumbnail-dropzone .dropzone-icon {
    font-size: 24px;
}

/* When thumbnail has an image */
.thumbnail-dropzone.has-image {
    border: 2px solid #e5e7eb;
    background: white;
    padding: 0;
}

.thumbnail-dropzone.has-image:hover {
    border-color: #4CAF50;
    transform: scale(1.02);
}

.thumbnail-dropzone img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Loading state */
.thumbnail-dropzone.loading {
    background: linear-gradient(45deg, #f3f4f6 25%, #e5e7eb 25%, #e5e7eb 50%, #f3f4f6 50%, #f3f4f6 75%, #e5e7eb 75%, #e5e7eb);
    background-size: 20px 20px;
    animation: loading-stripes 1s linear infinite;
}

@keyframes loading-stripes {
    0% { background-position: 0 0; }
    100% { background-position: 20px 20px; }
}

.thumbnail-dropzone.loading .dropzone-icon {
    animation: spin 1s linear infinite;
}

/* Error state */
.thumbnail-dropzone.error {
    border-color: #ef4444;
    background: linear-gradient(to bottom, #fef2f2, #fee2e2);
}

.thumbnail-dropzone.error .dropzone-icon {
    color: #ef4444;
}

/* Action buttons styling */
.action-btn {
    padding: 6px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #d1d5db;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.action-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-btn img {
    width: 24px;
    height: 24px;
}

/* Mobile-specific adjustments for the new layout */
@media (max-width: 768px) {
    .page-wrapper {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .container {
        max-width: 100%;
    }
    
    /* Adjust heights for mobile - but keep main dropzone large */
    .middle-row {
        height: 120px;
    }
    
    /* Minimize padding on mobile to maximize dropzone */
    .main-pic-col {
        padding: 0.15rem;
    }
    
    .pic-dropzone {
        padding: 0.1rem;
    }
    
    .bottom-row {
        height: 80px;
    }
    
    .thumbnail-dropzone .dropzone-icon {
        font-size: 24px;
    }
    
    .main-pic-col .thumbnail-dropzone .dropzone-icon {
        font-size: 32px;
    }
    
    .pic-dropzone .thumbnail-dropzone .dropzone-icon {
        font-size: 20px;
    }
}