/* shared-ui — Filter chips, filter dialogs, DataTables overrides, expandable rows.
   Requires Bootstrap 5.3. Override the :root variables below for theming. */

/* ============================================
   Theme variables — override per project:

   <style>
     :root {
       --sui-primary: #1e293b;
       --sui-accent:  #2563eb;
     }
   </style>
   ============================================ */
:root {
    --sui-primary:          #1e293b;
    --sui-accent:           #2563eb;
    --sui-danger:           #dc2626;
    --sui-bg:               #ffffff;
    --sui-bg-alt:           #f1f5f9;

    /* Auto-derived — override only if color-mix gives wrong results */
    --sui-accent-light:     color-mix(in srgb, var(--sui-accent) 55%, white);
    --sui-accent-lighter:   color-mix(in srgb, var(--sui-accent) 10%, white);
    --sui-primary-dark:     color-mix(in srgb, var(--sui-primary) 85%, black);
}

/* ============================================
   Filter bar
   ============================================ */
.filters-bar-container {
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.filters-bar {
    background: var(--sui-bg-alt);
    border-bottom: 1px solid #dee2e6;
    padding: 8px 16px;
    min-height: 48px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.filters-bar-empty {
    color: #94a3b8;
    font-size: 13px;
    flex: 1;
}

.bar-label {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 600;
    margin-right: 2px;
}

/* ============================================
   Filter chips
   ============================================ */
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--sui-accent-lighter);
    border: 1px solid var(--sui-accent-light);
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 12px;
    color: var(--sui-accent);
    transition: background 0.15s ease;
}

.filter-chip:hover { background: var(--sui-bg-alt); }

.filter-chip-label { font-weight: 600; }

.filter-chip-value {
    font-weight: 400;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-chip-remove {
    cursor: pointer;
    font-weight: bold;
    color: var(--sui-accent);
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.15s ease;
}

.filter-chip-remove:hover {
    background: var(--sui-accent);
    color: white;
}

/* ============================================
   Filter popover (inside Bootstrap modal)
   ============================================ */
.filter-popover {
    min-width: 280px;
}

.filter-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--sui-primary);
    margin-bottom: 12px;
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 10px;
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.filter-option {
    border-radius: 4px;
    transition: background 0.15s;
    cursor: pointer;
    font-size: 14px;
}

.filter-option:hover { background: var(--sui-bg-alt); }

/* ============================================
   DataTables overrides (Bootstrap DataTables
   already handles most — this fills gaps)
   ============================================ */
.dataTables_wrapper .dataTables_info {
    font-size: 12px;
    color: #64748b;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--sui-accent) !important;
    color: white !important;
    border-color: var(--sui-accent) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.current) {
    background: var(--sui-bg-alt) !important;
    border-color: var(--sui-accent) !important;
}

.table thead th {
    font-weight: 600;
    font-size: 11px;
    color: var(--sui-primary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ============================================
   Expandable table rows
   ============================================ */
.parent-row { cursor: pointer; }
.parent-row:hover { background: var(--sui-bg-alt) !important; }

.parent-row td.expand-control {
    text-align: center;
    color: var(--sui-accent);
    font-size: 14px;
}

.expand-icon {
    transition: transform 0.2s ease;
    display: inline-block;
}

.expand-icon.expanded { transform: rotate(90deg); }

.child-table {
    width: 100%;
    margin: 8px 0;
    background: var(--sui-bg-alt);
    border-collapse: collapse;
}

.child-table thead tr { background: #e2e8f0; }
.child-table th { padding: 8px; text-align: left; font-size: 11px; font-weight: 600; color: #555; }
.child-table td { padding: 8px; font-size: 12px; border-bottom: 1px solid #eee; }

.child-doc-row { cursor: pointer; }
.child-doc-row:hover { background: var(--sui-bg-alt); }

/* ============================================
   Text highlighting
   ============================================ */
.highlight          { background: #fef08a; }
.highlight-must     { background: #fef08a; }
.highlight-should-0 { background: #86efac; }
.highlight-should-1 { background: #93c5fd; }
.highlight-should-2 { background: #d8b4fe; }

/* ============================================
   Toast (simpler than Bootstrap's toast)
   ============================================ */
.sui-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    color: white;
    padding: 10px 18px;
    border-radius: 8px;
    box-shadow: 0 20px 25px rgba(0,0,0,0.15);
    font-size: 13px;
    font-weight: 500;
    z-index: 10001;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    max-width: 400px;
}

.sui-toast.show         { opacity: 1; transform: translateY(0); }
.sui-toast-success      { background: #16a34a; }
.sui-toast-error        { background: var(--sui-danger); }
