/* ===================================
   RESPONSIVE CSS FOR MOBILE DEVICES
   =================================== */

/* Base responsive utilities */
@media (max-width: 767.98px) {
    /* Container adjustments */
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    /* Typography responsive */
    h1, .h1 {
        font-size: 1.5rem;
    }
    
    h2, .h2 {
        font-size: 1.3rem;
    }
    
    h3, .h3 {
        font-size: 1.1rem;
    }
    
    /* Dashboard specific */
    .dashboard-title {
        font-size: 1.4rem;
    }
    
    .dashboard-subtitle {
        font-size: 0.9rem;
    }
    
    /* Card adjustments */
    .card {
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    /* Button responsive */
    .btn {
        font-size: 0.875rem;
        padding: 0.375rem 0.75rem;
    }
    
    .btn-sm {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Table responsive improvements */
    .table-responsive {
        border: none;
    }
    
    .table {
        font-size: 0.8rem;
    }
    
    .table td, .table th {
        padding: 0.5rem 0.25rem;
        vertical-align: middle;
    }
    
    /* Hide less important columns on mobile */
    .table .d-none-mobile {
        display: none !important;
    }
    
    /* Action buttons in tables */
    .table .btn {
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
        margin: 0.1rem;
    }
    
    /* Form responsive */
    .form-group {
        margin-bottom: 0.75rem;
    }
    
    .form-control {
        font-size: 0.9rem;
    }
    
    /* Sidebar adjustments */
    .sidebar {
        width: 100% !important;
    }
    
    .sidebar .nav-link {
        padding: 0.75rem 1rem;
    }
    
    .sidebar .nav-link span {
        font-size: 0.9rem;
    }
    
    /* Content wrapper */
    #content-wrapper {
        padding-left: 0 !important;
    }
    
    /* Page heading responsive */
    .d-sm-flex {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    
    .d-sm-flex .text-muted {
        margin-top: 0.5rem;
        font-size: 0.8rem;
    }
    
    /* Alert responsive */
    .alert {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
    
    /* Carousel responsive */
    .carousel-inner {
        max-height: 250px !important;
    }
    
    .carousel-item img {
        height: 250px !important;
    }
    
    /* Categories responsive */
    .component-categories {
        margin-bottom: 1rem;
    }
    
    .categories-text {
        font-size: 0.8rem;
    }
    
    /* Navigation responsive */
    .navbar-nav .nav-link {
        padding: 0.5rem 0.75rem;
    }
    
    /* Footer responsive */
    .footer {
        padding: 1rem 0;
    }
    
    .footer .col-md-6 {
        text-align: center;
        margin-bottom: 0.5rem;
    }
}

/* Extra small devices (portrait phones, less than 576px) */
@media (max-width: 575.98px) {
    /* Even smaller adjustments */
    .container-fluid {
        padding-left: 5px;
        padding-right: 5px;
    }
    
    h1, .h1 {
        font-size: 1.3rem;
    }
    
    .card-body {
        padding: 0.5rem;
    }
    
    .table {
        font-size: 0.7rem;
    }
    
    .btn {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Stack columns on very small screens */
    .col-xl-3, .col-md-6, .col-lg-2, .col-md-3 {
        margin-bottom: 0.5rem;
    }
    
    /* Carousel even smaller */
    .carousel-inner {
        max-height: 200px !important;
    }
    
    .carousel-item img {
        height: 200px !important;
    }
    
    /* Dropdown improvements for very small screens */
    .dropdown-menu {
        min-width: 180px !important;
        max-width: 90vw !important;
        right: 0.5rem !important;
        left: auto !important;
        background-color: #ffffff !important;
        border: 1px solid #e3e6f0 !important;
        box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15) !important;
        z-index: 1050 !important;
        opacity: 1 !important;
    }
    
    .dropdown-item {
        padding: 0.75rem 1.5rem;
        font-size: 0.875rem;
        background-color: transparent !important;
        color: #5a5c69 !important;
        border: none !important;
    }
    
    .dropdown-item:hover,
    .dropdown-item:focus {
        background-color: #f8f9fc !important;
        color: #3a3b45 !important;
    }
    
    /* Ensure user name is hidden on very small screens */
    .d-none.d-sm-inline {
        display: none !important;
    }
}

/* Tablet responsive (768px to 991.98px) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .sidebar {
        width: 200px !important;
    }
    
    .table {
        font-size: 0.9rem;
    }
    
    .card-body {
        padding: 1rem;
    }
}

/* Utility classes for responsive design */
.text-responsive {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.img-responsive {
    max-width: 100%;
    height: auto;
}

/* Mobile-first navigation improvements */
@media (max-width: 767.98px) {
    .navbar-toggler {
        border: none;
        padding: 0.25rem 0.5rem;
    }
    
    .navbar-collapse {
        margin-top: 0.5rem;
    }
    
    .dropdown-menu {
        position: static;
        float: none;
        width: 100%;
        margin-top: 0;
        background-color: transparent;
        border: 0;
        box-shadow: none;
    }
}

/* DataTables responsive improvements */
@media (max-width: 767.98px) {
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        text-align: center;
        margin-bottom: 0.5rem;
    }
    
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        text-align: center;
        margin-top: 0.5rem;
    }
    
    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 0.25rem 0.5rem;
        margin: 0.1rem;
    }
}

/* Form improvements for mobile */
@media (max-width: 767.98px) {
    .form-row .col {
        margin-bottom: 0.5rem;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .input-group .input-group-prepend,
    .input-group .input-group-append {
        width: 100%;
        margin-bottom: 0.25rem;
    }
    
    .input-group .form-control {
        border-radius: 0.25rem;
    }
}

/* Modal responsive */
@media (max-width: 767.98px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-header {
        padding: 0.75rem;
    }
    
    .modal-body {
        padding: 0.75rem;
    }
    
    .modal-footer {
        padding: 0.5rem;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin-bottom: 0.25rem;
    }
}

/* Badge responsive improvements */
@media (max-width: 767.98px) {
    .badge {
        font-size: 0.65rem;
        padding: 0.25rem 0.4rem;
    }
}

/* Icon button improvements for mobile */
@media (max-width: 767.98px) {
    .btn-icon-split {
        flex-direction: column;
        text-align: center;
    }
    
    .btn-icon-split .icon {
        margin-bottom: 0.25rem;
    }
    
    .btn-icon-split .text {
        font-size: 0.75rem;
    }
}

/* Empty state improvements */
@media (max-width: 767.98px) {
    .text-center.py-5 {
        padding: 2rem 1rem !important;
    }
    
    .text-center.py-5 .fa-3x {
        font-size: 2rem !important;
    }
}

/* Action buttons in tables - mobile stacking */
@media (max-width: 575.98px) {
    .table td:last-child {
        white-space: nowrap;
    }
    
    .table .btn {
        display: block;
        width: 100%;
        margin-bottom: 0.25rem;
    }
    
    .table .d-inline {
        display: block !important;
    }
}

/* Header improvements for mobile */
@media (max-width: 767.98px) {
    .d-flex.justify-content-between {
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    .d-flex.justify-content-between > div:last-child {
        margin-top: 1rem;
        width: 100%;
    }
    
    .d-flex.justify-content-between .btn {
        width: 100%;
    }
}

/* Alert improvements */
@media (max-width: 767.98px) {
    .alert-dismissible .close {
        padding: 0.5rem;
        font-size: 1rem;
    }
}

/* Dropdown menu improvements for mobile */
@media (max-width: 767.98px) {
    .dropdown-menu.dropdown-menu-right {
        right: 0 !important;
        left: auto !important;
        min-width: 200px;
    }
    
    .dropdown-divider {
        border-top: 1px solid #eaecf4 !important;
        margin: 0.5rem 0;
    }
    
    /* Ensure topbar dropdown is properly positioned */
    .topbar .nav-item.dropdown {
        position: relative;
    }
    
    .topbar .dropdown-menu {
        position: absolute !important;
        top: 100% !important;
        transform: none !important;
    }
    
    /* Fix for very small screens */
    .navbar-nav .dropdown-menu {
        position: absolute !important;
        float: none;
        width: auto;
        margin-top: 0;
        background-clip: padding-box;
        border-radius: 0.35rem;
    }
    
    /* Prevent dropdown from being cut off */
    .topbar {
        overflow: visible !important;
    }
    
    .navbar {
        overflow: visible !important;
    }
}

/* Print responsive */
@media print {
    .sidebar,
    .navbar,
    .btn,
    .pagination {
        display: none !important;
    }
    
    .container-fluid {
        padding: 0;
    }
    
    .card {
        border: 1px solid #000;
        box-shadow: none;
    }
}