/* Brand Logo Customization */
.ss-brand-logo-container {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    flex-direction: row !important;
}

.ss-brand-logo-image {
    height: 30px !important;
    width: auto !important;
    flex-shrink: 0;
}

/* Login Page Specific */
.fi-simple-page .fi-simple-header {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Hide standard sidebar header (logo) since it's now in the top header */
aside.fi-sidebar .fi-sidebar-header {
    display: none !important;
}

/* FULL-WIDTH TOPBAR OVERRIDE */
.fi-topbar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 30 !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
}



/* Adjust sidebar to sit beneath the new full-width topbar - ONLY ON DESKTOP */
@media (min-width: 1024px) {
    .fi-sidebar {
        top: 4rem !important;
        height: calc(100vh - 4rem) !important;
        z-index: 20 !important;
    }
}

/* Ensure mobile sidebar is on top of everything when active */
@media (max-width: 1023px) {
    .fi-sidebar {
        z-index: 50 !important;
    }
}

/* Ensure main content is pushed down so the fixed topbar doesn't cover it */
.fi-main {
    padding-top: 4rem !important;
}

/* Ensuring alignment in the dashboard header/sidebar */
.fi-sidebar-header>a,
.fi-topbar-header>a {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
}



.fi-sidebar-item-label {
    font-size: 0.95rem !important;
    font-weight: 400 !important;
    /* Softens the text so it doesn't look too dark/heavy */
}

.fi-sidebar-item-icon {
    height: 1.25rem !important;
    width: 1.25rem !important;
}

.fi-sidebar-group {
    margin-top: 0.5rem !important;
}

/* ===== KEY FIX: force button to single row ===== */
.fi-sidebar-group-button {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    width: 100% !important;
    min-width: 0 !important;
    overflow: hidden !important;
}

/* ===== KEY FIX: label must shrink inside flex ===== */
.fi-sidebar-group-label {
    flex: 1 1 0% !important;
    min-width: 0 !important;
    font-size: 0.8rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
}

/* ===== KEY FIX: chevron must not push label down ===== */
.fi-sidebar-group-button svg {
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    width: 1.15rem !important;
    /* Restored to a larger, default-style size */
    height: 1.15rem !important;
}

/* Global Page Header Heading */
.fi-header-heading {
    font-size: 1.5rem !important;
}

/* Align Relation Manager search bar with its header title on the exact same row - DESKTOP */
@media (min-width: 1024px) {
    .fi-resource-relation-manager .fi-ta-header-ctn {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        border-bottom: 1px solid #e5e7eb !important;
        padding: 0.2rem 1rem 0.2rem 1rem !important;
    }

    /* Eliminate horizontal borders separating the merged blocks */
    .fi-resource-relation-manager .fi-ta-header-ctn>* {
        border: none !important;
    }

    /* Balance padding for a tight, elegant single-row header */
    .fi-resource-relation-manager .fi-ta-header-ctn .fi-ta-header {
        padding-bottom: 0 !important;
        padding-top: 0.5rem !important;
    }

    .fi-resource-relation-manager .fi-ta-header-ctn .fi-ta-header-toolbar {
        padding-bottom: 0 !important;
        padding-top: 0.5rem !important;
    }
}

/* =====================================================================
   RESPONSIVE LAYOUT FOR MOBILE / TABLET (< 1024px)
   DOM structure inside .fi-ta-header-ctn:
     - .fi-ta-header         (title text)
     - .fi-ta-header-actions (Ajouter button) — sibling, NOT child of .fi-ta-header
     - .fi-ta-header-toolbar (search bar)

   Target layout on mobile:
     Row 1: [Title ...................] [+ Ajouter]
     Row 2: [Search bar - full width           ]
   ===================================================================== */
