/* OmniVenta V63.28.03 STABLE-R47
 * Cross-device UI audit/polish layer.
 * Presentation only: no business rules, endpoints, permissions, totals or database behavior.
 * Loaded last so it can normalize older Bootstrap 3 screens without replacing module engines.
 */

/* ---------- Shared containment / typography ---------- */
html { -webkit-text-size-adjust: 100%; }
body.ov-responsive,
body.ov-responsive .main-content,
body.ov-responsive .main-content > .container-fluid,
body.ov-responsive .main-content .row,
body.ov-responsive .main-content [class*="col-"] {
  min-width: 0;
}
body.ov-responsive .main-content { max-width: 100%; }
body.ov-responsive .main-content .panel,
body.ov-responsive .main-content .panel-body,
body.ov-responsive .main-content .well,
body.ov-responsive .main-content .list-group,
body.ov-responsive .main-content .tab-content,
body.ov-responsive .main-content .invoice_body {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
body.ov-responsive .main-content .panel-title,
body.ov-responsive .main-content .panel-heading,
body.ov-responsive .main-content .help-block,
body.ov-responsive .main-content .alert,
body.ov-responsive .main-content .list-group-item {
  overflow-wrap: break-word;
  word-break: normal;
}
body.ov-responsive .main-content img,
body.ov-responsive .main-content video,
body.ov-responsive .main-content canvas,
body.ov-responsive .main-content svg:not(.svg-inline--fa) {
  max-width: 100%;
}
body.ov-responsive .main-content fieldset { min-width: 0; }
body.ov-responsive .main-content textarea { resize: vertical; }
body.ov-responsive .main-content .form-control,
body.ov-responsive .main-content .btn,
body.ov-responsive .main-content .input-group-addon,
body.ov-responsive .main-content .input-group-btn > .btn {
  box-sizing: border-box;
}

/* ---------- Menus / action bars ---------- */
body.ov-responsive .main-content .dropdown-menu {
  max-width: min(380px, calc(100vw - 20px));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
body.ov-responsive .main-content .dropdown-menu > li > a,
body.ov-responsive .main-content .dropdown-menu > li > button {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  line-height: 1.35;
}
body.ov-responsive .main-content .btn-toolbar,
body.ov-responsive .main-content .buttons-list,
body.ov-responsive .main-content .form-actions {
  max-width: 100%;
}
body.ov-responsive .main-content .btn-toolbar .btn-group,
body.ov-responsive .main-content .buttons-list .btn-group { min-width: 0; }
body.ov-responsive .main-content .btn { vertical-align: middle; }
body.ov-responsive .main-content .btn > i:first-child,
body.ov-responsive .main-content .btn > span[class*="ion-"]:first-child,
body.ov-responsive .main-content .btn > span[class*="ti-"]:first-child { vertical-align: middle; }

/* ---------- Form controls ---------- */
body.ov-responsive .main-content .input-group { min-width: 0; max-width: 100%; }
body.ov-responsive .main-content .input-group .form-control { min-width: 0; }
body.ov-responsive .main-content .input-group-btn { width: 1%; white-space: nowrap; }
body.ov-responsive .main-content .select2-container,
body.ov-responsive .main-content .selectize-control,
body.ov-responsive .main-content .bootstrap-select { max-width: 100%; }
body.ov-responsive .main-content label { max-width: 100%; }
body.ov-responsive .main-content input[type="file"] { max-width: 100%; }
body.ov-responsive .main-content .checkbox label,
body.ov-responsive .main-content .radio label { white-space: normal; }

/* ---------- Tables stay Excel-like; contain them instead of shrinking data ---------- */
body.ov-responsive .main-content .table-responsive,
body.ov-responsive .main-content .table_holder,
body.ov-responsive .main-content .ov-auto-table-responsive,
body.ov-responsive .main-content .ov-table-scroll,
body.ov-responsive .main-content .ov-register-table-scroll,
body.ov-responsive .main-content .dataTables_scrollBody {
  max-width: 100%;
}
body.ov-responsive .main-content table.table th,
body.ov-responsive .main-content table.table td {
  vertical-align: middle;
}
body.ov-responsive .main-content table.table th { line-height: 1.25; }
body.ov-responsive .main-content table.table td .btn-group { white-space: nowrap; }
body.ov-responsive .main-content table.table td img { max-width: 100%; height: auto; }
body.ov-responsive .main-content .dataTables_wrapper { max-width: 100%; min-width: 0; }
body.ov-responsive .main-content .dataTables_wrapper .row { min-width: 0; }

/* ---------- Bootstrap dialogs / popovers ---------- */
body.ov-responsive .modal-dialog { max-width: calc(100vw - 20px); }
body.ov-responsive .modal-content { min-width: 0; max-width: 100%; }
body.ov-responsive .modal-header,
body.ov-responsive .modal-body,
body.ov-responsive .modal-footer { min-width: 0; }
body.ov-responsive .modal-title { overflow-wrap: break-word; }
body.ov-responsive .popover { max-width: min(360px, calc(100vw - 16px)); }
body.ov-responsive .tooltip { max-width: calc(100vw - 16px); }
body.ov-responsive .ui-datepicker { max-width: calc(100vw - 16px); }
body.ov-responsive .daterangepicker { max-width: calc(100vw - 16px); }

/* ---------- Generic manage/list screens ---------- */
body.ov-responsive .manage_buttons,
body.ov-responsive .manage-table,
body.ov-responsive .manage-row-options { min-width: 0; max-width: 100%; }
body.ov-responsive .manage_buttons .search,
body.ov-responsive .manage_buttons .search ul.list-inline { max-width: 100%; }
body.ov-responsive .manage_buttons .search ul.list-inline > li { min-width: 0; }
body.ov-responsive .manage_buttons .search .form-control { max-width: 100%; }
body.ov-responsive .pagination { max-width: 100%; }

/* ---------- Module families: containment on desktop and mobile ---------- */
body.ov-module-customers .main-content,
body.ov-module-suppliers .main-content,
body.ov-module-employees .main-content,
body.ov-module-items .main-content,
body.ov-module-item_kits .main-content,
body.ov-module-giftcards .main-content,
body.ov-module-locations .main-content,
body.ov-module-price_rules .main-content,
body.ov-module-work_orders .main-content,
body.ov-module-appointments .main-content,
body.ov-module-deliveries .main-content,
body.ov-module-expenses .main-content,
body.ov-module-timeclocks .main-content,
body.ov-module-reports .main-content,
body.ov-module-messages .main-content,
body.ov-module-customer_subscriptions .main-content,
body.ov-module-permission_templates .main-content {
  min-width: 0;
  max-width: 100%;
}

/* Reports: long category names should never leak outside their card. */
body.ov-module-reports .report-listing .list-group-item {
  white-space: normal;
  min-height: 42px;
}
body.ov-module-reports .report-listing .list-group-item .icon { vertical-align: middle; }

/* Accounting / finance summary cards and filters. */
body.ov-module-accounting .accounting-query-panel,
body.ov-module-accounting .accounting-data-panel,
body.ov-module-bank_accounts .bank-query-card,
body.ov-module-bank_accounts .panel,
body.ov-module-petty_cash .panel,
body.ov-module-expenses .panel,
body.ov-module-payroll .panel,
body.ov-module-invoices .panel { min-width: 0; max-width: 100%; }
body.ov-module-accounting .acct-card,
body.ov-module-invoices .ov-summary-card { min-width: 0; }

/* Inventory families. */
body.ov-module-items .main-content .panel,
body.ov-module-item_kits .main-content .panel,
body.ov-module-insumos .main-content .panel,
body.ov-module-supplies_inventory .main-content .panel,
body.ov-module-shelf_gaps .main-content .panel,
body.ov-module-shelf_labels .main-content .panel { min-width: 0; max-width: 100%; }

/* Operational screens preserve their native register engine and only get containment. */
body.ov-module-sales .register,
body.ov-module-receivings .register,
body.ov-module-sales .register-box,
body.ov-module-receivings .register-box,
body.ov-module-restaurant .main-content { min-width: 0; max-width: 100%; }
body.ov-module-sales .sales-dropdown,
body.ov-module-receivings .sales-dropdown { overflow-x: hidden; }

/* Configuration / dashboard / messaging / subscription shells. */
body.ov-module-config .config-panel,
body.ov-module-config .config-page,
body.ov-module-home .main-content,
body.ov-module-messages .main-content,
body.ov-module-customer_subscriptions .main-content,
body.ov-module-permission_templates .main-content {
  min-width: 0;
  max-width: 100%;
}
body.ov-module-config .config-panel .panel,
body.ov-module-config .config-panel .form-group { max-width: 100%; }

/* ---------- Tablet ---------- */
@media (max-width: 991px) {
  body.ov-responsive .main-content .dropdown-menu { max-height: min(68vh, 520px); }
  body.ov-responsive .main-content .btn-toolbar,
  body.ov-responsive .main-content .buttons-list { display: flex; flex-wrap: wrap; gap: 6px; }
  body.ov-responsive .main-content .btn-toolbar:before,
  body.ov-responsive .main-content .btn-toolbar:after,
  body.ov-responsive .main-content .buttons-list:before,
  body.ov-responsive .main-content .buttons-list:after { display: none; }
  body.ov-responsive .main-content .btn-toolbar > .btn,
  body.ov-responsive .main-content .buttons-list > .btn { margin: 0; }
}

/* ---------- Phone ---------- */
@media (max-width: 767px) {
  body.ov-responsive { overflow-x: hidden; }
  body.ov-responsive .main-content { width: 100%; }
  body.ov-responsive .main-content > .container-fluid { padding-left: 7px; padding-right: 7px; }

  /* Legacy inline min-widths on controls/cards must not force the entire page wider.
     Tables/cells are intentionally excluded because their horizontal scroll is useful. */
  body.ov-responsive .main-content :not(table):not(thead):not(tbody):not(tr):not(th):not(td)[style*="min-width"] {
    min-width: 0 !important;
    max-width: 100%;
  }

  /* Comfortable touch targets, while keeping dense table action buttons compact. */
  body.ov-responsive .main-content .btn:not(.btn-xs) { min-height: 42px; }
  body.ov-responsive .main-content .btn.btn-sm { min-height: 38px; }
  body.ov-responsive .main-content .table .btn.btn-sm,
  body.ov-responsive .main-content .table .btn.btn-xs { min-height: 32px; }
  body.ov-responsive .main-content .form-horizontal input.form-control,
  body.ov-responsive .main-content .form-horizontal select.form-control,
  body.ov-responsive .main-content .form-horizontal .select2-container .select2-choice,
  body.ov-responsive .main-content form:not(.form-inline) > .form-group > input.form-control,
  body.ov-responsive .main-content form:not(.form-inline) > .form-group > select.form-control {
    min-height: 42px;
  }
  body.ov-responsive .main-content .form-horizontal .control-label { text-align: left !important; padding-top: 0; margin-bottom: 5px; }
  body.ov-responsive .main-content .form-horizontal .form-group { margin-bottom: 14px; }

  /* Action/search bars become rows instead of overflowing. */
  body.ov-responsive .manage_buttons { padding-left: 0; padding-right: 0; }
  body.ov-responsive .manage_buttons > .row,
  body.ov-responsive .manage_buttons .row { margin-left: 0; margin-right: 0; }
  body.ov-responsive .manage_buttons .row > [class*="col-"] { min-width: 0; }
  body.ov-responsive .manage_buttons .search ul.list-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 0;
  }
  body.ov-responsive .manage_buttons .search ul.list-inline > li {
    float: none;
    margin: 0;
    padding: 0;
    flex: 1 1 145px;
    max-width: 100%;
  }
  body.ov-responsive .manage_buttons .search ul.list-inline > li:first-child { flex-basis: 220px; }
  body.ov-responsive .manage_buttons .search .form-control,
  body.ov-responsive .manage_buttons .search .select2-container,
  body.ov-responsive .manage_buttons .search .bootstrap-select { width: 100% !important; }
  body.ov-responsive .manage_buttons .btn-more { min-width: 44px; }

  /* Menus opened from normal page action bars fit the viewport. Register mode menus are excluded. */
  body.ov-responsive .manage_buttons .btn-group.open > .dropdown-menu,
  body.ov-responsive .panel-options .btn-group.open > .dropdown-menu,
  body.ov-responsive .ov-receiving-more-group.open > .dropdown-menu {
    left: auto;
    right: 0;
    width: max-content;
    min-width: 210px;
    max-width: calc(100vw - 18px);
  }
  body.ov-module-receivings .ov-receiving-more-group.open > .dropdown-menu {
    left: 0;
    right: auto;
  }
  body.ov-responsive .main-content .dropdown-menu { max-height: min(70dvh, 520px); }
  body.ov-responsive .main-content .dropdown-menu > li > a { padding-top: 10px; padding-bottom: 10px; }

  /* Bootstrap modals become viewport-safe sheets without changing submit handlers. */
  body.ov-responsive .modal-dialog {
    width: auto !important;
    max-width: calc(100vw - 12px) !important;
    margin: max(6px, env(safe-area-inset-top, 0px)) 6px max(6px, env(safe-area-inset-bottom, 0px));
  }
  body.ov-responsive .modal-content {
    max-height: calc(100dvh - 12px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  body.ov-responsive .modal-header,
  body.ov-responsive .modal-footer { flex: 0 0 auto; }
  body.ov-responsive .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
  body.ov-responsive .modal-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
  }
  body.ov-responsive .modal-footer .btn { flex: 1 1 120px; margin: 0 !important; }

  /* Pagination/DataTables controls remain reachable. */
  body.ov-responsive .dataTables_wrapper .dataTables_length,
  body.ov-responsive .dataTables_wrapper .dataTables_filter,
  body.ov-responsive .dataTables_wrapper .dataTables_info,
  body.ov-responsive .dataTables_wrapper .dataTables_paginate {
    float: none !important;
    width: 100%;
    text-align: left !important;
    margin: 6px 0;
  }
  body.ov-responsive .dataTables_wrapper .dataTables_filter input { max-width: 100%; }
  body.ov-responsive .pagination { display: flex; flex-wrap: wrap; gap: 3px; white-space: normal; }
  body.ov-responsive .pagination > li { float: none; }

  /* People: customers / suppliers / employees. */
  body.ov-module-customers .manage_buttons .search ul.list-inline > li,
  body.ov-module-suppliers .manage_buttons .search ul.list-inline > li,
  body.ov-module-employees .manage_buttons .search ul.list-inline > li { flex-basis: 100%; }
  body.ov-module-customers .main-content .form-group[style*="min-width"] { min-width: 0 !important; width: 100%; }

  /* Employee form has a legacy custom location/permission drop-menu. */
  body.ov-module-employees .list-group-item .drop-menu {
    left: auto !important;
    right: 0 !important;
    width: min(320px, calc(100vw - 28px)) !important;
    max-width: calc(100vw - 28px) !important;
    max-height: 60dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }
  body.ov-module-employees .list-group-item .drop-menu label { white-space: normal; }

  /* Items / kits / gift cards / locations / price rules / work orders. */
  body.ov-module-items .manage_buttons .search ul.list-inline > li,
  body.ov-module-item_kits .manage_buttons .search ul.list-inline > li,
  body.ov-module-giftcards .manage_buttons .search ul.list-inline > li,
  body.ov-module-locations .manage_buttons .search ul.list-inline > li,
  body.ov-module-price_rules .manage_buttons .search ul.list-inline > li,
  body.ov-module-work_orders .manage_buttons .search ul.list-inline > li { flex-basis: 150px; }
  body.ov-module-items .main-content .nav-tabs,
  body.ov-module-item_kits .main-content .nav-tabs,
  body.ov-module-work_orders .main-content .nav-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
  body.ov-module-items .main-content .nav-tabs > li,
  body.ov-module-item_kits .main-content .nav-tabs > li,
  body.ov-module-work_orders .main-content .nav-tabs > li { float: none; flex: 0 0 auto; }

  /* Appointments / deliveries: keep calendar/list actions on-screen. */
  body.ov-module-appointments .manage_buttons .buttons-list,
  body.ov-module-deliveries .manage_buttons .buttons-list { display: flex; flex-wrap: wrap; gap: 6px; }
  body.ov-module-appointments .manage_buttons .buttons-list .btn,
  body.ov-module-deliveries .manage_buttons .buttons-list .btn { margin: 0 !important; }

  /* Timeclock is an operational touch screen: one action per comfortable block. */
  body.ov-module-timeclocks .main-content ul.list-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-left: 0;
  }
  body.ov-module-timeclocks .main-content ul.list-inline > li {
    float: none !important;
    margin: 0 !important;
    padding: 0;
    flex: 1 1 180px;
  }
  body.ov-module-timeclocks .main-content ul.list-inline > li.pull-right { margin-left: 0 !important; }
  body.ov-module-timeclocks .main-content ul.list-inline .btn { width: 100%; white-space: normal; }

  /* Reports: category chooser becomes a clean vertical touch list. */
  body.ov-module-reports .report-listing > [class*="col-"] { width: 100%; float: none; }
  body.ov-module-reports .report-listing .list-group-item { min-height: 46px; padding: 12px 14px; }

  /* Finance / payroll filters: controls stack without touching table widths. */
  body.ov-module-accounting .accounting-query-panel .row > [class*="col-"],
  body.ov-module-bank_accounts .bank-query-card .row > [class*="col-"],
  body.ov-module-petty_cash .panel form .row > [class*="col-"],
  body.ov-module-expenses .main-content form .row > [class*="col-"],
  body.ov-module-payroll .payroll-query-panel .row > [class*="col-"],
  body.ov-module-payroll .payroll-filter-panel .row > [class*="col-"] { margin-bottom: 8px; }
  body.ov-module-accounting form.form-inline,
  body.ov-module-bank_accounts form.form-inline,
  body.ov-module-petty_cash form.form-inline,
  body.ov-module-payroll .panel-body > form.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: flex-end;
  }
  body.ov-module-accounting form.form-inline .form-group,
  body.ov-module-bank_accounts form.form-inline .form-group,
  body.ov-module-petty_cash form.form-inline .form-group,
  body.ov-module-payroll .panel-body > form.form-inline .form-group { flex: 1 1 145px; margin: 0; }

  /* Supplies / internal warehouse. */
  body.ov-module-insumos .ins-toolbar,
  body.ov-module-supplies_inventory .omni-stock-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  body.ov-module-insumos .ins-toolbar .btn,
  body.ov-module-supplies_inventory .omni-stock-toolbar .btn { margin: 0 !important; }

  /* Sales / receiving: do not alter their engines; just stop outer page overflow. */
  body.ov-module-sales .register,
  body.ov-module-receivings .register { margin-left: 0; margin-right: 0; }
  body.ov-module-sales .register > [class*="col-"],
  body.ov-module-receivings .register > [class*="col-"] { min-width: 0; }
  body.ov-module-sales .register-right,
  body.ov-module-receivings .register-right { max-width: 100%; }

  /* Restaurant / shelf tools already have dedicated mobile flows; only contain helper UI. */
  body.ov-module-restaurant .main-content .panel,
  body.ov-module-shelf_gaps .main-content .panel,
  body.ov-module-shelf_labels .main-content .panel { max-width: 100%; }

  /* Footer never causes horizontal page movement. */
  body.ov-responsive #footers { max-width: 100%; overflow-wrap: anywhere; }
}

@media (max-width: 480px) {
  body.ov-responsive .main-content > .container-fluid { padding-left: 5px; padding-right: 5px; }
  body.ov-responsive .manage_buttons .search ul.list-inline > li { flex-basis: 100%; }
  body.ov-responsive .main-content .dropdown-menu { max-width: calc(100vw - 12px); }
  body.ov-responsive .modal-dialog { max-width: calc(100vw - 8px) !important; margin-left: 4px; margin-right: 4px; }
  body.ov-responsive .modal-header { padding: 12px; }
  body.ov-responsive .modal-body { padding: 12px; }
  body.ov-responsive .modal-footer { padding-left: 12px; padding-right: 12px; }
}

/* Printing: the UI audit layer must never introduce scrolling/fixed action UI on paper. */
@media print {
  body.ov-responsive .main-content,
  body.ov-responsive .main-content .container-fluid,
  body.ov-responsive .main-content .panel,
  body.ov-responsive .main-content .panel-body { overflow: visible !important; }
  body.ov-responsive .modal,
  body.ov-responsive .dropdown-menu { max-height: none !important; }
}
