/* ── Mobile: Filament table filter panel — full width, top aligned ── */
@media (max-width: 1023px) {
    /* Make the dropdown wrapper a full-screen overlay */
    .fi-ta-filters-dropdown {
        position: static !important;
    }

    /* The floating panel itself */
    .fi-ta-filters-dropdown .fi-dropdown-panel {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
        border-radius: 0 0 1rem 1rem !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
        z-index: 50 !important;
        transform: none !important;
    }
}

/* ── Mobile topbar logo ── */
@media (max-width: 1023px) {
    /* Make topbar the positioning context */
    .fi-topbar {
        position: relative !important;
    }
    /* Show the topbar-start that Filament hides on mobile */
    .fi-topbar-start {
        display: flex !important;
        position: absolute !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
        margin: 0 !important;
    }
    /* Hide desktop-only sidebar collapse buttons — not needed on mobile */
    .fi-topbar-open-collapse-sidebar-btn,
    .fi-topbar-close-collapse-sidebar-btn {
        display: none !important;
    }
}

/* ── Dashboard: stat card value font size (all screens) ── */
.fi-wi-stats-overview-stat-value {
    font-size: 1.25rem !important;
    line-height: 1.3 !important;
}

/* ── Dashboard: mobile stat cards ── */
@media (max-width: 639px) {

    /* Widget grid gap */
    .fi-dashboard-widgets {
        gap: 0.4rem !important;
    }

    /* Stat card padding */
    .fi-wi-stats-overview-stat {
        padding: 0.6rem 0.75rem !important;
    }
    .fi-wi-stats-overview-stat-content {
        padding: 0 !important;
    }

    /* Icon + label row — keep on one line */
    .fi-wi-stats-overview-stat-heading {
        display: flex !important;
        align-items: center !important;
        gap: 0.35rem !important;
        flex-wrap: nowrap !important;
    }

    /* Icon shrink */
    .fi-wi-stats-overview-stat-heading .fi-icon svg,
    .fi-wi-stats-overview-stat .fi-icon svg {
        width: 0.85rem !important;
        height: 0.85rem !important;
        flex-shrink: 0 !important;
    }

    /* Label text — single line, truncate if needed */
    .fi-wi-stats-overview-stat-label {
        font-size: 0.65rem !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    /* Big value number */
    .fi-wi-stats-overview-stat-value {
        font-size: 1.1rem !important;
        line-height: 1.2 !important;
        margin-top: 0.25rem !important;
        margin-bottom: 0.2rem !important;
    }

    /* Description / trend line */
    .fi-wi-stats-overview-stat-description {
        font-size: 0.6rem !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    .fi-wi-stats-overview-stat-description .fi-icon svg {
        width: 0.7rem !important;
        height: 0.7rem !important;
    }
}

/* ── Image Comparison modal: always top-aligned so height changes don't shift position ── */
.fi-modal-window-ctn {
    align-items: flex-start !important;
    padding-top: 2rem !important;
    padding-bottom: 2rem !important;
}

/* Hide section heading inside relation managers (Generated Images, Generated Documents, etc.) */
.fi-resource-relation-manager .fi-section-header {
    display: none !important;
}

/* ── Support Conversation Modal ────────────────────────────────────────── */

/* Scrollable thread container */
.support-chat-scroll {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 0.25rem;
    margin-bottom: 1rem;
}

/* Ticket meta row (icon + label items in one line) */
.support-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    font-size: 0.75rem;
    color: rgb(107 114 128);
}
.dark .support-meta-row { color: rgb(156 163 175); }

.support-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.support-meta-item .fi-icon svg {
    width: 0.875rem;
    height: 0.875rem;
}

/* Message row wrapper */
.support-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 0.625rem;
}
.support-msg-row.is-admin { flex-direction: row-reverse; }

