/*
 * UltimatePOS Premium UI Design System
 * ------------------------------------------------------------
 * IMPORTANT:
 * - This file intentionally does NOT define a fixed brand color.
 * - The existing UltimatePOS Blade theme resolver remains the source
 *   of truth and exposes --theme-700 / --theme-800 / --theme-900.
 * - All primary UI styling below consumes those runtime variables.
 * - Do not replace the variables with hard-coded orange/blue values.
 * - Keep this file loaded AFTER the application's base CSS so it acts
 *   as a presentation override only.
 */

:root {
    --ui-bg: #f5f7fa;
    --ui-surface: #ffffff;
    --ui-surface-elevated: #ffffff;
    --ui-surface-soft: #f8fafc;
    --ui-border: #e5e7eb;
    --ui-border-subtle: #edf0f3;
    --ui-text: #17202a;
    --ui-text-secondary: #475467;
    --ui-text-muted: #667085;
    --ui-text-faint: #98a2b3;

    /* Runtime theme: supplied by layouts/partials/css.blade.php */
    --ui-primary: var(--theme-700, #344054);
    --ui-primary-hover: var(--theme-800, #1d2939);
    --ui-primary-active: var(--theme-900, #101828);

    --ui-success: #067647;
    --ui-success-bg: #ecfdf3;
    --ui-warning: #b54708;
    --ui-warning-bg: #fffaeb;
    --ui-danger: #b42318;
    --ui-danger-bg: #fef3f2;
    --ui-info: #026aa2;
    --ui-info-bg: #eff8ff;

    --ui-radius-xs: 5px;
    --ui-radius-sm: 7px;
    --ui-radius-md: 10px;
    --ui-radius-lg: 14px;
    --ui-radius-xl: 18px;

    --ui-shadow-xs: 0 1px 2px rgba(16, 24, 40, .04);
    --ui-shadow-sm: 0 2px 6px rgba(16, 24, 40, .05);
    --ui-shadow-md: 0 8px 24px rgba(16, 24, 40, .07);

    --ui-control-h: 38px;
    --ui-control-h-sm: 32px;
    --ui-control-h-lg: 44px;

    --ui-sidebar-w: 248px;
    --ui-sidebar-collapsed-w: 68px;
    --ui-header-h: 60px;

    --ui-transition: 160ms ease;
    --ui-focus-ring: color-mix(in srgb, var(--ui-primary) 28%, transparent);
}

/* ------------------------------------------------------------
   Application canvas
   ------------------------------------------------------------ */
html,
body {
    min-height: 100%;
}

body {
    background: var(--ui-bg);
    color: var(--ui-text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--ui-primary);
    transition: color var(--ui-transition), background-color var(--ui-transition), border-color var(--ui-transition);
}

a:hover,
a:focus {
    color: var(--ui-primary-hover);
}

::selection {
    background: color-mix(in srgb, var(--ui-primary) 18%, transparent);
}

/* Do not hide content or change application display contracts. */
.content-wrapper,
.right_col,
.main-content,
.main-container {
    background: var(--ui-bg);
}

/* ------------------------------------------------------------
   Shared surfaces
   ------------------------------------------------------------ */
.box,
.panel,
.card,
.modal-content,
.dropdown-menu,
.popover,
.well,
.info-box,
.small-box {
    border-color: var(--ui-border);
    border-radius: var(--ui-radius-md);
    box-shadow: var(--ui-shadow-sm);
}

.box,
.panel,
.card,
.info-box {
    background: var(--ui-surface);
}

.box-header,
.panel-heading,
.card-header {
    border-bottom-color: var(--ui-border-subtle);
}

.box-footer,
.panel-footer,
.card-footer {
    border-top-color: var(--ui-border-subtle);
}

/* Preserve existing semantic small-box colors; only improve geometry. */
.small-box {
    overflow: hidden;
}

/* ------------------------------------------------------------
   Sidebar
   ------------------------------------------------------------ */
#side-bar,
.main-sidebar {
    background: var(--ui-surface);
    border-inline-end: 1px solid var(--ui-border-subtle);
}

#side-bar a,
.main-sidebar .sidebar-menu > li > a {
    color: var(--ui-text-secondary);
    border-radius: var(--ui-radius-sm);
    transition:
        background-color var(--ui-transition),
        color var(--ui-transition),
        box-shadow var(--ui-transition);
}

#side-bar a:hover,
#side-bar a:focus-visible,
.main-sidebar .sidebar-menu > li > a:hover,
.main-sidebar .sidebar-menu > li > a:focus-visible {
    color: var(--ui-primary);
    background: color-mix(in srgb, var(--ui-primary) 7%, transparent);
}

#side-bar a.theme-sidebar-active,
#side-bar .theme-sidebar-active,
.main-sidebar .sidebar-menu > li.active > a {
    color: var(--ui-primary);
    background: color-mix(in srgb, var(--ui-primary) 11%, transparent);
    box-shadow: inset 3px 0 0 var(--ui-primary);
}

#side-bar .theme-sidebar-child-active {
    color: var(--ui-primary);
}

#side-bar .theme-sidebar-child-hover:hover,
#side-bar .theme-sidebar-child-hover:focus-visible {
    color: var(--ui-primary);
    background: color-mix(in srgb, var(--ui-primary) 6%, transparent);
}

#side-bar a svg,
#side-bar a i {
    color: currentColor;
}

