/*
 * Moretto ERP — Resources Specifics
 * Contiene ajustes específicos para recursos (Quotations, Products, etc.)
 */

.moretto-quotation-priority {
    border-color: rgb(243 108 33 / .42) !important;
    box-shadow: inset 4px 0 0 var(--moretto-orange), var(--moretto-shadow-card) !important;
}

.moretto-context-action {
    box-shadow: 0 10px 24px -16px rgb(24 24 24 / .55) !important;
}

.fi-resource-products .fi-sc-actions.fi-sticky .fi-ac {
    z-index: 25;
    border: 1px solid var(--moretto-line);
}

/*
 * Excepción responsive de tabs (wrapper/wrapping y distribución).
 * Convive con el owner canónico del chrome (moretto-admin-components.css):
 * mismo guard de POS y carga posterior, por lo que gana en el empate.
 */
@media (min-width: 641px) and (max-width: 1279px) {
    .fi-body:not([data-moretto-pos]) .fi-resource-quotations .fi-tabs {
        flex-wrap: wrap !important;
        overflow-x: visible !important;
    }

    .fi-body:not([data-moretto-pos]) .fi-resource-quotations .fi-tabs-item {
        flex: 1 1 auto;
    }
}

@media (max-width: 640px) {
    /* Las bandejas/listados usan un rail horizontal tipo app. El chrome visual
       vive en moretto-admin-components.css; aquí solo cerramos la composición
       responsive porque este archivo carga después del owner de tabs. */
    .fi-body:not([data-moretto-pos]) .fi-resource-list-records-page .fi-tabs {
        flex-wrap: nowrap !important;
        width: 100% !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
    }

    .fi-body:not([data-moretto-pos]) .fi-resource-list-records-page .fi-tabs-item {
        flex: 0 0 auto !important;
    }

    .fi-resource-view-record-page.fi-resource-quotations {
        padding-bottom: 4.75rem;
    }

    .fi-resource-view-record-page.fi-resource-quotations .moretto-context-action {
        position: fixed !important;
        z-index: 24;
        right: 1rem;
        bottom: max(1rem, env(safe-area-inset-bottom));
        left: 1rem;
        justify-content: center;
        width: auto;
        min-height: 3rem !important;
        border: 1px solid rgb(24 24 24 / .12);
        box-shadow: 0 18px 38px -18px rgb(24 24 24 / .65) !important;
    }

    .fi-resource-products .fi-sc-actions.fi-sticky .fi-ac {
        right: 0;
        bottom: 0;
        left: 0;
        margin: 0 !important;
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* ==========================================================================
   CANONICAL MORETTO VIEW / VER / SHOW SCREENS
   Referencia visual canónica: /admin/sales/61 (Sales Detail Canon)
   Aplica de manera unificada a todos los ViewRecord Resources en Moretto ERP
   ========================================================================== */

.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page {
    --mtt-view-detail-bg: var(--ui-surface, #fff);
    --mtt-view-detail-soft: var(--ui-bg-soft, #f8fafc);
    --mtt-view-detail-border: var(--ui-border, #d8dee8);
    --mtt-view-detail-border-soft: color-mix(in srgb, var(--ui-border, #d8dee8) 72%, transparent);
    --mtt-view-detail-text: var(--ui-text, #18191b);
    --mtt-view-detail-muted: var(--ui-text-muted, #667085);
    --mtt-view-detail-accent: var(--ui-accent, #f36c21);
    --mtt-view-detail-radius: 0.75rem;
}

/* --- View Header & Heading --- */
.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-header {
    display: flex !important;
    align-items: flex-end !important;
    justify-content: space-between !important;
    gap: 0.65rem 1rem !important;
    margin-bottom: 0.42rem !important;
    padding: 0.16rem 0 0.62rem !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-header > div:first-child {
    min-width: 0 !important;
    flex: 1 1 auto !important;
}

.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-header-heading {
    margin: 0 !important;
    padding: 0 !important;
    color: var(--mtt-view-detail-text) !important;
    font-size: 1.35rem !important;
    font-weight: 600 !important;
    line-height: 1.18 !important;
    letter-spacing: -0.022em !important;
}

.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-header-subheading {
    max-width: 48rem !important;
    margin-top: 0.16rem !important;
    color: var(--mtt-view-detail-muted) !important;
    font-size: 0.625rem !important;
    font-weight: 400 !important;
    line-height: 1.35 !important;
}

.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page :is(.fi-breadcrumbs-item, .fi-breadcrumbs-item-label, .fi-breadcrumbs-item-separator) {
    color: var(--mtt-view-detail-muted) !important;
    font-size: 0.625rem !important;
    font-weight: 500 !important;
}

/* --- View Header Actions --- */
.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-header-actions-ctn {
    width: auto !important;
    margin: 0 !important;
}

.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-header-actions-ctn .fi-ac {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 0.38rem !important;
    flex-wrap: wrap !important;
}

/* Secondary header actions (Edit, Print, Back, Export) in View pages */
.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-header-actions-ctn .fi-btn:not(.fi-color-primary) {
    --ui-press-scale: 1 !important;
    min-height: 2.25rem !important;
    height: 2.25rem !important;
    padding-inline: 0.72rem !important;
    border-radius: 0.625rem !important;
    border: 1px solid var(--mtt-view-detail-border) !important;
    background: var(--mtt-view-detail-bg) !important;
    color: var(--mtt-view-detail-text) !important;
    font-size: 0.6875rem !important;
    font-weight: 550 !important;
    line-height: 1 !important;
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.03) !important;
    transform: none !important;
    transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease !important;
}

.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-header-actions-ctn .fi-btn:not(.fi-color-primary):hover {
    background: var(--mtt-view-detail-soft) !important;
    border-color: color-mix(in srgb, var(--mtt-view-detail-border) 80%, black 20%) !important;
    color: var(--mtt-view-detail-text) !important;
}

.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-header-actions-ctn .fi-btn:not(.fi-color-primary) :is(svg, .fi-icon) {
    width: 0.9rem !important;
    height: 0.9rem !important;
}

/* --- Section Cards Canon --- */
.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-section {
    min-width: 0 !important;
    overflow: hidden !important;
    border: 1px solid var(--mtt-view-detail-border) !important;
    border-radius: var(--mtt-view-detail-radius) !important;
    background: var(--mtt-view-detail-bg) !important;
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.025) !important;
}

/* Subtle orange accent top line on the summary/first section card */
.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-section:first-of-type,
.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-section.moretto-view-summary {
    border-top: 2px solid color-mix(in srgb, var(--mtt-view-detail-accent) 74%, transparent) !important;
}

/* Compact Section Header */
.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-section-header {
    min-height: 0 !important;
    padding: 0.48rem 0.7rem !important;
    border-bottom: 1px solid var(--mtt-view-detail-border-soft) !important;
    background: transparent !important;
    box-shadow: none !important;
}

.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-section-header-heading {
    color: var(--mtt-view-detail-text) !important;
    font-size: 0.6875rem !important;
    font-weight: 600 !important;
    line-height: 1.16 !important;
    letter-spacing: -0.01em !important;
}

.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-section-header-description {
    max-width: 54rem !important;
    margin-top: 0.08rem !important;
    color: var(--mtt-view-detail-muted) !important;
    font-size: 9px !important;
    font-weight: 400 !important;
    line-height: 1.3 !important;
}

/* Section Content Padding & Horizontal Grid */
.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-section-content {
    padding: 0.58rem 0.7rem 0.64rem !important;
}

.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-section-content .fi-grid {
    gap: 0.46rem 0.8rem !important;
    align-items: start !important;
}

.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-in-entry-wrp {
    min-width: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
}

/* Data Labels (9.5px / 500) */
.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page :is(.fi-in-entry-wrp-label, .fi-in-text-entry-label) {
    margin-bottom: 0.1rem !important;
    color: var(--mtt-view-detail-muted) !important;
    font-size: 9.5px !important;
    font-weight: 500 !important;
    line-height: 1.15 !important;
}

/* Data Values (11px / 400) */
.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page :is(.fi-in-entry-wrp-state, .fi-in-text-entry, .fi-in-text-item) {
    color: var(--mtt-view-detail-text) !important;
    font-size: 0.6875rem !important;
    font-weight: 400 !important;
    line-height: 1.3 !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
}

/* Numeric entries tabular alignment */
.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page [class*="-total"] :is(.fi-in-entry-wrp-state, .fi-in-text-entry, .fi-in-text-item),
.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page [class*="-amount"] :is(.fi-in-entry-wrp-state, .fi-in-text-entry, .fi-in-text-item),
.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page [class*="-balance"] :is(.fi-in-entry-wrp-state, .fi-in-text-entry, .fi-in-text-item),
.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page [class*="-price"] :is(.fi-in-entry-wrp-state, .fi-in-text-entry, .fi-in-text-item) {
    font-variant-numeric: tabular-nums !important;
}

/* Badges inside View Record: geometría delegada al owner (moretto-admin-components.css).
   Aquí solo viven estado/composición propios de la vista de registro. */

/* --- Internal Tables & Repeatables in View Record pages --- */
.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-in-repeatable {
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-in-repeatable table,
.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-section table {
    width: 100% !important;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
}

.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-section table thead th {
    height: 1.7rem !important;
    padding: 0.32rem 0.58rem !important;
    border-bottom: 1px solid var(--mtt-view-detail-border-soft) !important;
    background: var(--mtt-view-detail-soft) !important;
    color: var(--mtt-view-detail-muted) !important;
    font-size: 9.5px !important;
    font-weight: 600 !important;
    line-height: 1.15 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.035em !important;
    white-space: nowrap !important;
}

.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-section table tbody td {
    height: 1.95rem !important;
    padding: 0.38rem 0.58rem !important;
    border-bottom: 1px solid var(--mtt-view-detail-border-soft) !important;
    color: var(--mtt-view-detail-text) !important;
    font-size: 0.6875rem !important;
    font-weight: 400 !important;
    line-height: 1.25 !important;
    background: transparent !important;
}

.fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-section table tbody tr:hover td {
    background: color-mix(in srgb, var(--mtt-view-detail-soft) 85%, transparent) !important;
}

/* --- Dark Mode Support for View Record pages --- */
html.dark .fi-body:not([data-moretto-pos]) .fi-resource-view-record-page {
    --mtt-view-detail-bg: #121316;
    --mtt-view-detail-soft: #18191d;
    --mtt-view-detail-border: #26282e;
    --mtt-view-detail-border-soft: #1f2026;
    --mtt-view-detail-text: #f3f4f6;
    --mtt-view-detail-muted: #9aa2b1;
}

html.dark .fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-header-actions-ctn .fi-btn:not(.fi-color-primary) {
    background: #18191d !important;
    border-color: #2a2c34 !important;
    color: #e5e7eb !important;
}

html.dark .fi-body:not([data-moretto-pos]) .fi-resource-view-record-page .fi-header-actions-ctn .fi-btn:not(.fi-color-primary):hover {
    background: #212329 !important;
    border-color: #3b3e4a !important;
    color: #fff !important;
}
