/* =============================================================================
   Goal Editor — Custom CSS
   Registered via AdminPanelProvider::assets().

   Filament's pre-compiled Tailwind only includes utilities used by Filament's
   own components, so custom component styles must live in plain CSS.

   Filament's table repeater handles: field rendering, validation rings,
   delete confirmation modal, drag handle icon. This file covers the custom
   table layout, compact overrides, number styling, and footer.
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Wrapper — no extra layout needed, Filament's field wrapper handles it
   ----------------------------------------------------------------------------- */
.ge-wrapper {
    width: 100%;
}

/* -----------------------------------------------------------------------------
   Toolbar — expand/collapse all
   ----------------------------------------------------------------------------- */
.ge-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
}

.ge-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.25rem;
    border: 1px solid rgb(229, 231, 235);
    border-radius: 0.375rem;
    background: white;
    color: rgb(55, 65, 81);
    cursor: pointer;
}
.ge-toolbar-btn:hover {
    background: rgb(249, 250, 251);
    border-color: rgb(209, 213, 219);
    color: rgb(17, 24, 39);
}
.ge-toolbar-btn:disabled {
    opacity: 0.4;
    cursor: default;
}
.ge-toolbar-btn:disabled:hover {
    background: white;
    border-color: rgb(229, 231, 235);
    color: rgb(55, 65, 81);
}
.dark .ge-toolbar-btn {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgb(209, 213, 219);
}
.dark .ge-toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}
.dark .ge-toolbar-btn:disabled {
    opacity: 0.4;
}
.dark .ge-toolbar-btn:disabled:hover {
    background: rgba(255, 255, 255, 0.05);
    color: rgb(209, 213, 219);
}

.ge-toolbar-icon {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

/* -----------------------------------------------------------------------------
   Table container — matches Filament table card
   ----------------------------------------------------------------------------- */
.ge-table-container {
    border-radius: 0.75rem;
    background: white;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    outline: 1px solid rgba(3, 7, 18, 0.05);
    outline-offset: -1px;
    overflow: hidden;
}
.dark .ge-table-container {
    background: transparent;
    outline-color: rgba(255, 255, 255, 0.1);
}

.ge-table-scroll {
    overflow-x: auto;
}

/* -----------------------------------------------------------------------------
   Table — fixed layout sized to fit container
   ----------------------------------------------------------------------------- */
.ge-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.875rem;
}

/* -----------------------------------------------------------------------------
   Header cells
   ----------------------------------------------------------------------------- */
.ge-th {
    padding: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: rgb(3, 7, 18);
    background: rgb(249, 250, 251);
    border-bottom: 1px solid rgb(229, 231, 235);
    border-right: 1px solid rgb(229, 231, 235);
    text-align: start;
}
.ge-th:first-child {
    border-top-left-radius: 0.75rem;
}
.ge-th:last-child {
    border-top-right-radius: 0.75rem;
    border-right: none;
}
.ge-th.fi-align-end {
    text-align: end;
}
.dark .ge-th {
    color: white;
    background: rgba(255, 255, 255, 0.05);
    border-bottom-color: rgba(255, 255, 255, 0.1);
    border-right-color: rgba(255, 255, 255, 0.1);
}

.ge-required {
    color: rgb(220, 38, 38);
    font-weight: 500;
    margin-left: 1px;
}
.dark .ge-required {
    color: rgb(248, 113, 113);
}

/* -----------------------------------------------------------------------------
   Column widths
   ----------------------------------------------------------------------------- */
.ge-col-drag { width: 32px; }
.ge-col-chevron { width: 28px; }
.ge-col-action { width: 32px; }

/* Center the drag handle and action buttons within their narrow cells */
.ge-col-drag .fi-fo-table-repeater-actions,
.ge-col-action .fi-fo-table-repeater-actions {
    justify-content: center;
}
.ge-col-drag .fi-icon-btn {
    cursor: grab;
}
.ge-col-drag .fi-icon-btn:active {
    cursor: grabbing;
}

/* -----------------------------------------------------------------------------
   Body rows
   ----------------------------------------------------------------------------- */
