/* Mobile-First Responsive Design for Django Business App */

/* Base Mobile Styles */
@media (max-width: 767.98px) {
    /* Container and spacing adjustments */
    .container,
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    /* Card optimizations */
    .card {
        margin-bottom: 1rem;
        border-radius: 0.75rem;
    }

    .card-body {
        padding: 1rem !important;
    }

    .card-header {
        padding: 0.75rem 1rem;
    }

    /* Typography adjustments */
    .h1, h1 {
        font-size: 1.5rem;
    }

    .h2, h2 {
        font-size: 1.35rem;
    }

    .h3, h3 {
        font-size: 1.25rem;
    }

    .h4, h4 {
        font-size: 1.1rem;
    }

    .h5, h5 {
        font-size: 1rem;
    }

    /* Button optimizations */
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    .btn-lg {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }

    .btn-sm {
        padding: 0.375rem 0.75rem;
        font-size: 0.8rem;
    }

    /* Form elements */
    .form-control,
    .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
        border-radius: 0.5rem;
    }

    .form-control-lg {
        font-size: 16px;
        padding: 1rem;
    }

    .input-group-lg .form-control,
    .input-group-lg .form-select {
        font-size: 16px;
        padding: 1rem;
    }

    /* Navigation improvements */
    .navbar-brand span {
        display: none;
    }    .navbar-nav {
        background: rgba(255, 255, 255, 0.95);
        border-radius: 0.75rem;
        padding: 0.75rem;
        margin-top: 0.5rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    [data-bs-theme="dark"] .navbar-nav {
        background: rgba(30, 41, 59, 0.95);
        box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
    }

    .nav-link {
        padding: 0.75rem 1rem;
        margin: 0.125rem 0;
        border-radius: 0.5rem;
        font-size: 0.9rem;
    }

    /* Table improvements */    .table-responsive {
        border-radius: 0.75rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        margin-bottom: 1rem;
    }

    [data-bs-theme="dark"] .table-responsive {
        box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
    }

    .table th,
    .table td {
        padding: 0.5rem 0.375rem;
        font-size: 0.85rem;
        word-break: break-word;
    }

    /* Hide less important columns on mobile */
    .d-mobile-none {
        display: none !important;
    }

    /* Modal improvements */
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-content {
        border-radius: 1rem;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        padding: 1rem;
    }

    /* Alert improvements */
    .alert {
        padding: 0.75rem;
        font-size: 0.9rem;
        border-radius: 0.75rem;
    }

    /* Breadcrumb improvements */
    .breadcrumb {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
        background: transparent;
        margin-bottom: 0.5rem;
    }

    /* Dropdown improvements */    .dropdown-menu {
        border-radius: 0.75rem;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
        border: none;
        margin-top: 0.5rem !important;
    }

    [data-bs-theme="dark"] .dropdown-menu {
        background-color: #374151;
        box-shadow: 0 8px 25px rgba(255, 255, 255, 0.1);
    }

    .dropdown-item {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    /* Pagination improvements */
    .pagination {
        justify-content: center;
        margin-bottom: 0;
    }

    .page-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    /* Badge improvements */
    .badge {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
    }

    /* Icon adjustments */
    .fa-2x {
        font-size: 1.5em !important;
    }

    .icon-square {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1rem;
    }
}

/* Extra small screens (phones) */
@media (max-width: 576px) {
    .container,
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .card-body {
        padding: 0.75rem !important;
    }

    .navbar-brand {
        font-size: 0.9rem;
    }

    /* Typography for extra small screens */
    body {
        font-size: 0.9rem;
    }

    .small {
        font-size: 0.8rem;
    }

    .h1, h1 {
        font-size: 1.35rem;
    }

    .h2, h2 {
        font-size: 1.25rem;
    }

    .h3, h3 {
        font-size: 1.15rem;
    }

    .display-4 {
        font-size: 1.75rem;
    }

    /* Button adjustments */
    .btn {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
    }

    .btn-lg {
        font-size: 0.95rem;
        padding: 0.625rem 0.875rem;
    }

    /* Form adjustments */
    .form-control,
    .form-select {
        padding: 0.625rem;
    }

    /* Stack elements vertically */
    .d-flex.flex-column.flex-sm-row {
        flex-direction: column !important;
    }

    .d-flex.flex-column.flex-sm-row > * {
        margin-bottom: 0.5rem;
        width: 100%;
    }

    .d-flex.flex-column.flex-sm-row > *:last-child {
        margin-bottom: 0;
    }

    /* Pagination simplification */
    .pagination .page-item:not(.active):not(:first-child):not(:last-child):not(:nth-child(2)):not(:nth-last-child(2)) {
        display: none;
    }

    /* Reduce icon sizes */
    .icon-square {
        width: 2rem;
        height: 2rem;
        font-size: 0.9rem;
    }

    .fa-lg {
        font-size: 1.1em !important;
    }

    /* Table adjustments */
    .table {
        font-size: 0.8rem;
    }

    .table th,
    .table td {
        padding: 0.375rem 0.25rem;
    }
}

/* Touch-friendly improvements */
@media (pointer: coarse) {
    .btn,
    .form-control,
    .form-select,
    .nav-link {
        min-height: 44px; /* Apple's recommended touch target size */
    }

    .nav-link {
        display: flex;
        align-items: center;
    }

    .dropdown-item {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Enhanced mobile button sizing for business list action buttons */
    .btn-group-vertical .btn {
        min-height: 44px !important;
        padding: 0.75rem 1rem !important;
        font-size: 0.85rem !important;
        margin-bottom: 0.5rem !important;
    }

    /* Increase clickable area for small buttons (non-action buttons) */
    .btn-sm:not(.btn-group-vertical .btn) {
        min-height: 38px;
        padding: 0.5rem 0.75rem;
    }
}

/* Landscape orientation adjustments */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .navbar {
        padding-top: 0.25rem;
        padding-bottom: 0.25rem;
    }

    .container {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .card-body {
        padding: 0.75rem !important;
    }

    .modal-dialog {
        margin: 0.25rem;
        max-height: calc(100vh - 0.5rem);
    }

    .modal-content {
        max-height: 100%;
        overflow-y: auto;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .icon-square,
    .fas,
    .far,
    .fab {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Utility classes for mobile */
.min-width-0 {
    min-width: 0;
}

.flex-shrink-0 {
    flex-shrink: 0;
}

/* Responsive text utilities */
@media (max-width: 767.98px) {
    .text-responsive {
        font-size: 0.9rem;
    }

    .text-responsive-sm {
        font-size: 0.8rem;
    }
}

/* Enhanced focus states for accessibility */
.form-control:focus,
.form-select:focus,
.btn:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
    border-color: #3b82f6;
    outline: none;
}

/* Loading and interaction states */
.card-hover {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}    .card-hover:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    [data-bs-theme="dark"] .card-hover:hover {
        box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
    }

/* Improved spacing for mobile cards */
@media (max-width: 767.98px) {
    .card + .card {
        margin-top: 1rem;
    }

    .row.g-3 > * {
        padding: 0.75rem;
    }

    .row.g-4 > * {
        padding: 1rem;
    }
}

/* Theme-specific mobile adjustments */
[data-bs-theme="dark"] .navbar-nav {
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
}

[data-bs-theme="light"] .navbar-nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

/* Print styles for mobile */
@media print {
    .navbar,
    .btn,
    .pagination {
        display: none !important;
    }

    .card {
        border: 1px solid #dee2e6 !important;
        box-shadow: none !important;
    }

    .container {
        max-width: none !important;
        padding: 0 !important;
    }
}

/* Mobile-specific button class for touch-friendly sizing */
.mobile-btn-lg {
    min-height: 44px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
}

.mobile-form-control {
    font-size: 16px; /* Prevents iOS zoom */
    min-height: 44px;
}

/* Mobile Cards Section - Show only on mobile devices */
.mobile-cards-section {
    display: none;
}

@media screen and (max-width: 767.98px) {    /* Mobile business card styling */
    .mobile-cards-section .mobile-business-card {
        background: #fff !important;
        border: 1px solid #dee2e6 !important;
        border-radius: 0.75rem !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
        margin-bottom: 1rem !important;
        min-height: 70px !important;
    }
    
    [data-bs-theme="dark"] .mobile-cards-section .mobile-business-card {
        background: #374151 !important;
        border: 1px solid #4b5563 !important;
        box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1) !important;
    }
    
    .mobile-cards-section .mobile-business-card .card-body {
        padding: 0.75rem !important;
    }
    
    /* Contact status badges */
    .mobile-cards-section .mobile-business-card .badge {
        font-size: 0.7rem !important;
        padding: 0.3rem 0.5rem !important;
        border-radius: 0.4rem !important;
        font-weight: 500 !important;
        white-space: nowrap !important;
    }
    
    /* Mobile button specific */
    .mobile-cards-section .mobile-business-card .btn-sm {
        min-height: 36px !important;
        padding: 0.4rem 0.6rem !important;
        font-size: 0.8rem !important;
        border-radius: 0.5rem !important;
    }
    
    /* Grid system fixes */
    .mobile-cards-section .row {
        margin: 0 !important;
    }
    
    .mobile-cards-section .col-5,
    .mobile-cards-section .col-4,
    .mobile-cards-section .col-3 {
        padding: 0.25rem !important;
    }
}

/* Extra small devices - mobile specific */
@media screen and (max-width: 576px) {
    .mobile-cards-section .mobile-business-card .badge {
        font-size: 0.65rem !important;
        padding: 0.2rem 0.4rem !important;
    }

    .mobile-cards-section .mobile-business-card .btn-sm {
        font-size: 0.7rem !important;
        padding: 0.3rem 0.5rem !important;
    }
}

/* Landscape phones */
@media screen and (max-width: 767.98px) and (orientation: landscape) {
    .mobile-cards-section {
        display: block !important;
    }
    
    .mobile-cards-section .mobile-business-card {
        margin-bottom: 0.5rem !important;
        min-height: 60px !important;
    }
}

/* Business List Table Responsive Design with Better Column Structure */
.business-table {
    width: 100% !important;
    table-layout: fixed !important;
    font-size: 0.9rem;
}

[data-bs-theme="dark"] .business-table {
    color: #f9fafb;
}

/* Column-specific header classes for responsive font sizing */
.business-header-wide .header-text {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

[data-bs-theme="dark"] .business-header-wide .header-text {
    color: #f9fafb;
}

.business-header-medium .header-text {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}

[data-bs-theme="dark"] .business-header-medium .header-text {
    color: #f9fafb;
}

.business-header-small .header-text {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}

[data-bs-theme="dark"] .business-header-small .header-text {
    color: #f9fafb;
}

.business-table thead th {
    font-weight: 600;
    text-transform: uppercase;
    background: linear-gradient(135deg, #343a40 0%, #495057 100%) !important;
    border: none !important;
    text-align: center !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle !important;
}

[data-bs-theme="dark"] .business-table thead th {
    background: linear-gradient(135deg, #1f2937 0%, #374151 100%) !important;
    color: #f9fafb !important;
}

.business-table thead th i {
    font-size: 0.8rem;
}

.business-table tbody td {
    text-align: center !important;
    vertical-align: middle !important;
    border-color: rgba(0,0,0,0.05) !important;
    padding: 0.75rem 0.5rem !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Responsive table adjustments */
@media (max-width: 1400px) {
    .business-table {
        font-size: 0.85rem;
    }
    
    .business-header-wide .header-text {
        font-size: 0.8rem;
    }
    
    .business-header-medium .header-text {
        font-size: 0.75rem;
    }
    
    .business-header-small .header-text {
        font-size: 0.7rem;
    }
    
    .business-table thead th {
        padding: 0.5rem 0.25rem;
    }
    
    .business-table tbody td {
        padding: 0.6rem 0.4rem !important;
    }
}

@media (max-width: 1200px) {
    .business-table {
        font-size: 0.8rem;
    }
    
    .business-header-wide .header-text {
        font-size: 0.75rem;
    }
    
    .business-header-medium .header-text {
        font-size: 0.7rem;
    }
    
    .business-header-small .header-text {
        font-size: 0.65rem;
    }
    
    .business-table thead th {
        padding: 0.5rem 0.2rem;
    }
    
    .business-table tbody td {
        padding: 0.5rem 0.3rem !important;
    }
    
    .btn-group-vertical .btn {
        font-size: 0.7rem;
        padding: 0.25rem 0.4rem;
    }
}

@media (max-width: 992px) {
    .business-table {
        font-size: 0.75rem;
    }
    
    .business-header-wide .header-text {
        font-size: 0.7rem;
    }
    
    .business-header-medium .header-text {
        font-size: 0.65rem;
    }
    
    .business-header-small .header-text {
        font-size: 0.6rem;
    }
    
    .business-table thead th {
        padding: 0.4rem 0.15rem;
    }
    
    .business-table tbody td {
        padding: 0.4rem 0.25rem !important;
    }
    
    .btn-group-vertical .btn {
        font-size: 0.65rem;
        padding: 0.2rem 0.3rem;
    }
    
    .avatar-sm {
        width: 32px;
        height: 32px;
        font-size: 0.7rem;
    }
}

@media (max-width: 768px) {
    .business-table {
        font-size: 0.7rem;
    }
    
    .business-header-wide .header-text {
        font-size: 0.65rem;
    }
    
    .business-header-medium .header-text {
        font-size: 0.6rem;
    }
    
    .business-header-small .header-text {
        font-size: 0.55rem;
    }
    
    .business-table thead th {
        padding: 0.3rem 0.1rem;
    }
    
    .business-table tbody td {
        padding: 0.3rem 0.2rem !important;
    }
    
    .btn-group-vertical .btn {
        font-size: 0.6rem;
        padding: 0.15rem 0.25rem;
    }
    
    .avatar-sm {
        width: 28px;
        height: 28px;
        font-size: 0.65rem;
    }
    
    .badge {
        font-size: 0.6rem;
        padding: 0.2rem 0.3rem;
    }
}

/* Business List Table Container Improvements */
@media (max-width: 767.98px) {
    .card.shadow-sm {
        margin: 0.5rem !important;
        border-radius: 0.75rem !important;
    }
    
    [data-bs-theme="dark"] .card.shadow-sm {
        background-color: #374151 !important;
        border: 1px solid #4b5563 !important;
    }
    
    .card-body.p-0 {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    
    .table-responsive {
        margin: 0 !important;
        border-radius: 0.5rem !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08) !important;
    }
    
    [data-bs-theme="dark"] .table-responsive {
        box-shadow: 0 2px 8px rgba(255,255,255,0.08) !important;
    }
}

/* Ultra-wide screen optimizations */
@media (min-width: 1400px) {
    .business-table {
        font-size: 1rem;
    }
    
    .business-table thead th {
        font-size: 0.9rem;
        padding: 0.75rem 0.5rem;
    }
    
    .business-table tbody td {
        padding: 0.875rem 0.6rem !important;
    }
    
    .btn-group-vertical .btn {
        font-size: 0.8rem;
        padding: 0.375rem 0.75rem;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .business-table {
        font-size: 0.6rem;
        min-width: 100%;
    }
    
    .business-header-wide .header-text {
        font-size: 0.55rem;
    }
    
    .business-header-medium .header-text {
        font-size: 0.5rem;
    }
    
    .business-header-small .header-text {
        font-size: 0.45rem;
    }
    
    .business-table thead th {
        padding: 0.2rem 0.05rem;
        line-height: 1.1;
    }
    
    .business-table thead th i {
        font-size: 0.6rem;
    }
    
    .business-table tbody td {
        padding: 0.2rem 0.1rem !important;
        font-size: 0.6rem;
    }
    
    .business-name h6 {
        font-size: 0.7rem !important;
        margin-bottom: 0.1rem !important;
    }
    
    .btn-group-vertical .btn {
        font-size: 0.5rem;
        padding: 0.1rem 0.15rem;
        margin-bottom: 1px;
    }
    
    .badge {
        font-size: 0.5rem;
        padding: 0.15rem 0.25rem;
    }
    
    .avatar-sm {
        width: 24px;
        height: 24px;
        font-size: 0.6rem;
    }
}

/* Landscape mobile optimizations */
@media (max-width: 767.98px) and (orientation: landscape) {
    .business-table {
        font-size: 0.7rem;
    }
    
    .business-header-wide .header-text {
        font-size: 0.65rem;
    }
    
    .business-header-medium .header-text {
        font-size: 0.6rem;
    }
    
    .business-header-small .header-text {
        font-size: 0.55rem;
    }
    
    .business-table thead th {
        padding: 0.25rem 0.15rem;
    }
    
    .business-table tbody td {
        padding: 0.3rem 0.2rem !important;
    }
}

/* Table scroll indicators for mobile */
@media (max-width: 767.98px) {
    .table-responsive::-webkit-scrollbar {
        height: 4px;
    }
    
    .table-responsive::-webkit-scrollbar-track {
        background: rgba(0,0,0,0.1);
        border-radius: 2px;
    }
    
    .table-responsive::-webkit-scrollbar-thumb {
        background: rgba(0,123,255,0.5);
        border-radius: 2px;
    }
    
    .table-responsive::-webkit-scrollbar-thumb:hover {
        background: rgba(0,123,255,0.7);
    }
}

/* Hover effects */
.business-row:hover {
    background-color: rgba(0, 123, 255, 0.05) !important;
    transform: translateY(-1px);
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
}

/* Enhanced mobile table readability */
@media (max-width: 576px) {
    .business-table {
        font-size: 0.65rem;
    }
    
    .business-table thead th {
        font-size: 0.6rem;
        padding: 0.25rem 0.1rem;
    }
    
    .business-table tbody td {
        padding: 0.25rem 0.15rem !important;
    }
    
    .business-name h6 {
        font-size: 0.8rem !important;
        line-height: 1.2;
    }
    
    .btn-group-vertical .btn {
        font-size: 0.55rem;
        padding: 0.1rem 0.2rem;
    }
}
