/*
 * Condensed contract-editor styling (helder-maritiem).
 *
 * Overrides Filament 5's default RichEditor table styling on the *editing*
 * surface (.fi-fo-rich-editor .tiptap). Filament sets `border border-gray-300`
 * and `!p-2` (0.5rem !important) on every cell; here we lighten the borders so
 * the grid recedes and tighten padding so the table reads compactly — matching
 * the condensed PDF output (resources/views/pdf/contract.blade.php).
 *
 * Registered via FilamentAsset::register([Css::make('contract-editor', …)]) in
 * AdminPanelProvider. This is a static asset (NOT Tailwind-compiled), so it
 * uses plain CSS — no @apply. Re-run `php artisan filament:assets` and commit
 * the published public/css artifact after editing (stale-artifact rule).
 */

/* Whole-table whitespace — margin on the table (not rows) so only the outer
   edges gain space. Mirrors the PDF rule in pdf/contract.blade.php. */
.fi-fo-rich-editor .tiptap table {
    margin: 1em 0;
}

.fi-fo-rich-editor .tiptap table td,
.fi-fo-rich-editor .tiptap table th {
    /* Beat Filament's `!p-2` (0.5rem !important) to condense rows. */
    padding: 2px 6px !important;
    /* Fainter than the default gray-300 so the grid lines stay subtle. */
    border-color: #eceef1;
    line-height: 1.3;
}

.fi-fo-rich-editor .tiptap table th {
    /* Softer header fill than the default gray-100. */
    background-color: #f7f8f9;
}

.dark .fi-fo-rich-editor .tiptap table td,
.dark .fi-fo-rich-editor .tiptap table th {
    border-color: rgba(255, 255, 255, 0.08);
}

.dark .fi-fo-rich-editor .tiptap table th {
    background-color: rgba(255, 255, 255, 0.04);
}

/* Nudge the editor body font down for parity with the smaller (~10pt) PDF. */
.fi-fo-rich-editor .tiptap {
    font-size: 0.9rem;
}

/* First column lines up with body text — beat Filament's `!p-2` left padding.
   Mirrors the PDF rule in resources/views/pdf/contract.blade.php so the editor
   preview matches the rendered contract. */
.fi-fo-rich-editor .tiptap table tr > :first-child {
    padding-left: 0 !important;
}

/* 2-column tables (max 2 cols) get the same fixed 35% title column as the PDF.
   Only for tables never resized by hand — once a column border is dragged the
   cells carry data-colwidth and TipTap's own colgroup widths take over (the
   PDF mirrors this via TableColumnWidths). */
.fi-fo-rich-editor .tiptap table:has(td:nth-child(2)):not(:has(td:nth-child(3))):not(:has([data-colwidth])),
.fi-fo-rich-editor .tiptap table:has(th:nth-child(2)):not(:has(th:nth-child(3))):not(:has([data-colwidth])) {
    table-layout: fixed;
}
.fi-fo-rich-editor .tiptap table:has(td:nth-child(2)):not(:has(td:nth-child(3))):not(:has([data-colwidth])) tr > :first-child,
.fi-fo-rich-editor .tiptap table:has(th:nth-child(2)):not(:has(th:nth-child(3))):not(:has([data-colwidth])) tr > :first-child {
    width: 35%;
}