.ge-row {
    border-bottom: 1px solid rgb(229, 231, 235);
}
/* Note: no .ge-row:last-child border removal — per-section <tbody> handles separation */
.dark .ge-row {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}
.ge-row--zero {
    opacity: 0.4;
}

.ge-cell {
    padding: 0.125rem 0.1875rem;
    vertical-align: middle;
    border-right: 1px solid rgb(229, 231, 235);
}
.ge-cell:last-child {
    border-right: none;
}
.dark .ge-cell {
    border-right-color: rgba(255, 255, 255, 0.1);
}

/* -----------------------------------------------------------------------------
   Compact Filament input overrides — scoped to .ge-cell for dense table
   ----------------------------------------------------------------------------- */
.ge-cell .fi-input-wrp {
    box-shadow: none;
    min-width: 0;
}
.ge-cell .fi-input {
    padding: 0.1875rem 0.25rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ge-cell .fi-select-input {
    padding-block: 0.1875rem;
    padding-inline-start: 0.25rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    min-width: 0;
}
.ge-cell .fi-input-wrp-label {
    font-size: 0.875rem;
}
.ge-cell .fi-input-wrp-prefix,
.ge-cell .fi-input-wrp-suffix {
    padding-inline-start: 0.25rem;
    padding-inline-end: 0;
}

/* -----------------------------------------------------------------------------
   Focus ring — outline-based so box-shadow:none doesn't clobber
   ----------------------------------------------------------------------------- */
.ge-cell .fi-input-wrp:focus-within {
    outline: 2px solid rgb(249, 115, 22);
    outline-offset: -1px;
}

/* -----------------------------------------------------------------------------
   Number inputs — right-alignment + spinner removal
   ----------------------------------------------------------------------------- */
.ge-cell input[type="number"] {
    text-align: end;
}
.ge-cell input[type="number"]::-webkit-inner-spin-button,
.ge-cell input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.ge-cell input[type="number"] {
    -moz-appearance: textfield;
}

/* -----------------------------------------------------------------------------
   Section headers — goal type group dividers
   ----------------------------------------------------------------------------- */
.ge-section-header-row {
    border: none;
}
.ge-section-header-cell {
    padding: 0.625rem 0.5rem 0.25rem;
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    border-bottom: 1px solid rgb(229, 231, 235);
    background: transparent;
}
.dark .ge-section-header-cell {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

/* Section colors — darkened for WCAG AA 4.5:1 contrast on white */
.ge-section--linear     { color: rgb(146, 100, 2); }
.ge-section--turbo      { color: rgb(180, 83, 16); }
.ge-section--non_linear { color: rgb(21, 128, 61); }
.dark .ge-section--linear     { color: rgb(250, 204, 21); }
.dark .ge-section--turbo      { color: rgb(251, 146, 60); }
.dark .ge-section--non_linear { color: rgb(74, 222, 128); }

/* Turbo row background tint */
.ge-row--turbo       { background: rgba(249, 115, 22, 0.04); }
.dark .ge-row--turbo { background: rgba(249, 115, 22, 0.08); }

/* -----------------------------------------------------------------------------
   Section subtotals — per-type payout + expected cost
   ----------------------------------------------------------------------------- */
.ge-section-subtotal-row {
    border: none;
}
.ge-section-subtotal-cell {
    padding: 0.375rem 0.5rem;
    font-size: 0.8125rem;
    color: rgb(107, 114, 128);
    border-bottom: 1px solid rgb(229, 231, 235);
    background: rgb(249, 250, 251);
}
.dark .ge-section-subtotal-cell {
    color: rgb(156, 163, 175);
    background: rgba(255, 255, 255, 0.02);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}
.ge-section-subtotal-label {
    font-weight: 600;
}
.ge-section-subtotal-value {
    text-align: end;
    font-weight: 600;
    color: rgb(3, 7, 18);
}
.dark .ge-section-subtotal-value {
    color: white;
}

.ge-section-subtotal-pct {
    margin-left: 0.25rem;
    font-weight: 400;
    opacity: 0.65;
}

/* -----------------------------------------------------------------------------
   Per-section add goal button
   ----------------------------------------------------------------------------- */
.ge-section-add-row {
    border: none;
}
.ge-section-add-cell {
    padding: 0.375rem 0.5rem;
    text-align: center;
    border-bottom: 2px solid rgb(229, 231, 235);
}
.dark .ge-section-add-cell {
    border-bottom-color: rgba(255, 255, 255, 0.15);
}
.ge-section-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.25rem;
    border: 1px solid rgb(229, 231, 235);
    border-radius: 0.375rem;
    background: white;
    color: rgb(55, 65, 81);
    cursor: pointer;
}
.ge-section-add-btn:hover {
    background: rgb(249, 250, 251);
    border-color: rgb(209, 213, 219);
    color: rgb(17, 24, 39);
}
.dark .ge-section-add-btn {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgb(209, 213, 219);
}
.dark .ge-section-add-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

/* -----------------------------------------------------------------------------
   Footer totals — flex row below the table and Add Goal button
   ----------------------------------------------------------------------------- */
.ge-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem;
    padding: 0.75rem 0.5rem 0;
    margin-top: 0.75rem;
    border-top: 1px solid rgb(229, 231, 235);
    font-size: 0.875rem;
    color: rgb(107, 114, 128);
}
.dark .ge-footer {
    border-top-color: rgba(255, 255, 255, 0.1);
    color: rgb(156, 163, 175);
}
.ge-footer-value {
    font-weight: 600;
    color: rgb(3, 7, 18);
}
.dark .ge-footer-value {
    color: white;
}

