body {
    background-color: rgb(250, 249, 246);
}

/* Mobile and Tablet Responsiveness */
@media (max-width: 991.98px) {
    /* Ensure full width on mobile/tablet */
    .container-fluid,
    .container,
    .container-sm,
    .container-md,
    .container-lg,
    .container-xl,
    .container-xxl {
        padding-left: 15px !important;
        padding-right: 15px !important;
        max-width: 100% !important;
    }

    /* Stack buttons vertically on mobile/tablet */
    .btn-group,
    .btn-toolbar {
        flex-direction: column !important;
        width: 100% !important;
    }

    .btn-group .btn,
    .btn-toolbar .btn {
        margin-bottom: 0.5rem !important;
        width: 100% !important;
        border-radius: 0.375rem !important;
    }

    .btn-group .btn:last-child,
    .btn-toolbar .btn:last-child {
        margin-bottom: 0 !important;
    }

    /* Improve touch targets for mobile - but exclude table action buttons */
    .btn:not(td .btn):not(th .btn):not(.table .btn) {
        min-height: 44px !important;
        padding: 0.75rem 1rem !important;
        font-size: 1rem !important;
    }

    /* Keep table action buttons compact */
    td .btn,
    th .btn,
    .table .btn {
        min-height: auto !important;
        padding: 0.25rem 0.5rem !important;
        font-size: 0.875rem !important;
    }

    /* Small buttons in tables should stay small */
    td .btn-sm,
    th .btn-sm,
    .table .btn-sm {
        min-height: 32px !important;
        padding: 0.25rem 0.5rem !important;
        font-size: 0.75rem !important;
    }

    /* Large buttons outside tables can be bigger */
    .btn-lg:not(td .btn-lg):not(th .btn-lg):not(.table .btn-lg) {
        min-height: 48px !important;
        padding: 1rem 1.25rem !important;
        font-size: 1.125rem !important;
    }

    /* Stack form elements */
    .form-row,
    .row .col-auto,
    .row .col,
    .row .col-sm,
    .row .col-md,
    .row .col-lg,
    .row .col-xl {
        margin-bottom: 1rem;
    }

    /* Make tables responsive */
    .table-responsive {
        border: none;
    }

    table {
        font-size: 0.875rem;
    }

    /* Card improvements for mobile */
    .card {
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Navigation improvements for mobile burger menu */
    .navbar-collapse {
        background-color: var(--bs-primary);
        margin-top: 0.5rem;
        border-radius: 0.375rem;
        padding: 1rem;
    }

    .navbar-nav .nav-link {
        padding: 0.75rem 1rem !important;
        margin: 0.25rem 0;
        border-radius: 0.375rem;
        font-size: 1rem !important;
    }

    .navbar-nav .nav-link:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }

    /* Dropdown improvements for mobile */
    .dropdown-menu {
        border: none;
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    }

    .dropdown-item {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }

    /* Toast container adjustments for mobile */
    #toast-container {
        min-width: 90% !important;
        max-width: 90% !important;
        left: 5% !important;
        right: 5% !important;
        transform: none !important;
    }
}

/* Tablet specific (768px to 991.98px) */
@media (min-width: 768px) and (max-width: 991.98px) {
    /* Slightly larger touch targets for tablets - but not table buttons */
    .btn:not(td .btn):not(th .btn):not(.table .btn) {
        min-height: 42px !important;
        padding: 0.625rem 1rem !important;
    }

    /* Two-column layout for some button groups on tablet */
    .btn-group-tablet-2col {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    .btn-group-tablet-2col .btn {
        flex: 1 1 calc(50% - 0.25rem) !important;
        width: auto !important;
    }
}

/* Phone specific (up to 767.98px) */
@media (max-width: 767.98px) {
    /* Smaller text for very small screens */
    body {
        font-size: 0.875rem;
    }

    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.125rem; }
    h5 { font-size: 1rem; }
    h6 { font-size: 0.875rem; }

    /* Reduce padding on small screens */
    .container-fluid {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .card-body {
        padding: 0.75rem;
    }

    /* Stack everything single column */
    .row > * {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
}

/* Test Runner UI Improvements */
#testRunner .progress-bar {
    min-width: 3rem; /* Ensure percentage text is always visible */
}

#testRunner .list-group-item:hover {
    background-color: rgba(0, 123, 255, 0.1);
}

#testRunner .list-group-item.border-primary {
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Make the bottom nav truly sticky */
#testRunner .position-sticky {
    position: -webkit-sticky !important;
    position: sticky !important;
}

/* Improve sidebar scrolling */
#testStepList {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

#testStepList::-webkit-scrollbar {
    width: 6px;
}

#testStepList::-webkit-scrollbar-track {
    background: transparent;
}

#testStepList::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

#testStepList::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.4);
}

/* Loading Spinner Overlay */
.loading-spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.loading-spinner {
    background-color: white;
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    text-align: center;
    min-width: 200px;
}

.loading-spinner .spinner-border {
    width: 3rem;
    height: 3rem;
}

.loading-spinner p {
    margin-bottom: 0;
    color: #6c757d;
    font-size: 0.875rem;
}

/* Ensure all dashboard cards are the same height */
.dashboard-card {
    height: 280px; /* Set a fixed, reasonable height */
    display: flex;
    flex-direction: column;
}

.dashboard-card .card-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

.dashboard-card .card-text {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Mobile dashboard card adjustments */
@media (max-width: 991.98px) {
    .dashboard-card {
        height: auto !important;
        min-height: 200px;
    }
}

/* Custom badge colours for project lifecycle stages */
.badge.bg-purple {
    background-color: #6f42c1 !important;
    color: white !important;
}

.badge.bg-orange {
    background-color: #fd7e14 !important;
    color: white !important;
}

/* Task action buttons styling */
.btn-group-vertical .btn {
    margin-bottom: 2px;
}

.btn-group-vertical .btn:last-child {
    margin-bottom: 0;
}

/* Improve task list item spacing */
.list-group-item .btn-group-vertical {
    min-width: 32px;
}

/* Compact button styling for task actions */
.btn-sm.task-action {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Mobile task action improvements */
@media (max-width: 991.98px) {
    .btn-group-vertical {
        flex-direction: column !important;
        width: 100% !important;
    }

    .btn-group-vertical .btn {
        width: 100% !important;
        margin-bottom: 0.5rem !important;
        border-radius: 0.375rem !important;
    }

    .list-group-item .btn-group-vertical {
        min-width: 100% !important;
        margin-top: 1rem;
    }
}