/* Avatar circle */
.support-avatar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    user-select: none;
}
.support-avatar.is-admin  { background-color: var(--color-primary-500, #6366f1); }
.support-avatar.is-user   { background-color: var(--color-success-500, #22c55e); }

/* Bubble column */
.support-bubble-col {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-width: 78%;
}
.support-bubble-col.is-admin { align-items: flex-end; }
.support-bubble-col.is-user  { align-items: flex-start; }

/* Meta line above bubble */
.support-bubble-meta {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: rgb(107 114 128);
}
.dark .support-bubble-meta { color: rgb(156 163 175); }
.support-bubble-col.is-admin .support-bubble-meta { flex-direction: row-reverse; }

.support-bubble-meta-name {
    font-weight: 600;
    font-size: 0.75rem;
    color: rgb(55 65 81);
}
.dark .support-bubble-meta-name { color: rgb(209 213 219); }

/* Bubble body */
.support-bubble {
    border-radius: 1rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
.support-bubble.is-admin {
    border-bottom-right-radius: 0.125rem;
    background-color: var(--color-primary-500, #6366f1);
    color: #fff;
}
.support-bubble.is-user {
    border-bottom-left-radius: 0.125rem;
    background-color: #fff;
    color: rgb(31 41 55);
    box-shadow: 0 0 0 1px rgb(229 231 235) inset;
}
.dark .support-bubble.is-user {
    background-color: rgba(255 255 255 / 0.06);
    color: rgb(243 244 246);
    box-shadow: 0 0 0 1px rgba(255 255 255 / 0.1) inset;
}

/* Reply divider */
.support-reply-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.support-reply-divider-line {
    flex: 1;
    height: 1px;
    background-color: rgb(229 231 235);
}
.dark .support-reply-divider-line { background-color: rgba(255 255 255 / 0.1); }
.support-reply-divider-label {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgb(156 163 175);
}

/* Attachment image in bubble */
.support-attachment {
    margin-top: 0.25rem;
    max-height: 13rem;
    max-width: 100%;
    border-radius: 0.75rem;
    object-fit: contain;
    box-shadow: 0 0 0 1px rgb(229 231 235);
}
.dark .support-attachment { box-shadow: 0 0 0 1px rgba(255 255 255 / 0.1); }

/* Empty state */
.support-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem 0;
    font-size: 0.875rem;
    color: rgb(156 163 175);
}
.support-empty .fi-icon svg { width: 1.25rem; height: 1.25rem; }

/* Chat window — dark mode overrides inline styles */
.dark .support-chat-bg {
    background: rgba(15, 23, 42, 0.6) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

/* Custom scrollbar */
.support-chat-bg::-webkit-scrollbar       { width: 5px; }
.support-chat-bg::-webkit-scrollbar-track { background: transparent; }
.support-chat-bg::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 9999px;
}
.support-chat-bg::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.dark .support-chat-bg::-webkit-scrollbar-thumb       { background: rgba(255,255,255,0.18); }
.dark .support-chat-bg::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.32); }

/* User bubble — dark mode override only (light handled inline) */
.dark .support-user-bubble {
    background: rgba(255, 255, 255, 0.14) !important;
    color: #f1f5f9 !important;
}

/* Name label above bubble */
.support-bubble-name {
    font-weight: 600;
    color: #374151;
}
.dark .support-bubble-name {
    color: #d1d5db;
}

/* Meta time + divider line */
.support-divider-line {
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}
.dark .support-divider-line {
    background: rgba(255, 255, 255, 0.1);
}


/* ═══════════════════════════════════════════════════════════════════════
   Generated Images — Responsive Filters
   Desktop (≥1024px): filters shown inline above the table in one row
   Mobile  (<1024px): toggle button opens filters as a bottom-sheet overlay
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Desktop: always show the filter form, one row ── */
@media (min-width: 1024px) {
    /* Force the filter form visible regardless of Alpine x-show
       Alpine sets inline display:none — !important overrides it */
    .fi-ta-filters-above-content-ctn .fi-ta-filters {
        display: block !important;
    }

    /* Single-row grid: 7 equal columns for the 7 filters */
    .fi-ta-filters-above-content-ctn .fi-ta-filters .fi-fo-component-ctn {
        display: grid !important;
        grid-template-columns: repeat(7, 1fr) !important;
        gap: 0.5rem !important;
        align-items: end !important;
    }

    /* Hide heading, reset link, apply button — not needed inline */
    .fi-ta-filters-above-content-ctn .fi-ta-filters-header {
        display: none !important;
    }

    /* Hide the collapse toggle button on desktop */
    .fi-ta-filters-above-content-ctn .fi-ta-filters-trigger-action-ctn {
        display: none !important;
    }

    /* Compact: hide field labels, reduce padding */
    .fi-ta-filters-above-content-ctn .fi-fo-field-wrp-label {
        display: none !important;
    }
    .fi-ta-filters-above-content-ctn {
        padding-bottom: 0.5rem !important;
    }

    /* Full-width filter inputs within each grid cell */
    .fi-ta-filters-above-content-ctn .fi-ta-filters .fi-fo-field-wrp,
    .fi-ta-filters-above-content-ctn .fi-ta-filters .fi-select,
    .fi-ta-filters-above-content-ctn .fi-ta-filters .fi-input,
    .fi-ta-filters-above-content-ctn .fi-ta-filters select,
    .fi-ta-filters-above-content-ctn .fi-ta-filters input[type="text"] {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    /* Right-align the apply filters button */
    .fi-ta-filters-above-content-ctn .fi-ta-filters-apply-action-ctn {
        display: flex !important;
        justify-content: flex-end !important;
    }
}

/* ── Mobile: bottom-sheet overlay when filters are open ── */
@media (max-width: 1023px) {
    /* Show the toggle button */
    .fi-ta-filters-above-content-ctn .fi-ta-filters-trigger-action-ctn {
        display: inline-flex !important;
        margin-bottom: 0.5rem !important;
    }

    /* Hide filters when not open */
    .fi-ta-filters-above-content-ctn:not(.fi-open) .fi-ta-filters {
        display: none !important;
    }

    /* When open: full-width panel from the top */
    .fi-ta-filters-above-content-ctn.fi-open .fi-ta-filters {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: auto !important;
        width: 100vw !important;
        max-width: 100vw !important;
        min-width: unset !important;
        transform: none !important;
        inset: unset !important;
        z-index: 9999 !important;
        background: transparent !important;
        display: block !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    /* The inner filter card */
    .fi-ta-filters-above-content-ctn.fi-open .fi-ta-filters > div {
        background: #1f2937 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        border-radius: 0 0 1.25rem 1.25rem !important;
        padding: 1rem 1rem 1.5rem !important;
        max-height: 88vh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        box-shadow: 0 4px 24px rgba(0,0,0,0.4) !important;
    }

    /* Two-column grid inside the sheet */
    .fi-ta-filters-above-content-ctn.fi-open .fi-ta-filters .fi-fo-component-ctn {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.75rem !important;
    }

    /* Show heading and reset link */
    .fi-ta-filters-above-content-ctn.fi-open .fi-ta-filters-header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin-bottom: 1rem !important;
    }

    /* Show Apply button */
    .fi-ta-filters-above-content-ctn.fi-open .fi-ta-filters-apply-action-ctn {
        display: flex !important;
        margin-top: 1rem !important;
    }
}
