/* Filament Compact Theme */

/* Filament Tables - header sticky */
/* .fi-ta-content are overflow:auto din Filament, ceea ce blochează sticky.
   Îl facem visible ca sticky să fie relativ la .fi-main-scroll-container */
.fi-ta-content {
    overflow: visible !important;
}
.fi-ta-header-ctn {
    position: sticky;
    top: 0;
    z-index: 20;
    background-color: rgb(255 255 255);
    border-top: none !important;
}
/* Anulează divide-y care pune border-top pe copiii .fi-ta-header-ctn */
.fi-ta-header-ctn > * {
    border-top: none !important;
}
.dark .fi-ta-header-ctn {
    background-color: rgb(17 24 39);
}
.fi-ta-table thead th {
    position: sticky;
    top: 48px; /* înălțimea fi-ta-header-ctn */
    z-index: 10;
    background-color: rgb(249 250 251);
    box-shadow: inset 0 -1px 0 rgb(156 163 175); /* border-bottom simulat inset, merge cu sticky */
}
.dark .fi-ta-table thead th {
    background-color: rgb(17 24 39);
}

/* Audit Log - tabel scrollabil cu header sticky */
.audit-table-container {
    overflow: auto;
    max-height: 70vh;
}
.audit-table-container th {
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Sections - reduce padding */
.fi-section-content {
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
}

.fi-section-header {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
}

/* Grid gaps in forms - very compact */
.fi-form > .grid {
    gap: 0.5rem !important;
}

.fi-section-content > .grid {
    column-gap: 0.5rem !important;
    row-gap: 0.1rem !important;
}

/* Form fields spacing */
.fi-fo-field-wrp {
    gap: 0.25rem !important;
}

/* Groups inside sections */
.fi-fo-component-ctn > .grid {
    gap: 0.1rem !important;
}

/* Override Tailwind gap-6 in form sections */
.fi-fo-component-ctn.gap-6 {
    gap: 1rem !important;
}

/* Cards / Sections */
.fi-section {
    border-radius: 0.5rem !important;
    border: 1px solid rgb(229 231 235) !important;  /* gray-200 */
}

/* Section header with background */
.fi-section-header {
    background: rgb(249 250 251) !important;  /* gray-50 */
    border-bottom: 1px solid rgb(229 231 235) !important;  /* gray-200 */
    border-radius: 0.5rem 0.5rem 0 0 !important;
    margin: -1px -1px 0 -1px !important;  /* compensate section padding */
}

.fi-section-header-heading {
    font-weight: 600 !important;
    color: rgb(55 65 81) !important;  /* gray-700 */
}

/* Filter bar buttons */
.fi-filter-btn {
    padding: 0.375rem 0.75rem !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    border-radius: 0.5rem !important;
    transition: background-color 0.15s, color 0.15s !important;
    background-color: #f3f4f6;
    color: #374151;
    white-space: nowrap !important;
}
.fi-filter-btn:hover {
    background-color: #e5e7eb;
}

/* Table container - allow filter bar to be fully visible */
.fi-ta-ctn {
    overflow: visible !important;
}

/* Table row hover highlight */
.fi-ta-row:hover > td {
    background-color: rgb(234, 242, 251) !important; /* gray-100 */
}

/* Table - compact rows */
.fi-ta-row td {
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
}
.fi-ta-row td div {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}
.fi-ta-text,
.fi-ta-icon {
    gap: 0.225rem !important;
}
.fi-ta-header-cell {
    padding-top: 0.4rem !important;
    padding-bottom: 0.4rem !important;
}

/* Page header */
.fi-header {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
}

/* Table header - buton + căutare pe același rând, dreapta */
.fi-ta-header-ctn {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-end !important;
    padding: 0.375rem 1rem !important;
    gap: 0.5rem !important;
}
.fi-ta-header-ctn > .fi-ta-header {
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    order: 2 !important;
}
/* Când există bară de filtre, filtrele iau spațiul disponibil, restul rămân dreapta */
.fi-ta-filters-above-content-ctn {
    flex: 1 !important;
    padding: 0 !important;
}
.fi-add-btn svg {
    margin-left: 0.35rem !important;
}
.fi-ta-header-ctn > .fi-ta-header-toolbar {
    padding: 0 !important;
    border: none !important;
    order: 1 !important;
    margin-left: auto !important;
}
.fi-ta-header-ctn > .fi-ta-header-toolbar > div {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* Buttons in forms */
.fi-form-actions {
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
}

/* Reduce label margin */
.fi-fo-field-wrp-label {
    margin-bottom: 0.125rem !important;
}

/* Inline labels - tighter */
.fi-fo-field-wrp.fi-inline {
    gap: 0.5rem !important;
}

.fi-fo-field-wrp.fi-inline .fi-fo-field-wrp-label {
    min-width: 7rem !important;
    max-width: 7rem !important;
    width: 7rem !important;
    white-space: nowrap !important;
}

/* Force label container fixed width */
.fi-fo-field-wrp.fi-inline > div:first-child {
    min-width: 7rem !important;
    max-width: 7rem !important;
    flex-shrink: 0 !important;
}

/* Input fields - compact */
.fi-input-wrp {
    min-height: 2rem !important;
    max-width: 220px !important;
}

.fi-input {
    padding-top: 0.375rem !important;
    padding-bottom: 0.375rem !important;
    font-size: 0.875rem !important;
}

/* Select inputs compact */
.fi-select-input {
    padding-top: 0.375rem !important;
    padding-bottom: 0.375rem !important;
    min-height: 2rem !important;
}

.fi-select {
    max-width: 220px !important;
}

/* Fixed width for input suffixes - align nicely */
.fi-input-wrp-suffix {
    min-width: 3rem !important;
    width: 3rem !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}

/* Prevent label wrapping */
.fi-fo-field-wrp-label {
    white-space: nowrap !important;
}

/* Breadcrumbs in topbar - force visible and positioned */
.fi-breadcrumbs,
.fi-breadcrumbs.hidden,
.fi-breadcrumbs.sm\:block {
    position: fixed !important;
    top: 0 !important;
    left: 4.5rem !important;
    height: 2.875rem !important;
    display: flex !important;  /* Override hidden class */
    visibility: visible !important;
    align-items: center !important;
    z-index: 45 !important;  /* Above topbar (z-index: 40) */
    padding-left: 1rem !important;
    background: transparent !important;
    transition: left 0.15s ease !important;
}

/* Adjust breadcrumbs when sidebar is expanded */
.fi-layout:has(.fi-sidebar-open) .fi-breadcrumbs {
    left: 20rem !important;  /* 320px = sidebar width when open */
}

/* Collapse page header zone (breadcrumbs moved to topbar via position:fixed) */
.fi-header {
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
}

/* Hide the heading text (empty anyway) */
.fi-header-heading {
    display: none !important;
}

/* ===== Scrollbar sub topbar - Via layout wrapper ===== */
/* Prevent body/html scroll */
html, body {
    overflow: hidden !important;
    height: 100vh !important;
}

/* Layout fills viewport */
.fi-layout {
    height: 100vh !important;
    overflow: hidden !important;
}

/* Main container as flex column */
.fi-main-ctn {
    height: 100vh !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Topbar fixed at top - no scroll, compact */
.fi-topbar {
    flex-shrink: 0 !important;
    z-index: 40 !important;
    background: rgb(249 250 251) !important;
}
.fi-topbar nav {
    height: 2.875rem !important;
    min-height: 2.875rem !important;
}
.fi-topbar nav > div {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* Scroll container - wrapper adăugat în layout */
.fi-main-scroll-container {
    flex: 1 !important;
    overflow-y: scroll !important;  /* Always visible */
    overflow-x: hidden !important;
    padding-right: 0 !important;  /* Scrollbar at edge */
}

/* Main content inside scroll container */
.fi-main {
    padding-bottom: 2rem !important;  /* Space at bottom */
}

/* Sidebar also fills height */
.fi-sidebar {
    height: 100vh !important;
    overflow-y: auto !important;
}

/* Sidebar header area - clickable toggle */
aside > .overflow-x-clip {
    cursor: pointer !important;
}

/* Sidebar collapsed - reglare latime */
aside:not(.fi-sidebar-open) {
    width: 4.5rem !important;
}

/* Sidebar + nav interior - scrollbar invizibil */
.fi-sidebar,
.fi-sidebar-nav {
    scrollbar-width: none !important;
}
.fi-sidebar::-webkit-scrollbar,
.fi-sidebar-nav::-webkit-scrollbar {
    display: none !important;
}

.qty_option{
    vertical-align: middle;
    height: 100%;
    padding-top: 1.4rem;
}

/* În modale - resetăm restricțiile compact */
.fi-modal .fi-input-wrp {
    max-width: none !important;
}
.fi-modal .fi-select {
    max-width: none !important;
}
.fi-modal .fi-fo-field-wrp.fi-inline {
    flex-direction: column !important;
}
.fi-modal .fi-fo-field-wrp.fi-inline .fi-fo-field-wrp-label {
    min-width: auto !important;
    max-width: none !important;
    width: auto !important;
}
.fi-modal .fi-fo-field-wrp.fi-inline > div:first-child {
    min-width: auto !important;
    max-width: none !important;
}
/* Sidebar header compact - same height as topbar */
.fi-sidebar-header {
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
    min-height: 2.875rem !important;
    height: 2.875rem !important;
}
/* Filter bar - proprietăți echipamente: radio + select + search pe aceeași linie */
/* Flex pe grid-ul interior Filament, nu pe wrapper */
.filter-props-bar > .fi-fo-component-ctn {
    display: flex !important;
    align-items: center !important;
    gap: 0 !important;
    flex-wrap: nowrap !important;
}
.filter-props-bar > .fi-fo-component-ctn > div {
    grid-column: unset !important;
}
.filter-props-bar .fi-fo-field-wrp {
    gap: 0 !important;
}
/* Radio: doar cât ocupă conținutul, anulează grid 3-col Filament pe field wrapper */
.filter-props-bar > .fi-fo-component-ctn > div:has(.filter-props-bar-type) {
    flex: 0 0 auto;
}
.filter-props-bar > .fi-fo-component-ctn > div:has(.filter-props-bar-type) .fi-fo-field-wrp > div {
    display: contents !important;
}
/* Select tip echipament: inline, cât are nevoie */
.filter-props-bar > .fi-fo-component-ctn > div:has(.filter-props-bar-select) {
    flex: 0 0 auto;
    margin-left:1rem;
}
.filter-props-bar > .fi-fo-component-ctn > div:has(.filter-props-bar-select) .fi-fo-field-wrp > div {
    display: contents !important;
}
/* Search: lățime fixă ca pe /clients, la dreapta */
.filter-props-bar > .fi-fo-component-ctn > div:has(.filter-props-bar-search) {
    flex: 0 0 auto;
    margin-left: auto !important;
    margin-right: 110px;
    width: 220px;
}
/* Ascunde label "Căutare" - placeholder e suficient */
.filter-props-bar > .fi-fo-component-ctn > div:has(.filter-props-bar-search) .fi-fo-field-wrp-label {
    display: none !important;
}
/* Search: input full width */
.filter-props-bar > .fi-fo-component-ctn > div:has(.filter-props-bar-search) .fi-fo-field-wrp > div {
    display: block !important;
}
.filter-props-bar > .fi-fo-component-ctn > div:has(.filter-props-bar-search) .fi-input-wrp {
    max-width: none !important;
    width: 100% !important;
}
/* Ascunde header "Filtre", păstrăm butonul "Resetare filtre" după search */
.fi-ta-filters-above-content-ctn .fi-ta-filters {
    position: relative;
}
.fi-ta-filters-above-content-ctn .fi-ta-filters > .flex.items-center.justify-between {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    pointer-events: none;
}
.fi-ta-filters-above-content-ctn .fi-ta-filters > .flex.items-center.justify-between > h4 {
    display: none;
}
.fi-ta-filters-above-content-ctn .fi-ta-filters > .flex.items-center.justify-between > div:has(.fi-link) {
    pointer-events: auto;
    padding-left: 0.5rem;
}
