/* ====================================
   Mobile Responsive Styles for AppflowZ
   ==================================== */

/* Base Mobile Styles */
@media (max-width: 991px) {
    /* Hide the sidebar column wrapper on mobile */
    .col-md-3.col-lg-2 {
        position: fixed !important;
        top: 0;
        left: -100%;
        width: 280px !important;
        height: 100vh;
        z-index: 1050;
        transition: left 0.3s ease;
        max-width: 280px !important;
        flex: none !important;
    }
    
    .col-md-3.col-lg-2.show {
        left: 0 !important;
    }
    
    /* Sidebar Mobile Menu */
    .sidebar {
        position: relative !important;
        width: 100% !important;
        height: 100vh;
        overflow-y: auto;
        left: 0 !important;
    }
    
    .sidebar.show {
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }
    
    /* Fix nav alignment on mobile */
    .sidebar .nav {
        align-items: flex-start !important;
    }
    
    .sidebar .nav-link {
        text-align: left !important;
        justify-content: flex-start !important;
    }
    
    /* Mobile Overlay */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1040;
    }
    
    .mobile-overlay.show {
        display: block;
    }
    
    /* Mobile Menu Toggle */
    .mobile-menu-toggle {
        display: block;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 1060;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border: none;
        color: white;
        padding: 10px 15px;
        border-radius: 8px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
        cursor: pointer;
        transition: all 0.3s ease;
    }
    
    .mobile-menu-toggle:hover {
        transform: scale(1.05);
        box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    }
    
    .mobile-menu-toggle i {
        font-size: 1.5rem;
    }
    
    /* Main Content Adjustment */
    .content {
        margin-left: 0 !important;
        padding: 70px 15px 20px 15px !important;
        width: 100% !important;
    }
    
    /* Main content takes full width */
    .col-md-9.col-lg-10 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Desktop - Hide mobile elements and ensure proper layout */
@media (min-width: 992px) {
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .mobile-overlay {
        display: none !important;
    }
    
    /* Ensure sidebar column is visible on desktop */
    .col-md-3.col-lg-2 {
        position: relative !important;
        left: 0 !important;
    }
}

