/* Custom styles */
/* Tabler uses Inter font family by default - no need to override */

/* Welcome message - Markdown rendered content */
.text-body p:last-child,
.card-body .text-body p:last-child {
	margin-bottom: 0;
}

.text-body ul,
.text-body ol {
	margin-bottom: 0.5rem;
	padding-left: 1.25rem;
}

/* Compact navbar */
.navbar {
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
    overflow: visible !important; /* Allow dropdown to show outside navbar */
}

.navbar .container-xl {
    overflow: visible !important;
}

.navbar-brand {
    height: auto !important;
    padding: 0 !important;
}

.navbar-brand img {
    height: 39px !important;
    width: auto !important;
    max-height: 39px !important;
}

.navbar-nav .nav-link {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
}

.navbar-nav .avatar {
    width: 2rem !important;
    height: 2rem !important;
    font-size: 0.875rem !important;
}

/* Mobile-friendly touch targets */
@media (max-width: 767.98px) {
    .navbar-toggler {
        min-height: 44px !important;
        min-width: 44px !important;
    }

    .navbar-nav .nav-link {
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
    }

    /* Full width nav items on mobile for better touch experience */
    .navbar-collapse .navbar-nav {
        width: 100%;
    }

    .navbar-collapse .navbar-nav .nav-item {
        width: 100%;
    }
}

/* Desktop navbar alignment */
@media (min-width: 768px) {

    /* Ensure navbar items are inline on desktop */
    .navbar-collapse .navbar-nav {
        flex-direction: row !important;
    }

    .navbar-nav .nav-link {
        display: flex;
        align-items: center;
    }
}

/* Equipment Privacy - Scrollable Owners List */
.owners-list-container {
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem;
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    background-color: var(--tblr-bg-surface-secondary);
}

/* Mobile: reduce max height for smaller screens */
@media (max-width: 767.98px) {
    .owners-list-container {
        max-height: 250px;
    }
}

/* Ensure checkboxes have proper spacing */
.owners-list-container .form-check {
    padding: 0.5rem;
    margin-bottom: 0;
    display: flex;
    align-items: center;
}

.owners-list-container .form-check+.form-check {
    border-top: 1px solid var(--tblr-border-color-translucent);
}

/* Make checkboxes visible and touch-friendly */
.owners-list-container .form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    margin: 0 0.5rem 0 0;
    cursor: pointer;
    flex-shrink: 0;
    position: static !important;
}

/* Touch-friendly checkbox labels */
.owners-list-container .form-check-label {
    cursor: pointer;
    display: block;
    padding: 0;
    margin: 0;
}

/* Private equipment badge */
.badge-private {
    background-color: var(--tblr-orange);
    color: white;
}

/* Equipment badges - top right corner */
.equipment-owner-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    justify-content: flex-end;
}

.equipment-owner-badge .badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    opacity: 0.9;
    white-space: nowrap;
}

/* Hide text on very small screens, show only icon */
@media (max-width: 575.98px) {
    .equipment-owner-badge .badge {
        padding: 0.25rem;
    }
}

/* Tablet and up: increase max height */
@media (min-width: 768px) {
    .owners-list-container {
        max-height: 400px;
    }
}

/* Sticky bottom card on mobile for form actions */
@media (max-width: 767.98px) {
    .sticky-bottom-mobile {
        position: sticky;
        bottom: 0;
        z-index: 1020;
        margin-top: 1rem !important;
        margin-bottom: 0 !important;
        border-radius: 0 !important;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }
}

/* Page actions - Mobile-first responsive behavior */

