/* Tasks
   Tasks / Kanban overrides */

/* =======================================================================
   Task Kanban Readability Override
   Keeps task details visible and uses scrolling instead of card squeeze.
   ======================================================================= */
.kanban-container .kanban-board {
    display: flex !important;
    flex: 1 !important;
    min-height: 0 !important;
    align-items: flex-start !important;
    gap: 1rem !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x proximity !important;
}

.kanban-container .kanban-column {
    min-width: 360px !important;
    width: 360px !important;
    height: 100% !important;
    flex-shrink: 0 !important;
    scroll-snap-align: start !important;
}

.kanban-container {
    height: calc(100vh - 80px) !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

.kanban-container .kanban-column .column-content {
    min-height: 0 !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
}

.kanban-container .task-card-body {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    max-height: none !important;
}

.kanban-container .task-details,
.kanban-container .task-facts,
.kanban-container .task-fact,
.kanban-container .task-assignee,
.kanban-container .task-deadline,
.kanban-container .task-priority,
.kanban-container .task-actions {
    visibility: visible !important;
    opacity: 1 !important;
}

.kanban-container .task-details {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.45rem !important;
}

.kanban-container .task-facts {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.4rem !important;
}

.kanban-container .task-fact {
    display: flex !important;
}

.kanban-container .task-actions {
    display: flex !important;
}

/* Explicit fix: Pending column must never collapse task details */
.kanban-container .kanban-column.column-status-pending .task-card {
    min-height: 220px !important;
}

.kanban-container .kanban-column.column-status-pending .task-card .task-card-body {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

.kanban-container .kanban-column.column-status-pending .task-card .task-details,
.kanban-container .kanban-column.column-status-pending .task-card .task-facts,
.kanban-container .kanban-column.column-status-pending .task-card .task-fact,
.kanban-container .kanban-column.column-status-pending .task-card .task-actions {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.kanban-container .kanban-column.column-status-pending .task-card .task-facts {
    flex-direction: column !important;
}

@media (max-width: 1200px) {
    .kanban-container .kanban-column {
        min-width: 340px !important;
        width: 340px !important;
    }
}

@media (max-width: 768px) {
    .kanban-container .kanban-column {
        min-width: 300px !important;
        width: 300px !important;
    }
}

/* Force Tasks list page to scroll (override generic content-body overflow hidden rules) */
.content-body > .task-management-container,
.content-body > .task-management-container.page-animate-in {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* Force Task Reports page to scroll (override generic content-body overflow hidden rules) */
.content-body > .reports-container,
.content-body > .reports-container.page-animate-in {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* ======================================================
   GRID CELL CONTENT CONSTRAINTS
   Applied globally via .udt-table-wrapper so template
   content from any page is constrained (scoped CSS
   can't reach cross-component RenderFragment content).
   ====================================================== */

/* Bootstrap badge + any class containing "badge" */
.udt-table-wrapper tbody td .badge,
.udt-table-wrapper tbody td [class*="badge"] {
    padding: 0.1rem 0.45rem !important;
    font-size: 0.7rem !important;
    line-height: 1.4 !important;
    border-radius: 3px !important;
    display: inline-block !important;
}

/* Payment / status pill classes */
.udt-table-wrapper tbody td [class*="payment-pill"],
.udt-table-wrapper tbody td [class*="status-pill"],
.udt-table-wrapper tbody td [class*="pill"] {
    padding: 0.08rem 0.5rem !important;
    font-size: 0.7rem !important;
    line-height: 1.4 !important;
    border-radius: 3px !important;
}

/* Icon-only action buttons (cust-icon-btn, etc.) */
.udt-table-wrapper tbody td [class*="icon-btn"] {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    max-width: 24px !important;
    max-height: 24px !important;
    border-radius: 3px !important;
    font-size: 0.72rem !important;
    padding: 0 !important;
    transform: none !important;
}

/* Regular buttons inside cells */
.udt-table-wrapper tbody td .btn {
    height: 26px !important;
    min-height: 26px !important;
    max-height: 26px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    font-size: 0.75rem !important;
    line-height: 1 !important;
    border-radius: 3px !important;
    transform: none !important;
}

/* Avatar circles / placeholders — the #1 cause of tall rows */
.udt-table-wrapper tbody td [class*="avatar"],
.udt-table-wrapper tbody td .rounded-circle:not(input):not(label) {
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    min-height: 22px !important;
    max-width: 22px !important;
    max-height: 22px !important;
    font-size: 9px !important;
    flex-shrink: 0 !important;
    line-height: 22px !important;
}

/* Margin between avatar and name text */
.udt-table-wrapper tbody td [class*="avatar"] {
    margin-inline-end: 0.4rem !important;
}

/* ======================================================
   GLOBAL ERP GRID TABLE STYLE
   Apply class="erp-grid" to any <table> outside of
   UnifiedDataTable to get the same desktop-grid look.
   ====================================================== */
.erp-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    border: 1px solid color-mix(in srgb, var(--primary-color) 26%, white);
}

.erp-grid thead th {
    padding: 0.12rem 0.45rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-dark);
    background: color-mix(in srgb, var(--primary-color) 20%, white);
    border: 1px solid color-mix(in srgb, var(--primary-color) 34%, white);
    text-align: start;
    white-space: nowrap;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 2;
    line-height: 1.4;
}

.erp-grid tbody td {
    padding: 0.08rem 0.45rem;
    font-size: 0.78rem;
    color: var(--primary-dark);
    border: 1px solid color-mix(in srgb, var(--primary-color) 16%, white);
    vertical-align: middle;
    text-align: start;
    line-height: 1.5;
    height: 22px;
}

.erp-grid tbody tr:nth-child(odd) td {
    background-color: #ffffff;
}

.erp-grid tbody tr:nth-child(even) td {
    background-color: color-mix(in srgb, var(--primary-color) 5%, white);
}

.erp-grid tbody tr:hover td {
    background-color: color-mix(in srgb, var(--primary-color) 12%, white) !important;
}

/* Compact buttons and badges inside .erp-grid cells */
.erp-grid tbody td .btn,
.erp-grid tbody td button:not(.dropdown-item) {
    height: 22px !important;
    min-height: 22px !important;
    max-height: 22px !important;
    padding: 0 0.4rem !important;
    font-size: 0.72rem !important;
    line-height: 1 !important;
    border-radius: 3px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.erp-grid tbody td .badge,
.erp-grid tbody td [class*="badge"],
.erp-grid tbody td [class*="status"],
.erp-grid tbody td span.rounded-pill,
.erp-grid tbody td span.rounded {
    padding: 0.05rem 0.45rem !important;
    font-size: 0.68rem !important;
    line-height: 1.4 !important;
    border-radius: 3px !important;
}

.erp-grid tbody tr.erp-grid-selected td {
    background-color: color-mix(in srgb, var(--primary-color) 28%, white) !important;
    color: var(--primary-dark) !important;
}

.erp-grid tfoot td,
.erp-grid tfoot th {
    padding: 0.35rem 0.6rem;
    font-weight: 600;
    background: color-mix(in srgb, var(--primary-color) 10%, white);
    border: 1px solid color-mix(in srgb, var(--primary-color) 26%, white);
    color: var(--primary-dark);
}

html[dir="rtl"] .erp-grid thead th,
html[dir="rtl"] .erp-grid tbody td,
html[dir="rtl"] .erp-grid tfoot td,
html[dir="rtl"] .erp-grid tfoot th {
    text-align: end;
}

/* ── UnifiedDataTable bulk-action bar buttons (global — needed because
       BulkActionsFragment content is rendered by the parent component and
       therefore does NOT receive the UnifiedDataTable scoped CSS attribute) ── */
.udt-bulk-bar .udt-bulk-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    height: 28px;
    padding: 0 0.85rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #fff;
    background: rgba(255, 255, 255, 0.13);
    border: 1px solid rgba(255, 255, 255, 0.38);
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
    letter-spacing: 0.01em;
}

.udt-bulk-bar .udt-bulk-btn:hover {
    background: rgba(255, 255, 255, 0.24);
    border-color: rgba(255, 255, 255, 0.65);
}

.udt-bulk-bar .udt-bulk-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.udt-bulk-bar .udt-bulk-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.udt-bulk-bar .udt-bulk-btn--danger {
    background: rgba(220, 53, 69, 0.22);
    border-color: rgba(255, 120, 130, 0.55);
    color: #ffd6d9;
}

.udt-bulk-bar .udt-bulk-btn--danger:hover {
    background: rgba(220, 53, 69, 0.38);
    border-color: rgba(255, 120, 130, 0.85);
    color: #fff;
}

.udt-bulk-bar .udt-bulk-btn i {
    font-size: 0.8rem;
    opacity: 0.9;
}
