/* Resolv custom styles — supplements Tailwind */

/* HTMX loading indicator */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Swap transition: fade in */
.htmx-settling .htmx-added {
    opacity: 0;
}

.htmx-added {
    opacity: 1;
    transition: opacity 0.2s ease-in;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.25rem;
}

/* Priority badges */
.badge-critical { background-color: #dc2626; color: #fff; }
.badge-high     { background-color: #f97316; color: #fff; }
.badge-medium   { background-color: #eab308; color: #1f2937; }
.badge-low      { background-color: #6b7280; color: #fff; }

/* Status badges */
.badge-open        { background-color: #10b981; color: #fff; }
.badge-in_progress { background-color: #8b5cf6; color: #fff; }
.badge-pending     { background-color: #f59e0b; color: #1f2937; }
.badge-resolved    { background-color: #3b82f6; color: #fff; }
.badge-closed      { background-color: #6b7280; color: #fff; }

/* Dark mode adjustments for badges */
.dark .badge-medium { background-color: #a16207; color: #fef3c7; }

/* ── Focus ring ───────────────────────────────────────────── */
*:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* ── Dark mode transitions ────────────────────────────────── */
html {
    transition: background-color 0.15s ease, color 0.15s ease;
}

/* ══════════════════════════════════════════════════════════════
   DARK MODE — Global overrides
   
   These rules catch ALL bg-white panels, borders, text, etc.
   so individual templates don't need dark: classes on every element.
   Uses a blue-tinted dark slate palette for warmth.
   ══════════════════════════════════════════════════════════════ */

/* ── Panel / card backgrounds ─────────────────────────────── */
/* bg-white → dark slate with subtle indigo undertone */
.dark .bg-white {
    background-color: #1a1f2e !important;
}
/* bg-gray-50 (page background, table headers, hover states) */
.dark .bg-gray-50 {
    background-color: #111827 !important;
}
/* bg-gray-100 (buttons, hover) */
.dark .bg-gray-100 {
    background-color: #1e2538 !important;
}
.dark .bg-gray-100:hover,
.dark .hover\:bg-gray-50:hover {
    background-color: #252d42 !important;
}
.dark .hover\:bg-gray-200:hover {
    background-color: #2a3350 !important;
}

/* ── Borders and dividers ─────────────────────────────────── */
.dark .border-gray-200,
.dark .border-gray-100 {
    border-color: #2a3350 !important;
}
.dark .border-gray-300 {
    border-color: #374160 !important;
}
.dark .divide-gray-200 > :not(:last-child),
.dark .divide-gray-100 > :not(:last-child) {
    border-color: #2a3350 !important;
}

/* Ring colors (card outlines) */
.dark .ring-gray-900\/5 {
    --tw-ring-color: rgba(99, 102, 241, 0.12) !important; /* subtle indigo glow */
}
.dark .ring-gray-200 {
    --tw-ring-color: #2a3350 !important;
}
.dark .hover\:ring-brand-300:hover {
    --tw-ring-color: rgba(99, 102, 241, 0.4) !important;
}

/* ── Text colors ──────────────────────────────────────────── */
.dark .text-gray-900 {
    color: #e5e7ef !important;
}
.dark .text-gray-800 {
    color: #d1d5e0 !important;
}
.dark .text-gray-700 {
    color: #b8bdd0 !important;
}
.dark .text-gray-600 {
    color: #9ca3bb !important;
}
.dark .text-gray-500 {
    color: #7c84a0 !important;
}
.dark .text-gray-400 {
    color: #6b7294 !important;
}

/* ── Form inputs ──────────────────────────────────────────── */
.dark input[type="text"],
.dark input[type="email"],
.dark input[type="password"],
.dark input[type="search"],
.dark input[type="date"],
.dark input[type="number"],
.dark textarea,
.dark select {
    background-color: #151a28 !important;
    border-color: #2a3350 !important;
    color: #e5e7ef !important;
}

.dark input[type="text"]:focus,
.dark input[type="email"]:focus,
.dark input[type="password"]:focus,
.dark input[type="search"]:focus,
.dark input[type="date"]:focus,
.dark input[type="number"]:focus,
.dark textarea:focus,
.dark select:focus {
    border-color: #6366f1 !important;
    background-color: #1a1f2e !important;
}

/* Disabled inputs */
.dark input:disabled,
.dark select:disabled,
.dark textarea:disabled {
    background-color: #111827 !important;
    color: #6b7294 !important;
}

/* Checkboxes */
.dark input[type="checkbox"] {
    background-color: #151a28 !important;
    border-color: #374160 !important;
}

/* ── Tables ───────────────────────────────────────────────── */
.dark table thead,
.dark thead.bg-gray-50 {
    background-color: #141827 !important;
}

.dark table tbody tr:hover {
    background-color: #1e2538 !important;
}

.dark table tbody {
    border-color: #2a3350 !important;
}

.dark th {
    color: #7c84a0 !important;
}

/* ── Modals ───────────────────────────────────────────────── */
.dark .bg-gray-500\/75 {
    background-color: rgba(0, 0, 0, 0.7) !important;
}

/* Modal content */
.dark .shadow-xl {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5) !important;
}

/* ── Specific component overrides ─────────────────────────── */

/* Admin dashboard stat cards: slightly different shade */
.dark .bg-blue-600 { color: #93c5fd; }
.dark .bg-red-600 { color: #fca5a5; }
.dark .text-blue-600 { color: #93c5fd !important; }
.dark .text-red-600 { color: #fca5a5 !important; }
.dark .text-green-600 { color: #86efac !important; }
.dark .text-amber-600 { color: #fcd34d !important; }

/* Alert / delete panels */
.dark .ring-red-200 {
    --tw-ring-color: rgba(239, 68, 68, 0.25) !important;
}

/* Internal note backgrounds */
.dark .bg-amber-50 {
    background-color: rgba(217, 119, 6, 0.1) !important;
}

/* Portal cards */
.dark .hover\:ring-brand-300:hover .ring-gray-200 {
    --tw-ring-color: rgba(99, 102, 241, 0.3) !important;
}

/* Chart bar chart tooltip */
.dark .bg-gray-800 {
    background-color: #0f1219 !important;
}

/* ── Scrollbar ────────────────────────────────────────────── */
.dark ::-webkit-scrollbar {
    width: 8px;
}
.dark ::-webkit-scrollbar-track {
    background: #111827;
}
.dark ::-webkit-scrollbar-thumb {
    background: #2a3350;
    border-radius: 4px;
}
.dark ::-webkit-scrollbar-thumb:hover {
    background: #374160;
}

/* ── Line clamp utility ───────────────────────────────────── */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Responsive top bar and sidebar drawer ─────────────────────
   Plain CSS (not Tailwind) so it works whatever the compiled CSS holds.
   ≥1024px: fixed sidebar, menu button hidden, user links inline.
   <1024px: sidebar becomes a drawer opened by the top bar's menu button,
   and the user links move into a menu under the user's name. */
.nav-wide { display: none; }
.nav-narrow > summary::-webkit-details-marker { display: none; }

@media (min-width: 1024px) {
    .sidebar-toggle, .sidebar-backdrop, .nav-narrow { display: none !important; }
    .nav-wide { display: flex; }
}

@media (max-width: 1023.98px) {
    .app-sidebar {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 3.5rem;            /* below the 56px top bar */
        bottom: 0;
        left: 0;
        width: 16rem;
        max-width: 85vw;
        z-index: 40;
        padding: 1rem 0;
        overflow-y: auto;
        background: #ffffff;
        border-right: 1px solid #e5e7eb;
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform 0.2s ease, visibility 0.2s;
    }
    .dark .app-sidebar { background: #252a36; border-right-color: #374151; }
    body.sidebar-open .app-sidebar {
        transform: none;
        visibility: visible;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    }
    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: 3.5rem;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 35;
        background: rgba(17, 24, 39, 0.4);
    }
    body.sidebar-open .sidebar-backdrop { display: block; }
    body.sidebar-open { overflow: hidden; } /* no page scroll behind the drawer */
}

/* Customer portal: links collapse into a menu below 768px. */
.portal-links-narrow > summary::-webkit-details-marker { display: none; }
@media (min-width: 768px) {
    .portal-links-narrow { display: none !important; }
}
@media (max-width: 767.98px) {
    .portal-links-wide { display: none !important; }
}
