/* VivatisReg - Mobile Optimizations */

/* General mobile improvements */
@media (max-width: 768px) {
    /* Reduce padding on mobile */
    .container, .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }

    /* Make headings smaller on mobile */
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    /* Navbar improvements */
    .navbar-collapse {
        background-color: #f8f9fa;
        padding: 1rem;
        margin-top: 0.5rem;
        border-radius: 0.5rem;
    }

    .navbar-toggler {
        padding: 0.5rem 0.75rem;
        font-size: 1.25rem;
    }

    /* Dashboard layout - stack on mobile */
    .row > [class*='col-'] {
        margin-bottom: 1rem;
    }

    /* Hide sidebar on mobile, show as drawer */
    .col-md-3 .list-group {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        background-color: white;
        z-index: 1040;
        transition: left 0.3s ease;
        overflow-y: auto;
        box-shadow: 2px 0 5px rgba(0,0,0,0.1);
        padding-top: 60px;
    }

    .col-md-3 .list-group.show {
        left: 0;
    }

    /* Sidebar toggle button */
    .sidebar-toggle {
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 1050;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background-color: #0d6efd;
        color: white;
        border: none;
        box-shadow: 0 4px 8px rgba(0,0,0,0.3);
        font-size: 1.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background-color: rgba(0,0,0,0.5);
        z-index: 1030;
    }

    .sidebar-overlay.show {
        display: block;
    }

    /* Full width main content on mobile */
    .col-md-9 {
        width: 100%;
        max-width: 100%;
    }

    /* Card improvements */
    .card {
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Form improvements */
    .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.25rem;
    }

    .form-control, .form-select {
        font-size: 0.95rem;
    }

    /* Button improvements */
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
    }

    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.35rem;
    }

    /* Fix button icon alignment */
    .btn i {
        display: inline-flex;
        align-items: center;
    }

    /* Make button groups stack on mobile */
    .d-flex.gap-2 {
        flex-direction: column;
        gap: 0.5rem !important;
    }

    .d-flex.gap-2 .btn {
        width: 100%;
    }

    /* Table improvements - make responsive */
    .table-responsive {
        margin-bottom: 1rem;
    }

    .table {
        font-size: 0.85rem;
    }

    .table th, .table td {
        padding: 0.5rem 0.25rem;
        vertical-align: middle;
    }

    /* Hide less important columns on mobile */
    .table th:last-child,
    .table td:last-child {
        display: none;
    }

    /* Make action buttons stack vertically in tables */
    .table .btn-sm {
        display: block;
        width: 100%;
        margin-bottom: 0.25rem;
    }

    .table .btn-sm:last-child {
        margin-bottom: 0;
    }

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

    /* Pagination improvements */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    .pagination .page-item {
        margin: 0.1rem;
    }

    .pagination .page-link {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }

    /* Hide page numbers on very small screens, keep only prev/next */
    @media (max-width: 576px) {
        .pagination .page-item:not(:first-child):not(:last-child) {
            display: none;
        }
    }

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

    /* List group improvements */
    .list-group-item {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    /* Statistics cards on dashboard */
    .card.text-center h2 {
        font-size: 1.5rem;
    }

    .card.text-center .small {
        font-size: 0.8rem;
    }

    /* Search form improvements */
    .card .row.g-3 {
        gap: 1rem !important;
    }

    .card .row.g-3 > div {
        padding-left: 0;
        padding-right: 0;
    }

    /* Make search/filter form stack vertically */
    .card .row.g-3 .col-md-4,
    .card .row.g-3 .col-md-3,
    .card .row.g-3 .col-md-5 {
        width: 100%;
        max-width: 100%;
    }

    .card .row.g-3 .d-flex {
        flex-direction: column;
    }

    /* Fix header title and button layout on mobile */
    .d-flex.justify-content-between {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .d-flex.justify-content-between .btn {
        width: 100%;
    }

    /* Results info - stack on mobile */
    .d-flex.justify-content-between.align-items-center.mb-3 {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }

    /* Documentation page improvements */
    .toc {
        padding: 1rem;
        font-size: 0.9rem;
    }

    .doc-section {
        margin-bottom: 2rem;
    }

    .doc-section h2 {
        font-size: 1.5rem;
    }

    .doc-section h3 {
        font-size: 1.25rem;
    }

    /* Role cards on documentation */
    .role-card {
        margin-bottom: 1rem;
    }

    /* Make role cards full width on mobile */
    .role-card .card-body {
        font-size: 0.9rem;
    }

    .role-card .card-body ul {
        font-size: 0.85rem;
    }

    /* Ingredient details improvements */
    .table-borderless td {
        padding: 0.5rem 0.25rem;
        font-size: 0.9rem;
    }

    /* Fix overflow issues */
    body {
        overflow-x: hidden;
    }

    .container-fluid {
        overflow-x: hidden;
    }

    /* Improve touch targets (minimum 44px) */
    .btn, .page-link, .list-group-item, .form-control, .form-select {
        min-height: 44px;
    }
}

/* Very small screens (< 576px) */
@media (max-width: 576px) {
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    /* Hide icon text on very small screens, show only icons */
    .btn i + span {
        display: none;
    }

    /* Make logo smaller */
    .navbar-brand img {
        max-height: 30px;
    }

    /* Stack dashboard statistics vertically */
    .row > .col-md-3 {
        width: 100%;
        max-width: 100%;
    }

    /* Simplify table on very small screens */
    .table {
        font-size: 0.75rem;
    }

    .table thead {
        font-size: 0.7rem;
    }

    /* Show only essential info in table rows */
    .table td small {
        display: none;
    }
}

/* Tablet optimizations (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .container {
        max-width: 100%;
    }

    /* Two columns for statistics cards */
    .row > .col-md-3 {
        width: 50%;
    }

    /* Adjust table font size */
    .table {
        font-size: 0.9rem;
    }
}

/* Landscape mobile optimization */
@media (max-width: 896px) and (orientation: landscape) {
    /* Reduce vertical spacing in landscape */
    .mb-4 {
        margin-bottom: 1rem !important;
    }

    .mt-4 {
        margin-top: 1rem !important;
    }

    /* Make navbar more compact */
    .navbar {
        padding: 0.5rem 1rem;
    }

    /* Reduce card padding */
    .card-body {
        padding: 0.75rem;
    }
}

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

    .container-fluid, .container {
        width: 100%;
        max-width: 100%;
    }

    .table {
        font-size: 10pt;
    }

    .badge {
        border: 1px solid #000;
    }
}
