/* Mobile Responsive Styles */

html {
    -webkit-text-size-adjust: 100%;
}

img,
svg,
canvas,
video,
iframe {
    max-width: 100%;
}

table {
    max-width: 100%;
}

.mobile-scroll-x {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    html {
        font-size: 15px;
    }

    body {
        overflow-x: hidden;
    }

    #main-content {
        overflow-x: hidden;
    }

    /* Smaller padding on mobile */
    .container,
    #main-content > .container {
        width: 100%;
        max-width: 100%;
        padding-left: 1rem;
        padding-right: 1rem;
        padding-top: 1rem;
    }

    /* Stack cards on mobile */
    .stats-grid,
    .kpi-grid,
    .dashboard-grid,
    .analytics-grid,
    .report-grid,
    .summary-grid,
    .card-grid,
    .feature-grid,
    .pricing-grid {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 0.875rem !important;
    }

    .grid[class*="grid-cols-"],
    [class*="grid-cols-"] {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .sm\:grid-cols-2,
    .md\:grid-cols-2,
    .lg\:grid-cols-2,
    .lg\:grid-cols-3,
    .lg\:grid-cols-4,
    .xl\:grid-cols-4 {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .flex:not(.keep-mobile-flex):not(.items-center):not(.justify-between),
    .md\:flex,
    .lg\:flex {
        min-width: 0;
    }

    .card,
    .bg-white,
    .rounded-2xl,
    .rounded-xl {
        max-width: 100%;
    }

    .shadow-2xl,
    .shadow-xl {
        box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
    }

    /* Make tables scrollable horizontally */
    .table-wrapper,
    .table-container,
    .overflow-x-auto,
    .gantt-container,
    .chart-container {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 680px;
    }

    .table-wrapper table,
    .table-container table {
        margin-bottom: 0;
    }

    th,
    td {
        white-space: nowrap;
    }

    /* Forms */
    form {
        max-width: 100%;
    }

    input,
    select,
    textarea,
    .form-control,
    .form-input {
        width: 100%;
        max-width: 100%;
        min-height: 44px;
        font-size: 16px;
    }

    textarea {
        min-height: 112px;
    }

    .form-group,
    .input-group {
        margin-bottom: 1rem;
    }

    /* Larger touch targets */
    .btn,
    button,
    .nav-item,
    .dropdown-menu a,
    .mob-link,
    input[type="checkbox"],
    input[type="radio"] {
        min-height: 44px;
    }

    .btn,
    button[type="submit"],
    a.btn,
    .submit-btn {
        width: 100%;
        justify-content: center;
    }

    .inline-flex.btn,
    .btn.inline-flex {
        display: flex;
    }

    /* Adjust font sizes */
    h1 {
        font-size: clamp(1.65rem, 8vw, 2.25rem);
        line-height: 1.08;
    }

    h2 {
        font-size: clamp(1.35rem, 6vw, 1.75rem);
        line-height: 1.14;
    }

    h3 {
        font-size: 1.15rem;
    }

    p,
    .text-sm,
    .text-gray-500,
    .text-gray-600 {
        overflow-wrap: anywhere;
    }

    .truncate {
        min-width: 0;
    }

    .max-w-7xl,
    .max-w-6xl,
    .max-w-5xl,
    .max-w-4xl,
    .max-w-3xl,
    .max-w-2xl {
        max-width: 100%;
    }

    /* Bottom navigation for mobile */
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
        display: flex;
        justify-content: space-around;
        padding: 0.5rem;
        z-index: 40;
    }

    .dark .mobile-bottom-nav {
        background: #1f2937;
        border-top-color: #374151;
    }

    /* Hide floating elements on mobile */
    .fixed.inset-0.pointer-events-none {
        display: none;
    }

    /* Adjust AI chat button position */
    .global-ai-toggle-btn {
        bottom: 70px;
        right: 16px;
        width: 50px;
        height: 50px;
    }

    .global-ai-chat-panel {
        width: 100vw;
        max-width: 100vw;
    }

    .notification,
    .fixed.top-24.right-4 {
        left: 1rem;
        right: 1rem;
        max-width: calc(100vw - 2rem);
    }

    #mobileMenu {
        width: min(90vw, 24rem);
    }

    .chart-container {
        height: 320px;
        padding: 1rem;
    }

    .modal-content {
        width: calc(100vw - 2rem);
        max-height: calc(100vh - 2rem);
    }
}

@media (max-width: 480px) {
    #main-content > .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .chart-container {
        height: 280px;
    }

    table {
        min-width: 620px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    button, a, [role="button"] {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    button:active, a:active {
        opacity: 0.7;
    }
}
