/*
 * The look of the CRM on top of Filament's stylesheet: plain CSS, no build step.
 * Filament keeps its rules in cascade layers, so these unlayered rules win without !important.
 * Colors come from the panel palette (--gray-*, --primary-*, set by AppPanelProvider).
 * Published to public/css/app/ by `php artisan filament:assets`.
 */

/* Surfaces: one hairline border instead of ring plus shadow. */
.fi-section:not(.fi-section-not-contained):not(.fi-aside),
.fi-ta-ctn,
.fi-wi-stats-overview-stat,
.fi-tabs:not(.fi-contained) {
    border: 1px solid var(--gray-200);
    box-shadow: none;
}

.dark .fi-section:not(.fi-section-not-contained):not(.fi-aside),
.dark .fi-ta-ctn,
.dark .fi-wi-stats-overview-stat,
.dark .fi-tabs:not(.fi-contained) {
    border-color: rgb(255 255 255 / 0.1);
}

.fi-topbar {
    border-bottom: 1px solid var(--gray-200);
    box-shadow: none;
}

.dark .fi-topbar {
    border-bottom-color: rgb(255 255 255 / 0.1);
}

/* Page header: a smaller title and less air above the content. */
.fi-header-heading {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 2rem;
}

.fi-page-header-main-ctn {
    gap: 1.5rem;
    padding-block: 1.5rem;
}

.fi-page-content {
    row-gap: 1.5rem;
}

/* Side menu: closer rows, a thin scrollbar, and the current page stands out. */
.fi-sidebar-nav {
    gap: 1.25rem;
    padding-block: 1.25rem;
    scrollbar-color: var(--gray-300) transparent;
    scrollbar-width: thin;
}

.dark .fi-sidebar-nav {
    scrollbar-color: var(--gray-700) transparent;
}

.fi-sidebar-nav-groups {
    gap: 1.25rem;
}

.fi-sidebar-group,
.fi-sidebar-group-items {
    gap: 0.125rem;
}

.fi-sidebar-group-btn {
    padding-block: 0.25rem;
}

.fi-sidebar-group-label {
    font-size: 0.75rem;
    letter-spacing: 0.02em;
}

.fi-sidebar-item-btn {
    padding-block: 0.375rem;
}

.fi-sidebar-item.fi-active > .fi-sidebar-item-btn {
    background-color: var(--primary-50);
}

.dark .fi-sidebar-item.fi-active > .fi-sidebar-item-btn {
    background-color: rgb(255 255 255 / 0.08);
}

/* Tables: quiet column titles, the rows carry the weight. */
.fi-ta-header-cell {
    color: var(--gray-500);
    font-size: 0.75rem;
    font-weight: 500;
    padding-block: 0.625rem;
}

.dark .fi-ta-header-cell {
    color: var(--gray-400);
}

/* Tabs wrap on a second line instead of scrolling sideways: every tab stays in sight. */
.fi-tabs:not(.fi-vertical) {
    flex-wrap: wrap;
    overflow-x: visible;
    row-gap: 0.25rem;
}

/* Numbers at a glance: compact tiles; a tile marked crm-stat-empty (nothing to report) steps back. */
.fi-wi-stats-overview-stat {
    padding: 0.875rem 1rem;
}

.fi-wi-stats-overview-stat .fi-wi-stats-overview-stat-content {
    row-gap: 0.25rem;
}

.fi-wi-stats-overview-stat .fi-wi-stats-overview-stat-label {
    font-size: 0.8125rem;
}

.fi-wi-stats-overview-stat .fi-wi-stats-overview-stat-value {
    font-size: 1.5rem;
    line-height: 2rem;
}

.fi-wi-stats-overview-stat.crm-stat-empty .fi-wi-stats-overview-stat-value {
    color: var(--gray-400);
    font-weight: 500;
}

.dark .fi-wi-stats-overview-stat.crm-stat-empty .fi-wi-stats-overview-stat-value {
    color: var(--gray-500);
}

