/* KillPest custom utilities.
 * Keep this file minimal: prefer Tailwind utilities over custom CSS.
 * Only put here styles that cannot be expressed with Tailwind. */

/* Mobile app shell: on phones/tablets the sidebar must be fully off-canvas,
   never a collapsed rail. This file loads after Tailwind, so it is the final
   authority for responsive chrome behavior.

   Tailwind v4 uses the native `translate` CSS property (not `transform`) for
   utilities like `-translate-x-full`. Overriding `transform` alone leaves the
   `translate` variable active and the sidebar stays off-canvas — we have to
   reset `translate` directly. */
@media (max-width: 1279.98px) {
    #sidebar {
        position: fixed !important;
        inset: 0 auto 0 0 !important;
        width: min(18rem, 86vw) !important;
        translate: -105% 0 !important;
        transform: none !important;
        visibility: hidden !important;
    }

    #sidebar.sidebar-mobile-open {
        translate: 0 0 !important;
        transform: none !important;
        visibility: visible !important;
    }

    body.sidebar-mobile-open {
        overflow: hidden;
    }
}

@media (min-width: 1280px) {
    #sidebar {
        translate: none !important;
        transform: none !important;
        visibility: visible !important;
    }
}

/* Defensive mobile/tablet rendering for visits: cards on small screens, table
   only once there is enough horizontal space. */
.visits-mobile-list {
    display: block;
}

.visits-table-wrap {
    display: none;
}

@media (min-width: 768px) {
    .visits-mobile-list {
        display: none;
    }

    .visits-table-wrap {
        display: block;
    }
}

/* Custom confirm/alert modal — used app-wide via window.killpestConfirm /
   window.killpestAlert. Markup is generated by static/js/confirm.js. */
.km-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: km-fade-in 120ms ease-out;
}
.km-modal-content {
    background: #fff;
    border-radius: 0.75rem;
    width: 100%;
    max-width: 28rem;
    padding: 1.25rem;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
    outline: none;
    animation: km-pop-in 140ms ease-out;
}
.km-modal-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.km-modal-icon {
    flex: none;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1;
}
.km-modal-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
}
.km-modal-body {
    color: #334155;
    font-size: 0.925rem;
    line-height: 1.45;
    margin-bottom: 1.25rem;
    white-space: pre-line;
}
.km-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.km-modal-btn {
    border-radius: 0.375rem;
    padding: 0.5rem 0.9rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    min-height: 2.5rem;
    transition: background-color 120ms ease, box-shadow 120ms ease;
}
.km-modal-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(28, 104, 94, 0.35);
}
.km-modal-btn-secondary {
    background: #fff;
    border-color: #cbd5e1;
    color: #1e293b;
}
.km-modal-btn-secondary:hover { background: #f8fafc; }

@keyframes km-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes km-pop-in {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 640px) {
    .km-modal-backdrop {
        align-items: flex-end;
        padding: 0;
    }
    .km-modal-content {
        max-width: none;
        border-radius: 0.75rem 0.75rem 0 0;
        padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
        animation: km-slide-up 180ms ease-out;
    }
    .km-modal-actions {
        flex-direction: column-reverse;
    }
    .km-modal-actions .km-modal-btn {
        width: 100%;
    }
}

@keyframes km-slide-up {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
