/* =========================================
   RESPONSIVE MOBILE & TABLET STYLES
   for Harmony Hills Management
   ========================================= */

/* Base responsive improvements */
* {
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
}

/* Responsive GridView / Tables */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 991.98px) {
    /* Stack table on mobile if it has data-mobile-stack attribute */
    table.table-mobile-stack {
        border: 0;
    }
    
    table.table-mobile-stack thead {
        display: none;
    }
    
    table.table-mobile-stack tr {
        display: block;
        margin-bottom: 1.5rem;
        border: 1px solid #dee2e6;
        border-radius: 0.25rem;
        background: white;
    }
    
    table.table-mobile-stack td {
        display: block;
        text-align: right;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid #dee2e6;
    }
    
    table.table-mobile-stack td:last-child {
        border-bottom: 0;
    }
    
    table.table-mobile-stack td::before {
        content: attr(data-label);
        float: left;
        font-weight: bold;
        color: #0b3a66;
    }
    
    /* Hide certain columns on mobile */
    .hide-mobile {
        display: none !important;
    }
    
    /* Adjust button groups for mobile */
    .btn-group {
        display: flex;
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        width: 100%;
        margin-bottom: 0.5rem;
        border-radius: 0.25rem !important;
    }
    
    /* Stack form rows */
    .row.form-row > div {
        margin-bottom: 1rem;
    }
    
    /* Better spacing for cards */
    .card {
        margin-bottom: 1rem;
    }
    
    /* Improve dropdown menus */
    .dropdown-menu {
        width: 100%;
        max-width: none;
    }
    
    /* Better input group spacing */
    .input-group {
        flex-wrap: wrap;
    }
    
    .input-group > * {
        flex: 1 1 auto;
        min-width: 0;
    }
    
    .input-group .btn {
        flex: 0 0 auto;
    }
}

/* Tablet optimizations */
@media (min-width: 768px) and (max-width: 991.98px) {
    .container-fluid {
        padding-left: 2rem;
        padding-right: 2rem;
    }
    
    .table {
        font-size: 0.9rem;
    }
    
    .btn-sm {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }
}

/* Extra small devices (phones) */
@media (max-width: 575.98px) {
    /* Make all buttons full width on mobile */
    .btn:not(.btn-inline) {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Better form control sizing */
    .form-control,
    .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Compact pagination */
    .pagination {
        font-size: 0.875rem;
    }
    
    .pagination .page-link {
        padding: 0.375rem 0.75rem;
    }
    
    /* Stack columns by default */
    .col-xs-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    /* Reduce padding in containers */
    .container,
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Smaller headings */
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.1rem; }
    h5 { font-size: 1rem; }
    
    /* Better alert spacing */
    .alert {
        font-size: 0.9rem;
        padding: 0.75rem;
    }
    
    /* Compact GridView pager */
    .GridPager {
        font-size: 0.85rem;
    }
    
    .GridPager a,
    .GridPager span {
        padding: 0.25rem 0.5rem;
        margin: 0 0.125rem;
    }
}

/* Landscape phone optimizations */
@media (max-width: 767.98px) and (orientation: landscape) {
    .sidebar {
        max-width: 200px;
    }
    
    .navbar-brand {
        font-size: 1rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger tap targets */
    .nav-link,
    .btn,
    .dropdown-item,
    .page-link,
    a {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Better spacing for checkboxes and radios */
    .form-check-input {
        width: 1.5rem;
        height: 1.5rem;
        margin-top: 0.125rem;
    }
    
    .form-check-label {
        padding-left: 0.5rem;
    }
    
    /* Remove hover effects on touch devices */
    .btn:hover,
    .nav-link:hover {
        transform: none;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .navbar,
    .btn,
    .no-print,
    .pagination {
        display: none !important;
    }
    
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
    }
    
    .table {
        page-break-inside: avoid;
    }
    
    thead {
        display: table-header-group;
    }
    
    tr {
        page-break-inside: avoid;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    /* Can be implemented later if needed */
}

/* Horizontal scroll indicator for tables */
.table-responsive::after {
    content: '? Scroll for more ?';
    display: none;
    text-align: center;
    padding: 0.5rem;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    font-size: 0.875rem;
    color: #6c757d;
}

@media (max-width: 991.98px) {
    .table-responsive:not(:empty)::after {
        display: block;
    }
}

/* Better modal sizing on mobile */
@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-content {
        border-radius: 0.5rem;
    }
}

/* Utility classes for responsive visibility */
.visible-xs { display: none !important; }
.visible-sm { display: none !important; }
.visible-md { display: none !important; }
.visible-lg { display: none !important; }

@media (max-width: 575.98px) {
    .visible-xs { display: block !important; }
    .hidden-xs { display: none !important; }
}

@media (min-width: 576px) and (max-width: 767.98px) {
    .visible-sm { display: block !important; }
    .hidden-sm { display: none !important; }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .visible-md { display: block !important; }
    .hidden-md { display: none !important; }
}

@media (min-width: 992px) {
    .visible-lg { display: block !important; }
    .hidden-lg { display: none !important; }
}