/* -----------------------------------------------------------------------------
   Chevron toggle button
   ----------------------------------------------------------------------------- */
.ge-col-chevron .fi-fo-table-repeater-actions,
.ge-col-chevron {
    text-align: center;
}

.ge-chevron-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    color: rgb(107, 114, 128);
    border-radius: 0.25rem;
}
.ge-chevron-btn:hover {
    color: rgb(249, 115, 22);
    background: rgba(249, 115, 22, 0.08);
}
.dark .ge-chevron-btn {
    color: rgb(156, 163, 175);
}
.dark .ge-chevron-btn:hover {
    color: rgb(251, 146, 60);
    background: rgba(251, 146, 60, 0.1);
}

.ge-chevron-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}
.ge-chevron-open {
    transform: rotate(90deg);
}

/* -----------------------------------------------------------------------------
   Detail row — expandable event binding panel
   ----------------------------------------------------------------------------- */
.ge-detail-row {
    border-bottom: 1px solid rgb(229, 231, 235);
}
.dark .ge-detail-row {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.ge-detail-cell {
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    background: rgb(249, 250, 251);
    border-left: 3px solid rgb(249, 115, 22);
}
.dark .ge-detail-cell {
    background: rgba(255, 255, 255, 0.03);
    border-left-color: rgb(249, 115, 22);
}

/* -----------------------------------------------------------------------------
   Detail panel header (title + subtitle + optional action inside expanded row)
   ----------------------------------------------------------------------------- */
.ge-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.ge-detail-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: rgb(17, 24, 39);
    margin: 0 0 0.125rem;
    line-height: 1.25;
}
.ge-detail-title--turbo {
    color: rgb(249, 115, 22);
}
.dark .ge-detail-title {
    color: white;
}
.dark .ge-detail-title--turbo {
    color: rgb(251, 146, 60);
}

.ge-detail-subtitle {
    font-size: 0.75rem;
    color: rgb(107, 114, 128);
    margin: 0;
    line-height: 1.4;
}
.dark .ge-detail-subtitle {
    color: rgb(156, 163, 175);
}

/* -----------------------------------------------------------------------------
   Inline event picker — search-to-reveal pattern
   ----------------------------------------------------------------------------- */
.ge-event-picker {
    display: flex;
    flex-direction: column;
    max-width: 24rem;
}

.ge-event-counter {
    font-size: 0.75rem;
    font-weight: 500;
    color: rgb(107, 114, 128);
    white-space: nowrap;
}
.dark .ge-event-counter {
    color: rgb(156, 163, 175);
}

/* Selected event rows */
.ge-event-selected {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.625rem;
    margin-bottom: 0.375rem;
    background: rgb(239, 246, 255);
    border: 1px solid rgb(191, 219, 254);
    border-radius: 0.375rem;
}
.dark .ge-event-selected {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
}

