/* Document Creation Styles */

/* =============================================
   Input Group - Elementos pegados con borde exterior
   ============================================= */

.input-group-bordered {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 4px;
    background: var(--mud-palette-surface);
}

/* Cada celda del grupo */
.input-group-cell {
    display: flex;
    align-items: center;
    padding: 0 8px;
    border-right: 1px solid var(--mud-palette-lines-default);
}

.input-group-cell:last-child {
    border-right: none;
}

/* Celda que se expande (input de búsqueda) */
.input-group-cell-expand {
    flex: 1;
}

/* Versión compacta del input group (menos altura) */
.input-group-compact .input-group-cell {
    padding: 0 4px;
}

.input-group-compact .mud-input-slot {
    padding: 4px 0 !important;
}

/* Quitar márgenes de MudBlazor inputs dentro del grupo */
.input-group-cell .mud-input-control {
    margin: 0 !important;
}

.input-group-cell .mud-input-slot {
    padding: 8px 0 !important;
}

.input-group-cell .mud-input.mud-input-text {
    padding: 0 !important;
}

/* =============================================
   Control de cantidad dentro del input group
   ============================================= */

.input-group-cell .quantity-control {
    display: flex;
    align-items: center;
}

.input-group-cell .quantity-control .mud-input-control {
    width: 60px;
}

.input-group-cell .quantity-control .mud-input-slot {
    text-align: center;
}

/* =============================================
   Quantity Control Inline (para tabla de líneas)
   ============================================= */

.quantity-control-inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* MudNumericField compacto sin bordes ni underline */
.quantity-control-inline .quantity-input {
    width: 70px;
    margin: 0;
}

.quantity-control-inline .quantity-input .mud-input-slot {
    text-align: center;
    font-size: 0.875rem;
    padding: 4px 0;
}

.quantity-control-inline .quantity-input .mud-input.mud-input-text::before,
.quantity-control-inline .quantity-input .mud-input.mud-input-text::after {
    border: none !important;
}

.quantity-control-inline .quantity-input .mud-input.mud-input-text:hover::before {
    border: none !important;
}

/* =============================================
   Action Buttons (Panel de comandos)
   ============================================= */

.action-button {
    width: 72px !important;
    height: 72px !important;
}

.action-button .mud-icon-root {
    font-size: 2rem !important;
}

/* =============================================
   Sidebar FAB (Mobile)
   ============================================= */

.sidebar-fab {
    position: fixed !important;
    bottom: 24px;
    left: 24px;
    z-index: 1000;
}

/* Adjust FAB position on mobile to avoid overlap with bottom bar */
@media (max-width: 960px) {
    .sidebar-fab {
        bottom: 80px; /* Move up to sit above bottom action bar */
    }
}

/* =============================================
   Mobile Bottom Action Bar
   ============================================= */

.mobile-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1100; /* Above FAB (1000) */
    padding-bottom: env(safe-area-inset-bottom); /* iOS safe area */
}

.mobile-bottom-bar .mud-paper {
    border-radius: 0; /* Full-width, no rounded corners on mobile */
    border-top: 1px solid var(--mud-palette-lines-default);
}

/* =============================================
   Product Search Drawer - Height Variables
   ============================================= */

:root {
    /* Header (72px) + Filters (80px) + Footer (56px) + Pager (49px) = 257px */
    --product-search-offset-default: 257px;
    /* Header + Filters wrapped on tablet (2 rows ~128px) + Footer + Pager = 305px */
    --product-search-offset-tablet: 305px;
    /* AppBar (64px) + Header (56px) + Filters (~100px) + Footer (~80px) + Margins (~180px) = 480px */
    --document-lines-offset: 480px;

    /* Viewport height - fallback for older browsers */
    --vh-full: 100vh;
}

/* Dynamic viewport height for mobile browsers (handles URL bar) */
@supports (height: 100dvh) {
    :root {
        --vh-full: 100dvh;
    }
}

/* Hide drawer when closed, but delay to allow closing animation */
.product-search-drawer.mud-drawer--closed {
    visibility: hidden;
    transition: visibility 0s linear 0.25s;
}

.product-search-drawer.mud-drawer--open {
    visibility: visible;
    transition: visibility 0s linear 0s;
}

.product-search-drawer-header {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--mud-palette-surface);
}

.product-search-table .mud-table-container {
    height: calc(85vh - var(--product-search-offset-default));
}

/* Screens < 1700px: drawer full height */
@media (max-width: 1699px) {
    .product-search-drawer {
        height: var(--vh-full) !important;
    }

    .product-search-table .mud-table-container {
        height: calc(var(--vh-full) - var(--product-search-offset-default)) !important;
    }
}

/* Tablet: filters wrap to 2 rows, need more offset */
@media (max-width: 1024px) {
    .product-search-table .mud-table-container {
        height: calc(var(--vh-full) - var(--product-search-offset-tablet)) !important;
    }
}

/* =============================================
   Document Lines Table - Responsive Height
   ============================================= */

.document-lines-table .mud-table-container {
    max-height: calc(var(--vh-full) - var(--document-lines-offset)) !important;
}

@media (max-width: 959px) {
    .document-lines-table .mud-table-container {
        max-height: 450px !important;
    }
}

/* =============================================
   Hide Scrollbar (mantiene funcionalidad)
   ============================================= */

.hide-scrollbar {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;     /* Firefox */
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;  /* Chrome, Safari, Opera */
}

/* =============================================
   Document Sidebar - Responsive
   ============================================= */

.document-sidebar {
    height: calc(var(--vh-full) - 208px);
    overflow: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.document-sidebar::-webkit-scrollbar {
    display: none;
}

@media (max-width: 959px) {
    .document-sidebar {
        height: 100%;
        overflow: visible;
    }
}

/* =============================================
   Document Editor Layout (sticky header + scroll)
   ============================================= */

.document-editor-layout {
    display: flex;
    flex-direction: column;
    height: calc(var(--vh-full) - 64px); /* viewport menos AppBar */
}

.document-editor-header {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--mud-palette-background);
    padding-bottom: 12px;
}

.document-editor-content {
    flex: 1;
    overflow: hidden;
}

.document-editor-scrollable {
    height: 100%;
    overflow-y: auto;
    padding-right: 8px; /* espacio para scrollbar */
}

/* =============================================
   Customer Search Drawer - Table
   ============================================= */

.customer-search-table .mud-table-container {
    height: calc(var(--vh-full) - 260px);
}

.customer-search-table .customer-row-selected {
    background-color: var(--mud-palette-gray-light);
}

/* =============================================
   Document Lines Grid - Keyboard Selection
   ============================================= */

.document-lines-table .selected-line {
    background-color: color-mix(in srgb, var(--mud-palette-primary) 12%, transparent) !important;
}

.document-lines-table .selected-line:hover {
    background-color: color-mix(in srgb, var(--mud-palette-primary) 18%, transparent) !important;
}

/* scroll-margin accounts for the sticky thead when using scrollIntoView.
   Without this, rows scroll behind the fixed header and appear hidden. */
.document-lines-table tbody tr {
    scroll-margin-top: 41px;
    scroll-margin-bottom: 0;
}