.sidebar-menu .treeview-menu {
    background: transparent;
}

.sidebar-menu .treeview-menu > li > a {
    color: var(--ui-text-muted);
}

.sidebar-menu .treeview-menu > li.active > a,
.sidebar-menu .treeview-menu > li > a:hover {
    color: var(--ui-primary);
    background: color-mix(in srgb, var(--ui-primary) 6%, transparent);
}

/* Existing theme hooks remain functional and dynamic. */
.theme-header-bg {
    background-image: none;
    background-color: var(--ui-primary-active);
}

.theme-btn-bg {
    background-color: var(--ui-primary-hover);
    border-color: color-mix(in srgb, var(--ui-primary) 40%, transparent);
}

.theme-btn-bg:hover {
    background-color: var(--ui-primary);
}

.theme-btn-bg:active,
.theme-btn-bg:focus,
.theme-btn-bg:focus-visible {
    background-color: var(--ui-primary-active);
    color: #fff;
    outline: 2px solid var(--ui-focus-ring);
    outline-offset: 1px;
}

.theme-logo-bg {
    background-color: var(--ui-primary-hover);
}

/* ------------------------------------------------------------
   Header
   ------------------------------------------------------------ */
.main-header,
.navbar,
.navbar-static-top {
    border-bottom: 1px solid var(--ui-border-subtle);
    box-shadow: var(--ui-shadow-xs);
}

.main-header .navbar,
.main-header .logo {
    min-height: var(--ui-header-h);
}

.main-header .navbar-nav > li > a {
    color: var(--ui-text-secondary);
}

.main-header .navbar-nav > li > a:hover,
.main-header .navbar-nav > li > a:focus {
    color: var(--ui-primary);
    background: color-mix(in srgb, var(--ui-primary) 6%, transparent);
}

/* ------------------------------------------------------------
   Typography / page hierarchy
   ------------------------------------------------------------ */
h1, h2, h3, h4, h5, h6 {
    color: var(--ui-text);
}

h1 {
    font-size: clamp(22px, 2vw, 28px);
    font-weight: 700;
    letter-spacing: -.025em;
}

h2 {
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -.02em;
}

h3 {
    font-size: 18px;
    font-weight: 650;
}

.text-muted,
.help-block,
.form-text {
    color: var(--ui-text-muted);
}

/* ------------------------------------------------------------
   Buttons
   ------------------------------------------------------------ */
.btn {
    min-height: var(--ui-control-h);
    border-radius: var(--ui-radius-sm);
    border-width: 1px;
    font-weight: 600;
    box-shadow: none;
    transition:
        color var(--ui-transition),
        background-color var(--ui-transition),
        border-color var(--ui-transition),
        box-shadow var(--ui-transition),
        transform var(--ui-transition);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:focus,
.btn:focus-visible,
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--ui-focus-ring);
    outline-offset: 2px;
}

.btn-primary,
.btn-primary:active,
.btn-primary:focus {
    background-color: var(--ui-primary);
    border-color: var(--ui-primary);
    color: #fff;
}

.btn-primary:hover {
    background-color: var(--ui-primary-hover);
    border-color: var(--ui-primary-hover);
    color: #fff;
}

.btn-default,
.btn-secondary {
    background: var(--ui-surface);
    border-color: var(--ui-border);
    color: var(--ui-text-secondary);
}

.btn-default:hover,
.btn-secondary:hover {
    background: var(--ui-surface-soft);
    border-color: #d0d5dd;
    color: var(--ui-text);
}

.btn-danger {
    background: var(--ui-danger);
    border-color: var(--ui-danger);
    color: #fff;
}

.btn-success {
    background: var(--ui-success);
    border-color: var(--ui-success);
    color: #fff;
}

.btn-warning {
    background: var(--ui-warning);
    border-color: var(--ui-warning);
    color: #fff;
}

.btn-link {
    color: var(--ui-primary);
}

/* ------------------------------------------------------------
   Forms
   ------------------------------------------------------------ */