/* Tablet Adjustments */
@media (max-width: 768px) {
    /* Typography */
    h1 {
        font-size: 1.75rem !important;
    }
    
    h2 {
        font-size: 1.5rem !important;
    }
    
    h3 {
        font-size: 1.25rem !important;
    }
    
    h4 {
        font-size: 1.1rem !important;
    }
    
    /* Buttons */
    .btn {
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
    }
    
    .btn-lg {
        font-size: 1rem;
        padding: 0.75rem 1.5rem;
    }
    
    /* Cards */
    .card {
        margin-bottom: 1rem;
    }
    
    .stat-card {
        margin-bottom: 1rem;
    }
    
    /* Tables */
    .table-responsive {
        border: 0;
    }
    
    .table {
        font-size: 0.9rem;
    }
    
    .table thead {
        display: none;
    }
    
    .table tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        padding: 0.5rem;
        background: white;
    }
    
    .table td {
        display: block;
        text-align: right;
        padding: 0.5rem;
        border: none;
        position: relative;
        padding-left: 50%;
    }
    
    .table td:before {
        content: attr(data-label);
        position: absolute;
        left: 0.5rem;
        font-weight: bold;
        text-align: left;
    }
    
    /* Forms */
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-label {
        font-size: 0.95rem;
        font-weight: 600;
    }
    
    .form-control,
    .form-select {
        font-size: 1rem;
        padding: 0.75rem;
    }
    
    /* Modals */
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-content {
        border-radius: 15px;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
    
    /* Dropdowns */
    .dropdown-menu {
        width: 100%;
        max-width: 300px;
    }
    
    /* Navigation */
    .navbar {
        padding: 0.5rem 1rem;
    }
    
    .navbar-brand {
        font-size: 1.25rem;
    }
    
    /* Hero Section */
    .hero {
        padding: 3rem 0 !important;
    }
    
    .hero h1 {
        font-size: 2rem !important;
        line-height: 1.2;
    }
    
    .hero .lead {
        font-size: 1rem !important;
    }
    
    .btn-hero {
        padding: 0.75rem 1.5rem !important;
        font-size: 1rem !important;
        margin-bottom: 0.5rem;
    }
    
    /* Feature Cards */
    .feature-card {
        margin-bottom: 1.5rem;
    }
    
    .feature-icon {
        width: 60px !important;
        height: 60px !important;
    }
    
    .feature-icon i {
        font-size: 2rem !important;
    }
    
    /* Stats Section */
    .stat-card {
        padding: 1.5rem !important;
    }
    
    .stat-number {
        font-size: 2rem !important;
    }
    
    /* Pricing Cards */
    .pricing-card {
        margin-bottom: 1.5rem;
    }
    
    .pricing-card.featured {
        transform: none !important;
    }
    
    /* Workflow Builder */
    .workflow-canvas {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .workflow-step {
        min-width: 200px;
    }
    
    /* Form Builder */
    .form-builder-canvas {
        padding: 1rem;
    }
    
    .field-item {
        margin-bottom: 1rem;
    }
    
    /* Analytics Charts */
    .chart-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Action Buttons */
    .action-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .action-buttons .btn {
        flex: 1 1 auto;
        min-width: 120px;
    }
    
    /* Flex Utilities */
    .d-flex.justify-content-between {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .d-flex.justify-content-between > * {
        flex: 1 1 100%;
    }
}

/* Mobile Portrait */
@media (max-width: 576px) {
    /* Extra small adjustments */
    body {
        font-size: 14px;
    }
    
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* Typography */
    h1 {
        font-size: 1.5rem !important;
    }
    
    h2 {
        font-size: 1.3rem !important;
    }
    
    /* Buttons */
    .btn {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        border-radius: 0.375rem !important;
        margin-bottom: 0.5rem;
    }
    
    /* Cards */
    .card-body {
        padding: 1rem;
    }
    
    /* Stat Cards Grid */
    .row.g-4 {
        gap: 1rem !important;
    }
    
    /* Section Padding */
    section {
        padding: 2rem 0 !important;
    }
    
    .section-title {
        font-size: 1.75rem !important;
    }
    
    .section-subtitle {
        font-size: 1rem !important;
    }
    
    /* Footer */
    .footer {
        text-align: center;
    }
    
    .footer .row > div {
        margin-bottom: 2rem;
    }
    
    /* Notification Badge */
    #unreadCountSidebar {
        font-size: 0.6rem !important;
    }
    
    /* Step Cards */
    .step-card {
        padding: 1.5rem !important;
    }
    
    .step-number {
        width: 50px !important;
        height: 50px !important;
        font-size: 1.25rem !important;
    }
    
    /* Testimonials */
    .testimonial-card {
        padding: 1.5rem !important;
    }
    
    /* Use Case Cards */
    .use-case-icon {
        padding: 1.5rem !important;
    }
    
    .use-case-icon i {
        font-size: 2.5rem !important;
    }
    
    /* Form Fields */
    .form-builder-preview input,
    .form-builder-preview select,
    .form-builder-preview textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
    
    /* QR Code Modal */
    .modal-dialog {
        max-width: 95%;
    }
    
    /* Records Table - Mobile Cards */
    .records-table-mobile {
        display: block;
    }
    
    .record-card-mobile {
        background: white;
        border-radius: 10px;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .record-card-mobile .record-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0.75rem;
        padding-bottom: 0.75rem;
        border-bottom: 1px solid #e9ecef;
    }
    
    .record-card-mobile .record-body {
        font-size: 0.9rem;
        color: #6c757d;
    }
    
    .record-card-mobile .record-body > div {
        margin-bottom: 0.5rem;
    }
    
    .record-card-mobile .record-actions {
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        border-top: 1px solid #e9ecef;
        display: flex;
        gap: 0.5rem;
    }
}

/* Landscape Mobile */
@media (max-width: 896px) and (orientation: landscape) {
    .hero {
        padding: 2rem 0 !important;
    }
    
    .hero h1 {
        font-size: 2rem !important;
    }
    
    .sidebar {
        width: 240px;
    }
}

/* Touch Improvements */
@media (hover: none) and (pointer: coarse) {
    /* Increase tap targets */
    .btn,
    .nav-link,
    a {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Remove hover effects on touch devices */
    .card:hover,
    .stat-card:hover,
    .feature-card:hover {
        transform: none;
    }
    
    /* Better touch scrolling */
    .table-responsive,
    .workflow-canvas,
    .sidebar {
        -webkit-overflow-scrolling: touch;
    }
}

/* Accessibility - Reduce Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .mobile-menu-toggle,
    .navbar,
    .btn,
    .mobile-overlay {
        display: none !important;
    }
    
    .content {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .table thead {
        display: table-header-group;
    }
    
    .table tr {
        display: table-row;
        border: none;
    }
    
    .table td {
        display: table-cell;
        text-align: left;
        padding: 0.5rem;
    }
}

/* iOS Safe Area */
@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    .sidebar {
        padding-left: env(safe-area-inset-left);
    }
    
    .mobile-menu-toggle {
        left: calc(15px + env(safe-area-inset-left));
    }
}


