/**
 * SYSBAR MODERN DESIGN SYSTEM & RESET
 * A clean, premium foundation for the application.
 */

/* 1. DESIGN TOKENS (CSS Variables) */
:root {
    /* Brand Colors - Sophisticated Blue Palette */
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-200: #bfdbfe;
    --primary-300: #93c5fd;
    --primary-400: #60a5fa;
    --primary-500: #3b82f6;
    /* Base Primary */
    --primary-600: #2563eb;
    --primary-700: #1d4ed8;
    --primary-800: #1e40af;
    --primary-900: #1e3a8a;

    /* Surface & Backgrounds */
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --border-subtle: #e2e8f0;

    /* Text */
    --text-main: #1e293b;
    --text-muted: #64748b;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* 2. MODERN CSS RESET (Based on Josh Comeau's Reset) */
*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
}

html,
body {
    height: 100%;
}

body {
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    background-color: var(--bg-main);
    color: var(--text-main);
}

img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
}

input,
button,
textarea,
select {
    font: inherit;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
    overflow-wrap: break-word;
}

/* 3. CORE STRUCTURAL FIXES (Preserved) */

/* Sidebar Layout Fixes */
.fi-sidebar {
    max-width: 240px;
    background: #232323 !important;
    border-right: 0 !important;
    box-shadow: 6px 0 20px rgba(15, 23, 42, 0.25);
}

.fi-sidebar-header,
.fi-sidebar-nav {
    background: #232323 !important;
}

.fi-sidebar-nav {
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
    padding-top: 0.5rem !important;
    padding-bottom: 1rem !important;
}

.fi-sidebar-header {
    background: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
}

@media (min-width: 1024px) {
    .fi-sidebar,
    .fi-sidebar-nav {
        background: #232323 !important;
    }

    .fi-sidebar-header {
        background: #ffffff !important;
    }
}

ul.fi-sidebar-nav-groups {
    row-gap: 0.875rem;
    padding-top: 0.5rem;
}

a.fi-sidebar-item-button {
    padding: 8px 10px;
    border-radius: 10px;
    color: #ffffff !important;
    font-weight: 600;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.fi-sidebar-group-label {
    color: #ffffff !important;
    opacity: 0.9;
    letter-spacing: 0;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: none;
}

.fi-sidebar-item-icon,
.fi-sidebar-group-icon {
    color: #ffffff !important;
    opacity: 0.9;
}

.fi-sidebar .fi-sidebar-item-label,
.fi-sidebar .fi-sidebar-group-label,
.fi-sidebar .fi-sidebar-item-button,
.fi-sidebar .fi-sidebar-item-button span,
.fi-sidebar .fi-icon-btn,
.fi-sidebar svg {
    color: #ffffff !important;
}

a.fi-sidebar-item-button:hover {
    background-color: #3a3a3a;
    color: #ffffff !important;
}

.fi-sidebar-item-active a.fi-sidebar-item-button,
a.fi-sidebar-item-button[aria-current='page'],
a.fi-sidebar-item-button[aria-current='true'] {
    background-color: rgb(217, 119, 6);
    color: #ffffff !important;
    box-shadow: inset 0 0 0 1px #f59e0b;
}

.fi-sidebar-item-active .fi-sidebar-item-icon,
a.fi-sidebar-item-button[aria-current='page'] .fi-sidebar-item-icon,
a.fi-sidebar-item-button[aria-current='true'] .fi-sidebar-item-icon {
    color: #ffffff !important;
}

/* Fix sidebar label truncation */
.filament-sidebar-item-label,
.fi-sidebar-item-label {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    max-width: none !important;
}

/* Main Content Spacing */
.fi-main {
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 1.5rem !important;
    margin-right: 1.5rem !important;
    max-width: calc(100% - 3rem) !important;
}

/* UI Refinements */
.fi-ta-text-item-label.text-sm {
    font-size: 0.8rem !important;
    line-height: 1rem !important;
}

.fi-ta-text.grid {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}

/* Repeater Spacing */
.fi-fo-field[data-state-path="detalles"] .fi-fo-repeater {
    gap: 0.5rem !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Form Fields - Readonly Consistency */
input[readonly="readonly"],
textarea[readonly="readonly"],
.fi-input[readonly="readonly"] {
    background-color: #f9fafb !important;
    color: #6b7280 !important;
    cursor: default !important;
    opacity: 1 !important;
}

/* Specialized Input: Cantidad */
.cantidad-cell input {
    text-align: center !important;
    width: 100px !important;
    color: #111827 !important;
    font-weight: 700 !important;
    background-color: #ffffff !important;
    border: 2px solid var(--primary-500) !important;
    border-radius: 6px !important;
    box-shadow: var(--shadow-sm) !important;
}

.dark .cantidad-cell input {
    color: #ffffff !important;
    background-color: #1f2937 !important;
}

/* Cross-browser spinner forcing */
.cantidad-cell input::-webkit-outer-spin-button,
.cantidad-cell input::-webkit-inner-spin-button {
    -webkit-appearance: inner-spin-button !important;
    opacity: 1 !important;
}

.cantidad-cell input {
    -moz-appearance: textfield !important;
}

/* Tamaño mínimo de la tabla en Consultar Productos */
.fi-resource-consulta-productos .fi-ta-content {
    min-height: 400px;
}

/* Selector de Categorías Maestras: contraste y tipografía */
.fi-resource-consulta-productos .choices__list--dropdown .choices__item--selectable {
    color: #111827 !important;
    background-color: #ffffff !important;
}

.fi-resource-consulta-productos .choices__list--dropdown .choices__item--selectable.is-highlighted,
.fi-resource-consulta-productos .choices__list[aria-expanded] .choices__item--selectable.is-highlighted,
.fi-resource-consulta-productos .choices__list--dropdown .choices__item--selectable:hover {
    color: #111827 !important;
    background-color: rgb(235 235 235) !important;
}

.fi-resource-consulta-productos .choices__list--dropdown .choices__item--selectable .cm-option-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    min-width: 0;
}

.fi-resource-consulta-productos .choices__list--dropdown .choices__item--selectable .cm-option-main {
    font-weight: 700;
    white-space: nowrap;
}

.fi-resource-consulta-productos .choices__list--dropdown .choices__item--selectable .cm-option-meta {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #374151;
}