.form-control,
.form-select,
select.form-control,
textarea.form-control,
input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
input[type="search"],
input[type="tel"],
input[type="url"] {
    min-height: var(--ui-control-h);
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-sm);
    background: var(--ui-surface);
    color: var(--ui-text);
    box-shadow: none;
    transition: border-color var(--ui-transition), box-shadow var(--ui-transition), background-color var(--ui-transition);
}

.form-control:hover,
.form-select:hover {
    border-color: #cfd4dc;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--ui-primary);
    box-shadow: 0 0 0 3px var(--ui-focus-ring);
}

.form-control[disabled],
.form-control[readonly],
.form-select[disabled] {
    background: #f2f4f7;
    color: var(--ui-text-muted);
    cursor: not-allowed;
}

label {
    color: var(--ui-text-secondary);
    font-weight: 600;
}

.form-group {
    margin-bottom: 16px;
}

.has-error .form-control,
.has-error .form-select {
    border-color: var(--ui-danger);
}

.has-error .help-block,
.text-danger {
    color: var(--ui-danger);
}

/* ------------------------------------------------------------
   Select2 — preserve plugin behavior, improve visual layer
   ------------------------------------------------------------ */
.select2-container .select2-selection--single,
.select2-container .select2-selection--multiple {
    min-height: var(--ui-control-h);
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-sm);
    background: var(--ui-surface);
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default .select2-selection--single:focus {
    border-color: var(--ui-primary);
    box-shadow: 0 0 0 3px var(--ui-focus-ring);
}

.select2-dropdown {
    border-color: var(--ui-border);
    border-radius: var(--ui-radius-sm);
    box-shadow: var(--ui-shadow-md);
    overflow: hidden;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: color-mix(in srgb, var(--ui-primary) 10%, transparent);
    color: var(--ui-primary);
}

/* ------------------------------------------------------------
   Tables / DataTables
   ------------------------------------------------------------ */
.table,
.dataTable {
    color: var(--ui-text);
}

.table > thead > tr > th,
.dataTable > thead > tr > th {
    background: var(--ui-surface-soft);
    color: var(--ui-text-secondary);
    border-bottom: 1px solid var(--ui-border);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: none;
    white-space: nowrap;
}

.table > tbody > tr > td,
.dataTable > tbody > tr > td {
    border-top-color: var(--ui-border-subtle);
    vertical-align: middle;
}

.table > tbody > tr:hover > td,
.dataTable > tbody > tr:hover > td {
    background: color-mix(in srgb, var(--ui-primary) 2.5%, var(--ui-surface));
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-sm);
    min-height: var(--ui-control-h-sm);
    background: var(--ui-surface);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--ui-primary);
    border-color: var(--ui-primary);
    color: #fff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: color-mix(in srgb, var(--ui-primary) 8%, transparent);
    border-color: color-mix(in srgb, var(--ui-primary) 20%, transparent);
    color: var(--ui-primary) !important;
}

/* ------------------------------------------------------------
   Alerts / statuses
   ------------------------------------------------------------ */
.alert {
    border-radius: var(--ui-radius-md);
    border-width: 1px;
    box-shadow: none;
}

.label,
.badge {
    border-radius: 999px;
    font-weight: 650;
    letter-spacing: .01em;
}

.bg-success,
.label-success {
    background-color: var(--ui-success) !important;
}

.bg-warning,
.label-warning {
    background-color: var(--ui-warning) !important;
}

.bg-danger,
.label-danger {
    background-color: var(--ui-danger) !important;
}

.label-primary,
.badge-primary {
    background-color: var(--ui-primary) !important;
}

/* ------------------------------------------------------------
   Dropdowns / popovers
   ------------------------------------------------------------ */
.dropdown-menu,
.popover {
    border: 1px solid var(--ui-border);
    box-shadow: var(--ui-shadow-md);
    padding: 6px;
}

.dropdown-menu > li > a,
.dropdown-menu .dropdown-item {
    border-radius: var(--ui-radius-xs);
    color: var(--ui-text-secondary);
    padding: 8px 10px;
}

.dropdown-menu > li > a:hover,
.dropdown-menu > li > a:focus,
.dropdown-menu .dropdown-item:hover,
.dropdown-menu .dropdown-item:focus {
    background: color-mix(in srgb, var(--ui-primary) 7%, transparent);
    color: var(--ui-primary);
}

/* ------------------------------------------------------------
   Modals
   ------------------------------------------------------------ */
.modal-content {
    overflow: hidden;
    border: 1px solid var(--ui-border);
    box-shadow: 0 20px 50px rgba(16, 24, 40, .14);
}

.modal-header,
.modal-footer {
    border-color: var(--ui-border-subtle);
}

.modal-title {
    font-weight: 700;
    color: var(--ui-text);
}