/* A tile that asks for attention shows its number in the color of its urgency. */
.fi-wi-stats-overview-stat.crm-stat-danger .fi-wi-stats-overview-stat-value {
    color: var(--danger-600);
}

.fi-wi-stats-overview-stat.crm-stat-warning .fi-wi-stats-overview-stat-value {
    color: var(--warning-600);
}

.dark .fi-wi-stats-overview-stat.crm-stat-danger .fi-wi-stats-overview-stat-value {
    color: var(--danger-400);
}

.dark .fi-wi-stats-overview-stat.crm-stat-warning .fi-wi-stats-overview-stat-value {
    color: var(--warning-400);
}

/* A tile that is a link says so when the pointer is on it. */
a.fi-wi-stats-overview-stat:hover {
    border-color: var(--primary-400);
}

/* The side menu is a surface of its own, so the page reads as menu plus content. */
.fi-sidebar {
    background-color: #fff;
    border-inline-end: 1px solid var(--gray-200);
}

.dark .fi-sidebar {
    background-color: var(--gray-900);
    border-inline-end-color: rgb(255 255 255 / 0.1);
}

/* The current page carries an accent bar as well as the tint. */
.fi-sidebar-item.fi-active > .fi-sidebar-item-btn {
    box-shadow: inset 3px 0 0 var(--primary-600);
}

.dark .fi-sidebar-item.fi-active > .fi-sidebar-item-btn {
    box-shadow: inset 3px 0 0 var(--primary-400);
}

/* Dark mode: a softer page behind slightly lighter cards, instead of black on black. */
.dark .fi-body {
    background-color: var(--gray-900);
}

.dark .fi-sidebar,
.dark .fi-topbar,
.dark .fi-section:not(.fi-section-not-contained):not(.fi-aside),
.dark .fi-ta-ctn,
.dark .fi-wi-stats-overview-stat,
.dark .fi-tabs:not(.fi-contained) {
    background-color: color-mix(in oklab, var(--gray-800) 55%, var(--gray-900));
}

/* An empty list says so in one quiet line: no tall block with a big icon. */
.fi-ta-empty-state {
    padding-block: 1.5rem;
}

.fi-ta-empty-state .fi-ta-empty-state-icon-bg {
    display: none;
}

.fi-ta-empty-state .fi-ta-empty-state-heading {
    color: var(--gray-500);
    font-size: 0.875rem;
    font-weight: 400;
}

.dark .fi-ta-empty-state .fi-ta-empty-state-heading {
    color: var(--gray-400);
}

/*
 * Pages opened from the side menu do not repeat their name as a title: the menu entry is highlighted.
 * The title stays in the page for screen readers. Record pages keep theirs: it is the name of the record.
 */