.ge-event-selected-name {
    flex: 1;
    min-width: 0;
    font-size: 0.875rem;
    color: rgb(17, 24, 39);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dark .ge-event-selected-name {
    color: rgb(229, 231, 235);
}

/* Search bar wrapper (positions the dropdown) */
.ge-event-search-wrap {
    position: relative;
    margin-top: 0.375rem;
}

.ge-event-search {
    width: 100%;
    padding: 0.375rem 0.625rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    border: 1px solid rgb(209, 213, 219);
    border-radius: 0.375rem;
    background: white;
    color: rgb(17, 24, 39);
    outline: none;
}
.ge-event-search:focus {
    border-color: rgb(249, 115, 22);
    box-shadow: 0 0 0 1px rgb(249, 115, 22);
}
.ge-event-search::placeholder {
    color: rgb(156, 163, 175);
}
.dark .ge-event-search {
    background: rgb(31, 41, 55);
    border-color: rgba(255, 255, 255, 0.15);
    color: white;
}
.dark .ge-event-search:focus {
    border-color: rgb(249, 115, 22);
    box-shadow: 0 0 0 1px rgb(249, 115, 22);
}
.dark .ge-event-search::placeholder {
    color: rgb(107, 114, 128);
}

/* Results dropdown */
.ge-event-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    max-height: 12rem;
    overflow-y: auto;
    border: 1px solid rgb(209, 213, 219);
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    background: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.dark .ge-event-results {
    background: rgb(31, 41, 55);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.ge-event-result-item {
    display: block;
    width: 100%;
    padding: 0.375rem 0.625rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    text-align: start;
    color: rgb(17, 24, 39);
    background: transparent;
    border: none;
    border-bottom: 1px solid rgb(243, 244, 246);
    cursor: pointer;
}
.ge-event-result-item:last-child {
    border-bottom: none;
}
.ge-event-result-item:hover {
    background: rgb(249, 250, 251);
    color: rgb(249, 115, 22);
}
.dark .ge-event-result-item {
    color: rgb(229, 231, 235);
    border-bottom-color: rgba(255, 255, 255, 0.05);
}
.dark .ge-event-result-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: rgb(251, 146, 60);
}

/* Disable clicks while Livewire is processing to prevent double-adds */
.ge-event-results--loading {
    pointer-events: none;
    opacity: 0.6;
}

.ge-event-results-empty {
    padding: 0.5rem 0.625rem;
    font-size: 0.8125rem;
    color: rgb(156, 163, 175);
    font-style: italic;
}
.dark .ge-event-results-empty {
    color: rgb(107, 114, 128);
}

.ge-event-qty {
    width: 64px;
    flex-shrink: 0;
    padding: 0.25rem 0.375rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    border: 1px solid rgb(209, 213, 219);
    border-radius: 0.375rem;
    background: white;
    color: rgb(17, 24, 39);
    text-align: end;
    outline: none;
}
.ge-event-qty:focus {
    border-color: rgb(249, 115, 22);
    box-shadow: 0 0 0 1px rgb(249, 115, 22);
}
.ge-event-qty::-webkit-inner-spin-button,
.ge-event-qty::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.ge-event-qty {
    -moz-appearance: textfield;
}
.dark .ge-event-qty {
    background: rgb(31, 41, 55);
    border-color: rgba(255, 255, 255, 0.15);
    color: white;
}
.dark .ge-event-qty:focus {
    border-color: rgb(249, 115, 22);
    box-shadow: 0 0 0 1px rgb(249, 115, 22);
}

.ge-event-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    color: rgb(107, 114, 128);
    border-radius: 0.25rem;
}
.ge-event-remove:hover {
    color: rgb(220, 38, 38);
    background: rgba(220, 38, 38, 0.08);
}
.dark .ge-event-remove {
    color: rgb(156, 163, 175);
}
.dark .ge-event-remove:hover {
    color: rgb(248, 113, 113);
    background: rgba(248, 113, 113, 0.1);
}


/* -----------------------------------------------------------------------------
   No-events message (create mode or no app events configured)
   ----------------------------------------------------------------------------- */
.ge-no-events-msg {
    font-size: 0.875rem;
    color: rgb(107, 114, 128);
    font-style: italic;
}
.dark .ge-no-events-msg {
    color: rgb(156, 163, 175);
}