/* Small screens (<576px): Action block 100% width, buttons 100% width */
@media (max-width: 575.98px) {

    /* Container for page actions */
    .page-header .col-12.col-lg-auto {
        margin-top: 1rem;
    }

    /* Make btn-list stack vertically */
    .page-header .col-12.col-lg-auto .btn-list {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    /* Make forms in btn-list display as block (not inline) */
    .page-header .col-12.col-lg-auto .btn-list form {
        display: block !important;
        width: 100%;
    }

    /* Make buttons full width */
    .page-header .col-12.col-lg-auto .btn {
        width: 100% !important;
        justify-content: center;
    }

    /* Stack buttons vertically with gap for d-flex containers */
    .page-header .col-12.col-lg-auto .d-flex {
        flex-direction: column;
        gap: 0.5rem !important;
    }

    /* Hide the shortened text version */
    .page-header .col-12.col-lg-auto .btn .d-inline.d-sm-none {
        display: none !important;
    }

    /* Show the full text version */
    .page-header .col-12.col-lg-auto .btn .d-none.d-sm-inline {
        display: inline !important;
    }
}

/* Medium screens (576px - 991.98px): Action block 100% width, buttons auto width */
@media (min-width: 576px) and (max-width: 991.98px) {

    /* Container for page actions - still full width but with spacing */
    .page-header .col-12.col-lg-auto {
        margin-top: 1rem;
    }

    /* Make btn-list horizontal on medium screens */
    .page-header .col-12.col-lg-auto .btn-list {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    /* Forms stay inline on medium screens */
    .page-header .col-12.col-lg-auto .btn-list form {
        display: inline-block !important;
    }

    /* Buttons auto width on medium screens */
    .page-header .col-12.col-lg-auto .btn {
        width: auto !important;
    }

    /* d-flex containers stay horizontal */
    .page-header .col-12.col-lg-auto .d-flex {
        flex-direction: row !important;
        gap: 0.5rem !important;
    }
}

/* Large screens (≥992px): Action block on the right, buttons auto width */
@media (min-width: 992px) {

    /* No margin-top needed - same row as title */
    .page-header .col-12.col-lg-auto {
        margin-top: 0;
    }

    /* Buttons auto width */
    .page-header .col-12.col-lg-auto .btn {
        width: auto !important;
    }

    /* btn-list horizontal with gap */
    .page-header .col-12.col-lg-auto .btn-list {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }
}

/* Uploaded file type image thumbnail styling */
.uploadedFileTypeImage {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.25rem;
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    background-color: var(--tblr-bg-surface);
}

.uploadedFileTypeImage img {
    display: block;
    max-width: 200px;
    max-height: 200px;
    width: auto;
    height: auto;
    border-radius: calc(var(--tblr-border-radius) - 0.125rem);
}

/* Mobile: smaller thumbnail */
@media (max-width: 575.98px) {
    .uploadedFileTypeImage img {
        max-width: 150px;
        max-height: 150px;
    }
}

/* Uploaded file cell styling - cohesive design for form file uploads */
.uploaded-file-cell {
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    background-color: var(--tblr-bg-surface);
    padding: 1rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.uploaded-file-cell:hover {
    border-color: var(--tblr-border-color-translucent);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.uploaded-file-header {
    margin-bottom: 0.5rem;
}

.uploaded-file-header .form-label {
    font-weight: 500;
    color: var(--tblr-body-color);
    margin-bottom: 0;
}

.uploaded-file-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.uploaded-file-content .form-control {
    margin-bottom: 0;
}

/* Hide the automatically generated uploadedFileTypeImage from the form widget */
.uploaded-file-content .uploadedFileTypeImage {
    display: none !important;
}

/* Ensure file input is visible */
.uploaded-file-content input[type="file"] {
    display: block !important;
    width: 100%;
}

/* Custom grid layout for uploaded files */
.uploaded-file-grid {
    display: flex;
    flex-direction: column;
}

/* Ensure button matches input height */
.uploaded-file-grid .row.align-items-end .col-auto .btn {
    height: 100%;
    min-height: 40px;
}

/* Custom thumbnail for manually rendered images */
.uploaded-file-thumbnail {
    display: inline-block;
    width: 100%;
    max-width: 100%;
    text-align: center;
    margin-top: 0;
    padding: 0.25rem;
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    background-color: var(--tblr-bg-surface);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.uploaded-file-thumbnail:hover {
    border-color: var(--tblr-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.uploaded-file-thumbnail img {
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
    margin: 0 auto;
    border-radius: calc(var(--tblr-border-radius) - 0.125rem);
    transition: opacity 0.2s ease;
}

.uploaded-file-thumbnail a {
    display: block;
}

.uploaded-file-thumbnail a:hover img {
    opacity: 0.8;
}

.uploaded-file-preview {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-top: 0.75rem;
}

.uploaded-file-preview .uploadedFileTypeImage {
    margin-top: 0;
    width: 100%;
    max-width: 100%;
    text-align: center;
}

.uploaded-file-preview .uploadedFileTypeImage img {
    max-width: 100%;
    width: auto;
    height: auto;
    margin: 0 auto;
}

.uploaded-file-document {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    text-align: center;
    min-height: 180px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    border: 2px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    background-color: var(--tblr-bg-surface);
    gap: 1rem;
}

.uploaded-file-document:hover {
    border-color: var(--tblr-primary);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    background-color: var(--tblr-bg-surface-secondary);
}

.uploaded-file-document-icon {
    font-size: 4rem;
    color: var(--tblr-danger);
    line-height: 1;
}

.uploaded-file-document-icon i {
    display: block;
}

.uploaded-file-document-label {
    font-weight: 500;
    color: var(--tblr-body-color);
    font-size: 0.95rem;
}

.uploaded-file-document-action {
    margin-top: 0.5rem;
}

/* Compact versions for show page */
.uploaded-file-thumbnail-compact {
    display: inline-block;
    width: 100%;
    max-width: 200px;
    text-align: center;
    padding: 0.5rem;
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    background-color: var(--tblr-bg-surface);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.uploaded-file-thumbnail-compact:hover {
    border-color: var(--tblr-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.uploaded-file-thumbnail-compact img {
    display: block;
    max-width: 100%;
    max-height: 150px;
    width: auto;
    height: auto;
    margin: 0 auto;
    border-radius: calc(var(--tblr-border-radius) - 0.125rem);
    transition: opacity 0.2s ease;
}

.uploaded-file-thumbnail-compact a {
    display: block;
}

.uploaded-file-thumbnail-compact a:hover img {
    opacity: 0.8;
}

.uploaded-file-document-compact {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    background-color: var(--tblr-bg-surface);
    max-width: 400px;
}

.uploaded-file-document-compact-icon {
    font-size: 2rem;
    color: var(--tblr-danger);
    line-height: 1;
    flex-shrink: 0;
}

.uploaded-file-document-compact-icon i {
    display: block;
}

.uploaded-file-document-compact-label {
    font-weight: 500;
    color: var(--tblr-body-color);
    font-size: 0.9rem;
    flex: 1;
}

.uploaded-file-document-compact .btn {
    flex-shrink: 0;
}

/* Mobile: adjust compact sizes */
@media (max-width: 767.98px) {
    .uploaded-file-thumbnail-compact {
        max-width: 100%;
        max-height: 120px;
    }

    .uploaded-file-thumbnail-compact img {
        max-height: 120px;
    }

    .uploaded-file-document-compact {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        max-width: 100%;
    }

    .uploaded-file-document-compact .btn {
        width: 100%;
    }
}

.uploaded-file-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    text-align: center;
    min-height: 150px;
    opacity: 0.6;
    transition: opacity 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    border: 2px dashed var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
}

.uploaded-file-empty:hover {
    opacity: 1;
    border-color: var(--tblr-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.uploaded-file-actions {
    width: 100%;
    display: flex;
    justify-content: flex-start;
}

/* Mobile: adjust cell padding and spacing */
@media (max-width: 767.98px) {
    .uploaded-file-cell {
        padding: 0.75rem;
    }

    .uploaded-file-document {
        min-height: 140px;
        padding: 1.5rem 1rem;
        gap: 0.75rem;
    }

    .uploaded-file-document-icon {
        font-size: 3rem;
    }

    .uploaded-file-empty {
        min-height: 120px;
        padding: 1.5rem 1rem;
    }

    .uploaded-file-preview .uploadedFileTypeImage img {
        max-width: 100%;
    }
}

/* Tablet and up: ensure equal height columns */
@media (min-width: 768px) {
    .uploaded-file-cell {
        min-height: 280px;
    }
}

/* Bulk selection for subtasks */
.subtask-bulk-item-wrapper {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.subtask-bulk-item-wrapper.is-selectable .card {
    box-shadow: 0 0.5rem 1rem rgba(15, 23, 42, 0.06);
}

/* Colonne pour la checkbox : largeur 0 hors sélection, largeur fixe en mode sélection */
.subtask-bulk-checkbox {
    width: 0;
    flex: 0 0 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow: hidden;
    transition: width 0.15s ease, flex-basis 0.15s ease;
}

.subtask-bulk-checkbox .form-check-input {
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.subtask-bulk-checkbox--visible {
    width: 3rem;            /* largeur fixe identique pour toutes les cartes */
    flex: 0 0 3rem;
}

.subtask-bulk-checkbox--visible .form-check-input {
    opacity: 1;
    transform: translateX(0);
}

.subtask-bulk-actions {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1030;
    max-width: 100%;
}

.subtask-bulk-actions--visible {
    animation: subtask-bulk-actions-in 0.18s ease-out forwards;
}

@keyframes subtask-bulk-actions-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Tom Select (member / user pickers) — aligné Tabler */
.member-select.ts-wrapper {
    width: 100%;
    display: block !important;
    position: relative;
    overflow: visible;
}

/* Hauteur 40px ; dropdown en position absolute, n'agrandit pas le conteneur */
.member-select.ts-wrapper.form-select {
    min-height: 40px;
    background-image: none;
}

.member-select.ts-wrapper.form-select .ts-control {
    min-height: 40px;
    border-radius: var(--tblr-border-radius, 0.25rem);
}

.member-select.ts-wrapper .ts-control .item {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Caret qui pointe vers le haut quand le dropdown est ouvert */
.member-select.ts-wrapper .ts-control::after {
    content: '';
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 12px;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px 12px;
    transition: transform 0.2s ease;
    pointer-events: none;
}

.member-select.ts-wrapper.dropdown-active .ts-control::after {
    transform: translateY(-50%) rotate(180deg);
}

/* Dropdown : position absolute pour ne jamais agrandir le parent (ne pas toucher display/visibility) */
.member-select .ts-dropdown,
.member-select-dropdown,
.member-select-dropdown.single,
.ts-dropdown.member-select-dropdown,
div.member-select-dropdown {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    margin-top: 0.25rem !important;
    background-color: #fff !important;
    border: 1px solid #ced4da !important;
    border-radius: 0.25rem !important;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
    padding: 0.25rem 0 !important;
    z-index: 1055 !important;
}

.ts-dropdown.member-select-dropdown .ts-dropdown-content,
div.member-select-dropdown .ts-dropdown-content {
    max-height: 200px;
    overflow-y: auto;
}

.ts-dropdown.member-select-dropdown .option,
.ts-dropdown.member-select-dropdown [data-selectable],
div.member-select-dropdown .option,
div.member-select-dropdown [data-selectable] {
    color: #212529 !important;
    padding: 0.5rem 0.75rem !important;
    cursor: pointer;
}

.ts-dropdown.member-select-dropdown .option.active,
.ts-dropdown.member-select-dropdown [data-selectable].active,
div.member-select-dropdown .option.active,
div.member-select-dropdown [data-selectable].active {
    background-color: #e9ecef !important;
    color: #212529 !important;
}

.ts-dropdown.member-select-dropdown .optgroup-header,
div.member-select-dropdown .optgroup-header {
    color: #6c757d !important;
    background-color: #f8f9fa !important;
    padding: 0.375rem 0.75rem !important;
}

/* Grille contributions */
[data-collection-type-target="item"] .row.g-2 > [class*="col-"] {
    min-width: 0;
}

[data-collection-type-target="item"] .row.g-2 {
    align-items: center;
}

body.modal-open .ts-dropdown.member-select-dropdown {
    z-index: 1065;
}
