/* Mobile Ergonomics Improvements */

/* Prevent iOS zooming on inputs */
@media screen and (max-width: 768px) {
    input, select, textarea, .form-control, .form-select {
        font-size: 16px !important;
    }
}

/* Larger touch targets for buttons */
.btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Improve spacing on mobile */
body {
    padding-bottom: 80px; /* Space for scrolling past bottom elements */
}

/* Search Results: Scrollable and better positioned */
.search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1050;
    width: 100%;
    max-height: 60vh;
    overflow-y: auto;
    background-color: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0 0 0.375rem 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.search-results .list-group-item {
    padding: 0.9rem 1rem;
    cursor: pointer;
    border-left: none;
    border-right: none;
}

.search-results .list-group-item:first-child {
    border-top: none;
}

/* Form group spacing */
.mb-3 {
    margin-bottom: 1.5rem !important;
}

/* Card adjustments for mobile */
@media (max-width: 576px) {
    .card-body {
        padding: 1.25rem;
    }

    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .navbar {
        margin-left: 0 !important;
        margin-right: 0 !important;
        border-radius: 0 !important;
    }
}

/* Theme toggler adjustments */
#theme-toggler {
    padding: 0.5rem 0.75rem;
}

/* Navbar adjustments */
.navbar-nav .nav-link {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.navbar-nav .btn {
    width: 100%;
    margin-bottom: 0.5rem;
    justify-content: flex-start;
}

@media (min-width: 992px) {
    .navbar-nav .btn {
        width: auto;
        margin-bottom: 0;
        justify-content: center;
    }
}

/* Loading state for submit button */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.75;
}

.btn-loading .btn-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 0.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =====================
   STICKY BOTTOM BAR
   Affichée via JS (IntersectionObserver) quand les boutons
   inline disparaissent du viewport — fonctionne sur tous écrans.
   ===================== */
.sticky-submit-bar {
    display: none; /* Contrôlé par JS */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1040;
    background-color: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
    padding: 0.75rem 1rem;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

/* =====================
   ATTACHMENT PREVIEWS
   ===================== */
.attachment-preview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.attachment-item {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
    overflow: hidden;
    background-color: var(--bs-body-tertiary-bg);
    min-width: 80px;
    max-width: 110px;
}

.attachment-item img {
    width: 100%;
    height: 70px;
    object-fit: cover;
    display: block;
}

.attachment-item .attachment-icon {
    font-size: 2rem;
    padding: 0.75rem;
    color: var(--bs-secondary);
}

.attachment-item .attachment-name {
    font-size: 0.65rem;
    padding: 0.2rem 0.4rem;
    text-align: center;
    word-break: break-all;
    max-width: 100%;
    color: var(--bs-body-color);
    line-height: 1.2;
    max-height: 2.4em;
    overflow: hidden;
}

.attachment-item .remove-attachment {
    position: absolute;
    top: 3px;
    right: 3px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0.85;
    transition: opacity 0.15s;
}

.attachment-item .remove-attachment:hover {
    opacity: 1;
}

.attachment-item .remove-attachment .btn-close {
    filter: invert(1);
    width: 10px;
    height: 10px;
}

/* Drag-over zone */
.drop-zone-active {
    border: 2px dashed var(--bs-primary) !important;
    background-color: var(--bs-primary-bg-subtle) !important;
}

/* =====================
   DESCRIPTION TRUNCATION (pending_requests)
   ===================== */
.description-truncated {
    max-height: 4.5em;
    overflow: hidden;
    position: relative;
    transition: max-height 0.3s ease;
}

.description-truncated.expanded {
    max-height: none;
}

.toggle-description {
    font-size: 0.75rem;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    color: var(--bs-primary);
    text-decoration: underline;
}

/* =====================
   URGENT BADGE ANIMATION
   ===================== */
.urgent-indicator {
    animation: pulse-border 1.5s ease-in-out infinite;
}

@keyframes pulse-border {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.3); }
    50% { box-shadow: 0 0 0 4px rgba(220, 53, 69, 0); }
}

/* =====================
   REQUEST CARDS (pending_requests)
   ===================== */
.request-card {
    transition: box-shadow 0.2s;
}

/* On touch devices, don't use translateY (causes layout issues) */
@media (hover: hover) {
    .request-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
    }
}

/* =====================
   PASSWORD TOGGLE (login)
   ===================== */
.password-wrapper {
    position: relative;
}

.password-toggle-btn {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    border: none;
    background: transparent;
    padding: 0 0.75rem;
    color: var(--bs-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    z-index: 5;
}

.password-toggle-btn:hover {
    color: var(--bs-body-color);
}

.password-wrapper .form-control {
    padding-right: 2.5rem;
}

/* =====================
   TOAST CONTAINER
   ===================== */
#toastContainer {
    max-width: min(400px, calc(100vw - 2rem));
}

/* =====================
   FILTER BAR (pending_requests)
   ===================== */
#filterBar {
    background-color: var(--bs-body-tertiary-bg);
    border-radius: 0.5rem;
    padding: 0.6rem 0.75rem;
}

/* =====================
   FORM SECTION HEADERS
   ===================== */
.card-header-collapsible {
    cursor: pointer;
    user-select: none;
}

.card-header-collapsible .collapse-icon {
    transition: transform 0.2s;
}

.card-header-collapsible.collapsed .collapse-icon {
    transform: rotate(-90deg);
}