@media (max-width: 1023px) {

    /* Container: flex row wrapping, allows Row1 and Row2 to form naturally */
    .fi-resource-relation-manager .fi-ta-header-ctn {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 0.6rem 0.5rem !important;
        padding: 1rem 1rem 0.85rem 1rem !important;
        border-bottom: 1px solid #e5e7eb !important;
        overflow: visible !important;
    }

    /* Borders between sections removed */
    .fi-resource-relation-manager .fi-ta-header-ctn>* {
        border: none !important;
    }

    /* Title: grows to fill available space in Row 1, stays on same row as button */
    .fi-resource-relation-manager .fi-ta-header-ctn .fi-ta-header {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        display: flex !important;
        align-items: center !important;
        overflow: hidden !important;
    }

    /* Ajouter button: does NOT grow, stays to the right of title in Row 1 */
    .fi-resource-relation-manager .fi-ta-header-ctn .fi-ta-header-actions,
    .fi-resource-relation-manager .fi-ta-header-ctn .fi-ta-actions {
        flex: 0 0 auto !important;
        position: static !important;
        top: auto !important;
        right: auto !important;
        margin: 0 !important;
    }

    /* Search toolbar: forces onto its own Row 2, full width */
    .fi-resource-relation-manager .fi-ta-header-ctn .fi-ta-header-toolbar {
        flex: 1 1 100% !important;
        width: 100% !important;
        padding: 0 0 0.25rem 0 !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        border-top: none !important;
        gap: 0.5rem !important;
    }

    /* Search input wrapper stretches full width */
    .fi-resource-relation-manager .fi-ta-header-ctn .fi-ta-header-toolbar>div,
    .fi-resource-relation-manager .fi-ta-header-ctn .fi-ta-header-toolbar .fi-ta-search-field {
        width: 100% !important;
        flex: 1 !important;
    }
}

/* ==========================================================================
   DASHBOARD GRID CLASSES (since standard Tailwind grid classes might be 
   stripped from Filament's core precompiled CSS)
   ========================================================================== */

@media (min-width: 768px) {
    .md\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }

    .lg\:grid-cols-5 {
        grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    }

    .lg\:col-span-3 {
        grid-column: span 3 / span 3 !important;
    }

    .lg\:col-span-2 {
        grid-column: span 2 / span 2 !important;
    }

    .lg\:col-span-12 {
        grid-column: span 12 / span 12 !important;
    }

    .lg\:col-span-5 {
        grid-column: span 5 / span 5 !important;
    }

    .lg\:col-span-4 {
        grid-column: span 4 / span 4 !important;
    }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-12 {
        grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
    }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

/* Override Filament native KPI stat value font size */
.fi-wi-stats-overview-stat-value {
    font-size: 1.25rem !important;
    /* text-xl, standard was text-3xl */
    line-height: 1.75rem !important;
}

/* Reduce padding for the Welcome/Bienvenue card */
.welcome-widget .fi-section,
.welcome-widget .fi-section-content,
.welcome-widget section {
    padding: 0 !important;
}

/* ── SweetStock custom scrollbar — mirrors the sidebar scrollbar ── */
.ss-scroll {
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

.ss-scroll::-webkit-scrollbar {
    width: 4px;
}

.ss-scroll::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 9999px;
}

.ss-scroll::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 9999px;
    border: none;
}

.ss-scroll::-webkit-scrollbar-thumb:hover {
    background-color: #9ca3af;
}

.dark .ss-scroll {
    scrollbar-color: #374151 transparent;
}

.dark .ss-scroll::-webkit-scrollbar-thumb {
    background-color: #374151;
}

.dark .ss-scroll::-webkit-scrollbar-thumb:hover {
    background-color: #4b5563;
}

/* Remove header border from specific sections */
.ss-no-header-border .fi-section-content-ctn {
    border-top: none !important;
}

.ss-compact-section .fi-section-content {
    padding-top: 0.5rem !important;
}

/* Add top padding to section header title */
.ss-section-top-pad .fi-section-header {
    padding-top: calc(0.75rem + 5px) !important;
}