/*
 * ASHOKA - UI v3 layer (loaded last, after style.css / app-shell.css / ui-motion.css)
 *
 *  1. Design tokens + global polish (focus rings, scrollbars, tabular numbers, print)
 *  2. Navbar tools: quick search (Ctrl+K) and theme toggle
 *  3. Page header: breadcrumb strip
 *  4. Command palette, shortcut sheet, confirm dialog, back-to-top
 *  5. Component polish: tables, forms, modals, alerts, badges, DataTables
 *  6. Dark theme (html[data-bs-theme="dark"]) for the glass "fashion" theme
 *
 * Nothing here changes what a page submits; it only changes how it looks and feels.
 */

/* ============================== 1. Tokens & global polish ============================== */
:root {
    --v3-radius-xs: 8px;
    --v3-radius-sm: 12px;
    --v3-radius: 18px;
    --v3-radius-lg: 24px;
    --v3-ring: 0 0 0 3px rgba(240, 196, 25, 0.45);
    --v3-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    --v3-surface: rgba(255, 255, 255, 0.72);
    --v3-surface-2: rgba(255, 255, 255, 0.55);
    --v3-ink: #0b1220;
    --v3-ink-muted: rgba(11, 18, 32, 0.6);
    --v3-line: rgba(16, 24, 40, 0.1);
    --v3-shadow: 0 24px 60px rgba(2, 8, 23, 0.22);
    --v3-shadow-sm: 0 10px 26px rgba(2, 8, 23, 0.12);
    --v3-accent: #f7df4c;
    --v3-accent-deep: #f0c419;
    scroll-behavior: smooth;
}

/* Keyboard users get one consistent ring everywhere */
.theme-fashion :is(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: none !important;
    box-shadow: var(--v3-ring) !important;
    border-radius: var(--v3-radius-xs);
}
.theme-fashion .btn:focus-visible,
.theme-fashion .form-control:focus-visible,
.theme-fashion .form-select:focus-visible {
    border-radius: inherit;
}

/* "Skip to content" for keyboard / screen-reader users */
.app-skip-link {
    position: absolute;
    top: -100px;
    left: 1rem;
    z-index: 3000;
    padding: 0.6rem 1rem;
    border-radius: var(--v3-radius-sm);
    background: var(--v3-ink);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    transition: top 0.2s var(--v3-ease);
}
.app-skip-link:focus {
    top: 0.75rem;
    color: #fff;
}

/* Money and counts line up in tables and KPI tiles */
.theme-fashion .table td,
.theme-fashion .table th,
.theme-fashion .h4,
.theme-fashion .fs-3,
.theme-fashion .fs-4,
.theme-fashion .metric-value {
    font-variant-numeric: tabular-nums;
}

/* Thin, theme-coloured scrollbars */
.theme-fashion ::-webkit-scrollbar { width: 10px; height: 10px; }
.theme-fashion ::-webkit-scrollbar-track { background: transparent; }
.theme-fashion ::-webkit-scrollbar-thumb {
    background: rgba(11, 18, 32, 0.18);
    border: 3px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
}
.theme-fashion ::-webkit-scrollbar-thumb:hover { background-color: rgba(11, 18, 32, 0.32); }

/* Page content settles in (pure CSS, works without JS) */
.theme-fashion #app-main {
    animation: v3-page-in 0.28s var(--v3-ease) backwards;
}
@keyframes v3-page-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* Number inputs: no browser spinners (they were tiny and easy to mis-tap) */
.theme-fashion input[type="number"]::-webkit-outer-spin-button,
.theme-fashion input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.theme-fashion input[type="number"] { -moz-appearance: textfield; }

/* Print: only the page content */
@media print {
    .app-navbar, .app-bottom-nav, .app-bottom-nav-spacer, .app-backtop, .app-cmdk,
    .app-breadcrumb, .footer, #app-toasts, #app-progress, .page-actions, .app-skip-link {
        display: none !important;
    }
    .theme-fashion .app-frame::before { display: none !important; }
    .theme-fashion .card { box-shadow: none !important; backdrop-filter: none !important; background: #fff !important; }
}