/* ------------------------------------------------------------
   Tabs / nav
   ------------------------------------------------------------ */
.nav-tabs {
    border-bottom-color: var(--ui-border);
}

.nav-tabs > li > a {
    border: 0;
    color: var(--ui-text-muted);
    font-weight: 600;
    border-bottom: 2px solid transparent;
}

.nav-tabs > li > a:hover {
    color: var(--ui-primary);
    background: transparent;
}

.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover,
.nav-tabs > li.active > a:focus {
    color: var(--ui-primary);
    background: transparent;
    border: 0;
    border-bottom: 2px solid var(--ui-primary);
}

/* ------------------------------------------------------------
   Dashboard cards / KPI surfaces
   ------------------------------------------------------------ */
.dashboard .box,
.dashboard .card,
.dashboard .info-box {
    min-height: 100%;
}

.dashboard .box-header,
.dashboard .card-header {
    padding: 14px 16px;
}

.dashboard .box-body,
.dashboard .card-body {
    padding: 16px;
}

.dashboard .info-box {
    border: 1px solid var(--ui-border);
    background: var(--ui-surface);
}

.dashboard .info-box-icon {
    border-radius: var(--ui-radius-md);
}

/* ------------------------------------------------------------
   POS: dense, fast, touch-friendly — no JS/DOM assumptions
   ------------------------------------------------------------ */
.pos .btn,
#pos-form .btn,
#pos-form .form-control,
#pos-form .select2-container .select2-selection--single {
    min-height: 40px;
}

#pos-form .table > tbody > tr > td {
    padding-top: 7px;
    padding-bottom: 7px;
}

#pos-form .box,
#pos-form .panel {
    box-shadow: var(--ui-shadow-xs);
}

#pos-form .box-header,
#pos-form .panel-heading {
    padding: 10px 14px;
}

#pos-form .box-body,
#pos-form .panel-body {
    padding: 12px;
}

/* Keep POS totals visually dominant without changing their values. */
#pos-form .pos-total,
#pos-form .total,
#pos-form .final-total {
    font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------
   Pagination / navigation controls
   ------------------------------------------------------------ */
.pagination > li > a,
.pagination > li > span {
    min-width: 32px;
    min-height: 32px;
    border-color: var(--ui-border);
    color: var(--ui-text-secondary);
}

.pagination > .active > a,
.pagination > .active > span,
.pagination > .active > a:hover,
.pagination > .active > span:hover {
    background-color: var(--ui-primary);
    border-color: var(--ui-primary);
    color: #fff;
}

/* ------------------------------------------------------------
   File uploads / checkboxes / radios
   ------------------------------------------------------------ */
input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--ui-primary);
}

.custom-file-input:focus,
input[type="file"]:focus {
    outline: 2px solid var(--ui-focus-ring);
    outline-offset: 2px;
}

/* ------------------------------------------------------------
   Scrollbars — subtle, never hide them
   ------------------------------------------------------------ */
* {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

/* ------------------------------------------------------------
   Responsive
   ------------------------------------------------------------ */
@media (max-width: 1199px) {
    :root {
        --ui-sidebar-w: 220px;
    }
}

@media (max-width: 991px) {
    .box-header,
    .panel-heading,
    .card-header {
        padding: 12px 14px;
    }

    .box-body,
    .panel-body,
    .card-body {
        padding: 14px;
    }

    .table-responsive {
        border: 0;
    }
}

@media (max-width: 767px) {
    :root {
        --ui-control-h: 40px;
        --ui-header-h: 56px;
    }

    .btn {
        min-height: 40px;
    }

    .modal-dialog {
        margin: 10px;
    }

    .table > thead > tr > th,
    .dataTable > thead > tr > th {
        font-size: 11px;
    }

    #pos-form .btn,
    #pos-form .form-control {
        min-height: 42px;
    }
}

/* ------------------------------------------------------------
   RTL-safe layout helpers
   ------------------------------------------------------------ */
[dir="rtl"] #side-bar .theme-sidebar-active,
[dir="rtl"] .main-sidebar .sidebar-menu > li.active > a {
    box-shadow: inset -3px 0 0 var(--ui-primary);
}

[dir="rtl"] .dropdown-menu {
    text-align: start;
}

/* ------------------------------------------------------------
   Print — do not interfere with existing print contracts
   ------------------------------------------------------------ */
@media print {
    body,
    .content-wrapper,
    .right_col,
    .main-content {
        background: #fff !important;
    }

    .box,
    .panel,
    .card,
    .modal-content {
        box-shadow: none !important;
    }
}

/* ------------------------------------------------------------
   Accessibility / reduced motion
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }

    .btn:hover {
        transform: none;
    }
}