.fi-resource-list-records-page .fi-header-heading,
.crm-page-in-menu .fi-header-heading {
    border: 0;
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

/* Without buttons the header is empty: it leaves no gap above the content. */
.fi-resource-list-records-page .fi-header:not(:has(.fi-header-actions-ctn)),
.crm-page-in-menu .fi-header:not(:has(.fi-header-actions-ctn)) {
    position: absolute;
}

/*
 * Lists: search on the left of the table bar, then filters and the buttons of the list on the right
 * (App\Filament\Concerns\ButtonsInTableBar puts them in the bar).
 */
.fi-resource-list-records-page .fi-ta-header-toolbar > :nth-child(1) {
    margin-inline-start: 0;
    order: 2;
}

.fi-resource-list-records-page .fi-ta-header-toolbar > :nth-child(2) {
    flex: 1;
    margin-inline-start: 0;
}

.fi-resource-list-records-page .fi-ta-header-toolbar .fi-ta-search-field {
    margin-inline-end: auto;
}

/* The tabs of a list start where its table starts. */
.fi-resource-list-records-page .fi-tabs:not(.fi-contained) {
    margin-inline-start: 0;
}

/* The text of a request log row, as it was sent. */
.crm-preformatted {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8125rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* AI summaries and drafts on the pages of emails and organizations. */
.crm-ai-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.crm-ai-panel-header {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
}

.crm-ai-waiting {
    color: var(--gray-500);
    font-size: 0.875rem;
}

.crm-ai-error {
    color: var(--danger-600);
    font-size: 0.875rem;
}

.crm-ai-output {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.crm-ai-text {
    white-space: pre-wrap;
}

/* The AI chat: the list of conversations beside the messages. */
.crm-chat {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 16rem 1fr;
}

@media (max-width: 768px) {
    .crm-chat {
        grid-template-columns: 1fr;
    }
}

.crm-chat-sidebar,
.crm-chat-main,
.crm-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.crm-chat-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.crm-chat-item {
    align-items: center;
    border-radius: 0.5rem;
    display: flex;
    justify-content: space-between;
}

.crm-chat-item-active {
    background: var(--gray-100);
}

.crm-chat-open {
    flex: 1;
    overflow: hidden;
    padding: 0.5rem;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-chat-message {
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
}

.crm-chat-message-user {
    background: var(--gray-50);
}

.crm-chat-proposal {
    align-items: center;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding-top: 0.5rem;
}

.crm-chat-proposal-actions,
.crm-chat-form {
    display: flex;
    gap: 0.5rem;
}

.crm-chat-form > :first-child {
    flex: 1;
}

/* Reports: one card per report, name and one line; the whole card is the link. */
.crm-report-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
}

.crm-report-card {
    align-items: flex-start;
    background-color: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 0.75rem;
    display: flex;
    gap: 0.875rem;
    padding: 1rem 1.125rem;
    transition: border-color 0.15s;
}

.crm-report-card:hover {
    border-color: var(--primary-400);
}

.crm-report-card-icon {
    align-items: center;
    background-color: var(--primary-50);
    border-radius: 0.5rem;
    color: var(--primary-600);
    display: flex;
    flex-shrink: 0;
    height: 2.25rem;
    justify-content: center;
    width: 2.25rem;
}

.crm-report-card-icon svg {
    height: 1.25rem;
    width: 1.25rem;
}

.crm-report-card-text {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.crm-report-card-label {
    color: var(--gray-950);
    font-size: 0.9375rem;
    font-weight: 600;
}

.crm-report-card-summary {
    color: var(--gray-500);
    font-size: 0.8125rem;
    line-height: 1.25rem;
}

.dark .crm-report-card {
    background-color: color-mix(in oklab, var(--gray-800) 55%, var(--gray-900));
    border-color: rgb(255 255 255 / 0.1);
}

.dark .crm-report-card-icon {
    background-color: rgb(255 255 255 / 0.06);
    color: var(--primary-400);
}

.dark .crm-report-card-label {
    color: #fff;
}

.dark .crm-report-card-summary {
    color: var(--gray-400);
}

/* Indicators of an organization: compact tiles side by side within each section. */
.crm-indicator-sections {
    display: grid;
    gap: 1.5rem;
}

.crm-indicator-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
}

.crm-indicator {
    border: 1px solid var(--gray-200);
    border-radius: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.875rem 1rem;
}

.crm-indicator-label {
    color: var(--gray-500);
    font-size: 0.8125rem;
}

.crm-indicator-value {
    color: var(--gray-950);
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 2rem;
}

.crm-indicator.crm-stat-empty .crm-indicator-value {
    color: var(--gray-400);
    font-weight: 500;
}

.dark .crm-indicator {
    border-color: rgb(255 255 255 / 0.1);
}

.dark .crm-indicator-label {
    color: var(--gray-400);
}

.dark .crm-indicator-value {
    color: #fff;
}

.dark .crm-indicator.crm-stat-empty .crm-indicator-value {
    color: var(--gray-500);
}