/* ============================== 2. Navbar tools ============================== */
.app-nav-tools {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: auto;
    margin-right: 0.5rem;
}
/* Desktop: brand | centre menu | user chips | tools  (tools go after the collapsed block) */
@media (min-width: 992px) {
    .app-navbar .container-fluid > .navbar-collapse { order: 2; }
    .app-navbar .container-fluid > .app-nav-tools { order: 3; margin-left: 0.5rem; margin-right: 0; }
}
.app-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    height: 38px;
    min-width: 38px;
    padding: 0 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.5);
    color: var(--v3-ink);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.18s ease, transform 0.15s ease, box-shadow 0.18s ease;
}
.app-tool-btn:hover { background: rgba(255, 255, 255, 0.85); box-shadow: var(--v3-shadow-sm); }
.app-tool-btn:active { transform: scale(0.96); }
.app-tool-btn kbd {
    padding: 0.05em 0.4em;
    border-radius: 6px;
    border: 1px solid rgba(11, 18, 32, 0.15);
    border-bottom-width: 2px;
    background: #fff;
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 700;
    color: rgba(11, 18, 32, 0.7);
}
.app-tool-btn .app-tool-label { white-space: nowrap; }
@media (max-width: 991.98px) {
    .app-nav-tools { margin: 0.5rem 0; }
    .app-tool-btn kbd { display: none; }
}
/* Theme toggle icon swap */
.app-theme-toggle .fa-moon { display: inline; }
.app-theme-toggle .fa-sun { display: none; }
html[data-bs-theme="dark"] .app-theme-toggle .fa-moon { display: none; }
html[data-bs-theme="dark"] .app-theme-toggle .fa-sun { display: inline; }
.app-theme-toggle i { transition: transform 0.4s var(--v3-ease); }
.app-theme-toggle:hover i { transform: rotate(-20deg) scale(1.1); }
/* Appearance options in the user menu */
.dropdown-item.app-theme-option .app-theme-check { margin-left: auto; opacity: 0; }
.dropdown-item.app-theme-option.is-active .app-theme-check { opacity: 1; }
.dropdown-item.app-theme-option { display: flex; align-items: center; }

/* ============================== 3. Breadcrumb strip ============================== */
.app-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--v3-ink-muted);
}
.app-breadcrumb a {
    color: inherit;
    text-decoration: none;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.45);
    transition: background-color 0.15s ease, color 0.15s ease;
}
.app-breadcrumb a:hover { background: rgba(255, 255, 255, 0.85); color: var(--v3-ink); }
.app-breadcrumb .sep { opacity: 0.45; }
.app-breadcrumb .current { color: var(--v3-ink); }
.app-page-header { gap: 0.75rem 1rem; }
.app-page-header .page-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }

/* ============================== 4. Overlays ============================== */
/* --- Command palette --- */
.app-cmdk {
    position: fixed;
    inset: 0;
    z-index: 2200;
    display: grid;
    place-items: start center;
    padding: min(12vh, 120px) 1rem 1rem;
}
.app-cmdk[hidden] { display: none; }
.app-cmdk-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(11, 18, 32, 0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: app-fade 0.2s ease backwards;
}
.app-cmdk-panel {
    position: relative;
    width: min(640px, 100%);
    border-radius: var(--v3-radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.8);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.86));
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    box-shadow: var(--v3-shadow);
    overflow: hidden;
    animation: app-pop 0.28s var(--v3-ease) backwards;
}
.app-cmdk-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid var(--v3-line);
}
.app-cmdk-input-wrap i { color: var(--v3-ink-muted); }
.app-cmdk-input-wrap input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--v3-ink);
}
.app-cmdk-input-wrap input:focus-visible { box-shadow: none !important; }
.app-cmdk-input-wrap kbd {
    padding: 0.15em 0.5em;
    border-radius: 6px;
    border: 1px solid rgba(11, 18, 32, 0.15);
    background: #fff;
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--v3-ink-muted);
}
.app-cmdk-list {
    max-height: min(52vh, 420px);
    overflow-y: auto;
    padding: 0.5rem;
}
.app-cmdk-group {
    padding: 0.55rem 0.75rem 0.25rem;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--v3-ink-muted);
}
.app-cmdk-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
    padding: 0.62rem 0.75rem;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--v3-ink);
    text-align: left;
    font-weight: 600;
    cursor: pointer;
}
.app-cmdk-item i {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(11, 18, 32, 0.06);
    color: var(--v3-ink-muted);
    font-size: 0.85rem;
}
.app-cmdk-item .app-cmdk-sub { margin-left: auto; font-size: 0.72rem; font-weight: 600; color: var(--v3-ink-muted); }
.app-cmdk-item[aria-selected="true"],
.app-cmdk-item:hover {
    background: rgba(247, 223, 76, 0.32);
}
.app-cmdk-item[aria-selected="true"] i { background: rgba(255, 255, 255, 0.8); color: var(--v3-ink); }
.app-cmdk-item mark { background: transparent; color: inherit; font-weight: 800; padding: 0; text-decoration: underline; text-decoration-color: var(--v3-accent-deep); text-underline-offset: 2px; }
.app-cmdk-empty { padding: 1.5rem; text-align: center; color: var(--v3-ink-muted); font-weight: 600; }
.app-cmdk-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    padding: 0.6rem 1.1rem;
    border-top: 1px solid var(--v3-line);
    font-size: 0.72rem;
    color: var(--v3-ink-muted);
}
.app-cmdk-foot kbd {
    padding: 0.05em 0.4em;
    border-radius: 5px;
    border: 1px solid rgba(11, 18, 32, 0.15);
    background: #fff;
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--v3-ink);
}
/* --- Shortcut sheet (reuses the palette shell) --- */
.app-shortcuts { padding: 0.5rem 1.1rem 1rem; }
.app-shortcuts h6 { margin: 0.75rem 0 0.4rem; font-weight: 800; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--v3-ink-muted); }
.app-shortcut-row { display: flex; align-items: center; justify-content: space-between; padding: 0.4rem 0; border-bottom: 1px dashed var(--v3-line); font-weight: 600; }
.app-shortcut-row:last-child { border-bottom: 0; }
.app-shortcut-row kbd { margin-left: 0.25rem; padding: 0.1em 0.5em; border-radius: 6px; border: 1px solid rgba(11, 18, 32, 0.15); border-bottom-width: 2px; background: #fff; font-family: inherit; font-size: 0.75rem; font-weight: 700; }

/* --- Confirm dialog --- */
.app-confirm .modal-content { border-radius: var(--v3-radius-lg); }
.app-confirm .app-confirm-icon {
    width: 52px; height: 52px; margin-bottom: 0.75rem;
    display: grid; place-items: center; border-radius: 16px;
    background: rgba(247, 223, 76, 0.4); color: var(--v3-ink); font-size: 1.3rem;
}
.app-confirm.is-danger .app-confirm-icon { background: rgba(220, 53, 69, 0.14); color: #dc3545; }

/* --- Back to top --- */
.app-backtop {
    position: fixed;
    right: 1rem;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    z-index: 1025;
    width: 44px; height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    color: var(--v3-ink);
    box-shadow: var(--v3-shadow-sm);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    opacity: 0;
    transform: translateY(12px) scale(0.9);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s var(--v3-ease);
}
.app-backtop.is-visible { opacity: 1; transform: none; pointer-events: auto; }
@media (max-width: 991.98px) {
    .app-backtop { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
    body.has-pos-paybar .app-backtop { display: none; }
}

/* ============================== 5. Component polish ============================== */
/* Tables: clearer header, calmer zebra, sticky header when the wrapper scrolls */
.theme-fashion .table thead th {
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--v3-ink-muted);
    border-bottom-width: 1px;
}
.theme-fashion .table-responsive { border-radius: var(--v3-radius-sm); }
.theme-fashion .table-responsive[style*="max-height"] thead th,
.theme-fashion .app-table-scroll thead th { position: sticky; top: 0; z-index: 2; backdrop-filter: blur(10px); }
.theme-fashion .table > :not(caption) > * > * { background-color: transparent; }
.theme-fashion .table-striped > tbody > tr:nth-of-type(odd) > * { background-color: rgba(255, 255, 255, 0.22); }
.theme-fashion .table tbody tr { transition: background-color 0.12s ease; }
.theme-fashion .table .btn-sm { padding: 0.28rem 0.65rem; font-size: 0.78rem; }

/* Cards: header title weight, footer */
.theme-fashion .card-header { font-weight: 700; }
.theme-fashion .card-footer { background: transparent; border-top: 1px solid var(--v3-line); }
.theme-fashion .card .card { box-shadow: none; }

/* Forms: labels, placeholders, invalid state, larger touch targets on phones */
/* style.css sets `background:` shorthand on .form-select, which wiped Bootstrap's chevron */
.theme-fashion .form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%230b1220' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    padding-right: 2.25rem;
}
.theme-fashion .form-label { font-weight: 700; font-size: 0.85rem; color: rgba(11, 18, 32, 0.78); }
.theme-fashion .form-text { color: var(--v3-ink-muted); }
.theme-fashion .form-control::placeholder { color: rgba(11, 18, 32, 0.38); }
.theme-fashion .form-control.is-invalid,
.theme-fashion .form-select.is-invalid { border-color: #dc3545; box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.15); animation: v3-shake 0.35s ease; }
.theme-fashion .form-check-input:checked { background-color: var(--v3-ink); border-color: var(--v3-ink); }
.theme-fashion .form-switch .form-check-input:checked { background-color: #198754; border-color: #198754; }
@keyframes v3-shake { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* Buttons: icon spacing, "soft" variants for secondary actions */
.theme-fashion .btn > i:first-child:not(:only-child) { margin-right: 0.35rem; }
.theme-fashion .btn-light { background: rgba(255, 255, 255, 0.7); border-color: rgba(255, 255, 255, 0.8); }
.theme-fashion .btn-link { backdrop-filter: none; font-weight: 700; text-decoration: none; }
.theme-fashion .btn-link:hover { text-decoration: underline; }

/* Modals & alerts: same glass language as the cards */
.theme-fashion .modal-content {
    border-radius: var(--v3-radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.8);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(255, 255, 255, 0.92));
    box-shadow: var(--v3-shadow);
}
.theme-fashion .modal-header { border-bottom: 1px solid var(--v3-line); }
.theme-fashion .modal-footer { border-top: 1px solid var(--v3-line); }
.theme-fashion .modal-title { font-weight: 800; letter-spacing: -0.02em; }
.theme-fashion .modal.fade .modal-dialog { transition: transform 0.25s var(--v3-ease), opacity 0.2s ease; transform: translateY(14px) scale(0.98); }
.theme-fashion .modal.show .modal-dialog { transform: none; }
.theme-fashion .alert { border-radius: var(--v3-radius-sm); border: 1px solid transparent; font-weight: 500; }
.theme-fashion .badge { font-weight: 700; letter-spacing: 0.01em; }
.theme-fashion .badge.rounded-pill { padding: 0.35em 0.7em; }
.theme-fashion .list-group-item { background: transparent; border-color: var(--v3-line); }
.theme-fashion .nav-tabs { border-bottom: 1px solid var(--v3-line); }
.theme-fashion .nav-tabs .nav-link { border: 0; border-bottom: 2px solid transparent; border-radius: 0; font-weight: 700; color: var(--v3-ink-muted); }
.theme-fashion .nav-tabs .nav-link.active { color: var(--v3-ink); background: transparent; border-bottom-color: var(--v3-accent-deep); }
.theme-fashion .nav-pills .nav-link { border-radius: 999px; font-weight: 700; }
.theme-fashion .nav-pills .nav-link.active { background: var(--v3-ink); }
.theme-fashion .dropdown-menu { border-radius: var(--v3-radius-sm); border: 1px solid rgba(255, 255, 255, 0.7); box-shadow: var(--v3-shadow); padding: 0.4rem; }
.theme-fashion .dropdown-item { border-radius: 10px; font-weight: 600; padding: 0.5rem 0.75rem; }
.theme-fashion .dropdown-item.active, .theme-fashion .dropdown-item:active { background: rgba(247, 223, 76, 0.4); color: var(--v3-ink); }
.theme-fashion .tooltip-inner { border-radius: 10px; font-weight: 600; }

/* DataTables controls */
.theme-fashion .dataTables_wrapper .dataTables_filter input {
    border-radius: 999px;
    border: 1px solid var(--v3-line);
    background: rgba(255, 255, 255, 0.6);
    padding: 0.4rem 0.9rem;
    min-width: 220px;
}
.theme-fashion .dataTables_wrapper .dataTables_length select { border-radius: 999px; }
.theme-fashion .dataTables_wrapper .dataTables_info { color: var(--v3-ink-muted); font-size: 0.82rem; }
.theme-fashion .dataTables_wrapper .dataTables_processing {
    border-radius: var(--v3-radius-sm);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--v3-shadow-sm);
    font-weight: 700;
}

/* Empty rows / no data */
.theme-fashion .table td.dataTables_empty { padding: 2rem; color: var(--v3-ink-muted); font-weight: 600; }

/* Phones: style.css used to hide every table's 3rd and 4th column (on a sales list that
   is the customer and the amount) and force every column class to full width. Tables now
   scroll sideways inside .table-responsive (ui-v3.js wraps bare tables), and two-up /
   three-up grids written with .col-6 / .col-4 keep their layout. */
@media (max-width: 768px) {
    .theme-fashion .table th:nth-child(2),
    .theme-fashion .table td:nth-child(2),
    .theme-fashion .table th:nth-child(3),
    .theme-fashion .table td:nth-child(3),
    .theme-fashion .table th:nth-child(4),
    .theme-fashion .table td:nth-child(4),
    .theme-fashion .table th:nth-child(5),
    .theme-fashion .table td:nth-child(5) { display: table-cell; }
    .theme-fashion .table th,
    .theme-fashion .table td { min-width: 0; padding: 0.55rem 0.5rem; white-space: nowrap; }
    .theme-fashion .table td.text-wrap, .theme-fashion .table th.text-wrap { white-space: normal; }
    .theme-fashion .row > .col-6 { width: 50% !important; }
    .theme-fashion .row > .col-4 { width: 33.3333% !important; }
    .theme-fashion .row > .col-8 { width: 66.6667% !important; }
    .theme-fashion .row > .col-3 { width: 25% !important; }
    .theme-fashion .row > .col-auto { width: auto !important; }
    .theme-fashion .row.g-2 > [class*="col-"],
    .theme-fashion .row.g-3 > [class*="col-"] { margin-bottom: 0 !important; }
    .theme-fashion .app-page-header { flex-direction: column; align-items: flex-start !important; }
    .theme-fashion .app-page-header .page-actions { width: 100%; }
    .theme-fashion .app-page-header .page-actions .btn { flex: 1 1 auto; }
    .theme-fashion h1.h2 { font-size: 1.55rem; }
}

/* ============================== 6. Dark theme ==============================
   Moved to ui-v4.css, where dark mode is a variable swap instead of per-component overrides. */

/* Reduced motion: keep the layer calm */
@media (prefers-reduced-motion: reduce) {
    .theme-fashion #app-main,
    .app-cmdk-backdrop,
    .app-cmdk-panel,
    .theme-fashion .form-control.is-invalid,
    .theme-fashion .form-select.is-invalid { animation: none !important; }
    .app-backtop, .app-tool-btn, .app-theme-toggle i, .theme-fashion .modal.fade .modal-dialog { transition: none !important; }
}
