/* ============================================================================
 * Zion — back-office UI modernisation + responsive fixes
 *
 * Loaded after app.css so it can override. Deliberately COLOUR-NEUTRAL: this
 * install is multi-tenant and each business picks its own theme colour, so
 * this file only touches shape, spacing, typography, touch targets and
 * overflow — never hue. Every business keeps its own colours.
 *
 * SCOPE: everything is under `body.sidebar-mini` (the back office). The POS
 * touch screen uses `body.lockscreen`, so it is never affected by this file.
 * ==========================================================================*/

body.sidebar-mini {
    --z-radius: 10px;
    --z-radius-sm: 8px;
    --z-shadow: 0 1px 2px rgba(16, 35, 63, .06), 0 4px 16px rgba(16, 35, 63, .06);
    --z-shadow-hover: 0 2px 6px rgba(16, 35, 63, .09), 0 10px 28px rgba(16, 35, 63, .10);
    --z-border: #e5eaf2;
    --z-ink-soft: #5b6b83;
}

/* ---------------------------------------------------------------- cards */

body.sidebar-mini .box,
body.sidebar-mini .small-box,
body.sidebar-mini .info-box,
body.sidebar-mini .nav-tabs-custom {
    border-radius: var(--z-radius);
    border: 1px solid var(--z-border);
    box-shadow: var(--z-shadow);
    overflow: hidden;
}

body.sidebar-mini .box:hover,
body.sidebar-mini .small-box:hover {
    box-shadow: var(--z-shadow-hover);
}

/* AdminLTE draws a heavy coloured 3px rule on top of every box. Softer. */
body.sidebar-mini .box.box-primary,
body.sidebar-mini .box.box-info,
body.sidebar-mini .box.box-success,
body.sidebar-mini .box.box-warning,
body.sidebar-mini .box.box-danger {
    border-top-width: 2px;
}

body.sidebar-mini .box-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--z-border);
}

body.sidebar-mini .box-header .box-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

body.sidebar-mini .box-body {
    padding: 16px;
}

/* Dashboard stat tiles: stop the labels truncating to "New Subs..." */
body.sidebar-mini .small-box h3,
body.sidebar-mini .small-box p,
body.sidebar-mini .info-box-text,
body.sidebar-mini .info-box-number,
body.sidebar-mini .description-block > .description-text {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    word-break: break-word;
}

body.sidebar-mini .small-box h3 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

/* ------------------------------------------------------------- buttons */

body.sidebar-mini .btn {
    border-radius: var(--z-radius-sm);
    font-weight: 600;
    transition: filter .12s ease, box-shadow .12s ease;
}

body.sidebar-mini .btn:hover:not(:disabled) {
    filter: brightness(1.05);
}

body.sidebar-mini .btn:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* ------------------------------------------------------- forms & inputs */

body.sidebar-mini .form-control,
body.sidebar-mini .select2-container .select2-selection--single {
    border-radius: var(--z-radius-sm);
    border-color: #d7dfea;
    box-shadow: none;
    min-height: 38px;
}

body.sidebar-mini .form-control:focus {
    border-color: #9db4d8;
    box-shadow: 0 0 0 3px rgba(90, 130, 200, .15);
}

/* BUG FIX: unstyled file inputs render ~1833px wide and blow out the page
   (seen on Business Settings → business_logo). */
body.sidebar-mini input[type="file"] {
    max-width: 100%;
    width: 100%;
    display: block;
    font-size: 13px;
}

/* Long values inside form groups shouldn't force the row wider */
body.sidebar-mini .form-group,
body.sidebar-mini .form-group > * {
    min-width: 0;
}

/* --------------------------------------------------- tables & overflow */

/* Wide data tables must scroll inside their own box, never stretch the page,
   and should scroll smoothly under a finger. */
body.sidebar-mini .table-responsive,
body.sidebar-mini .dataTables_wrapper,
body.sidebar-mini .dataTables_scrollBody,
body.sidebar-mini .dataTables_scroll {
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

body.sidebar-mini .table-responsive {
    overflow-x: auto;
    border-radius: var(--z-radius-sm);
}

body.sidebar-mini .table > thead > tr > th {
    border-bottom: 2px solid var(--z-border);
    font-size: 12.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .02em;
    color: var(--z-ink-soft);
    white-space: nowrap;
}

body.sidebar-mini .table > tbody > tr > td {
    vertical-align: middle;
    padding: 10px 8px;
}

body.sidebar-mini .table > tbody > tr:hover > td {
    background: #f7f9fc;
}

/* ------------------------------------------------------------- sidebar */

body.sidebar-mini .side-bar a,
body.sidebar-mini #side-bar a {
    border-radius: var(--z-radius-sm);
    transition: background-color .12s ease;
}

/* ==========================================================================
   TABLET  (<= 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
    body.sidebar-mini .box-body { padding: 14px; }
    body.sidebar-mini .content,
    body.sidebar-mini .content-wrapper { padding-left: 12px; padding-right: 12px; }

    /* Filter/action rows wrap instead of squeezing */
    body.sidebar-mini .box-header .box-tools { position: static; float: none; margin-top: 8px; }
}

/* ==========================================================================
   MOBILE  (<= 767px)
   ========================================================================== */
@media (max-width: 767px) {
    /* Comfortable touch targets — 40px minimum */
    body.sidebar-mini .btn,
    body.sidebar-mini .form-control,
    body.sidebar-mini .select2-container .select2-selection--single {
        min-height: 42px;
    }

    body.sidebar-mini .btn-xs,
    body.sidebar-mini .btn-sm {
        min-height: 36px;
        padding: 7px 12px;
        font-size: 13px;
    }

    /* Action buttons in table rows: stop them stacking into a thin column */
    body.sidebar-mini td .btn + .btn { margin-top: 4px; }

    /* Cards go edge-to-edge and lose the heavy chrome */
    body.sidebar-mini .box,
    body.sidebar-mini .small-box,
    body.sidebar-mini .info-box {
        margin-bottom: 12px;
        border-radius: var(--z-radius-sm);
    }

    body.sidebar-mini .box-body { padding: 12px; }
    body.sidebar-mini .box-header { padding: 12px; }

    body.sidebar-mini .content,
    body.sidebar-mini .content-wrapper {
        padding-left: 10px;
        padding-right: 10px;
    }

    /* Page headings scale down instead of wrapping awkwardly */
    body.sidebar-mini .content-header > h1,
    body.sidebar-mini .content-header h1 {
        font-size: 20px;
        line-height: 1.25;
    }

    /* Wide tables: make it obvious they scroll sideways */
    body.sidebar-mini .table-responsive {
        position: relative;
        background:
            linear-gradient(to right, #fff 30%, rgba(255,255,255,0)) left center / 28px 100% no-repeat,
            linear-gradient(to left,  #fff 30%, rgba(255,255,255,0)) right center / 28px 100% no-repeat,
            radial-gradient(farthest-side at 0 50%, rgba(16,35,63,.14), transparent) left center / 12px 100% no-repeat,
            radial-gradient(farthest-side at 100% 50%, rgba(16,35,63,.14), transparent) right center / 12px 100% no-repeat;
        background-attachment: local, local, scroll, scroll;
    }

    body.sidebar-mini .table > tbody > tr > td,
    body.sidebar-mini .table > thead > tr > th {
        padding: 9px 8px;
        font-size: 13px;
    }

    /* Filter panels stack cleanly */
    body.sidebar-mini .box-header .box-tools .btn { width: 100%; margin: 3px 0; }

    /* DataTables controls stop colliding on narrow screens */
    body.sidebar-mini .dataTables_wrapper .dataTables_filter,
    body.sidebar-mini .dataTables_wrapper .dataTables_length,
    body.sidebar-mini .dataTables_wrapper .dataTables_info,
    body.sidebar-mini .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        text-align: left !important;
        width: 100%;
        margin-bottom: 8px;
    }

    body.sidebar-mini .dataTables_wrapper .dataTables_filter input {
        width: 100%;
        margin-left: 0;
    }

    /* Modals use the full screen rather than a cramped centred box */
    body.sidebar-mini .modal-dialog {
        margin: 8px;
        width: auto;
    }

    /* Settings-style vertical tab rails sit in a col-xs-2 (~17% of a phone),
       which truncates every label to "Busine" / "Dashboa". On mobile turn the
       rail into a full-width horizontal strip that scrolls. */
    body.sidebar-mini .pos-tab-menu {
        width: 100% !important;
        max-width: 100% !important;
        float: none !important;
        margin-bottom: 12px;
        padding: 0;
    }

    /* the .list-group is the real list — make IT the horizontal scroller */
    body.sidebar-mini .pos-tab-menu .list-group {
        display: flex;
        flex-wrap: nowrap;
        gap: 6px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        margin: 0;
        padding-bottom: 2px;
    }
    body.sidebar-mini .pos-tab-menu .list-group::-webkit-scrollbar { display: none; }

    body.sidebar-mini .pos-tab-menu .list-group > .list-group-item {
        flex: 0 0 auto;
        width: auto !important;
        float: none !important;
        white-space: nowrap;
        overflow: visible;
        text-overflow: clip;
        border-radius: var(--z-radius-sm) !important;
        border: 1px solid var(--z-border);
        padding: 9px 14px;
    }

    /* the content column next to that rail takes the full width */
    body.sidebar-mini .pos-tab-menu + [class*="col-"] {
        width: 100% !important;
        float: none !important;
    }

    /* Tab strips scroll instead of wrapping into a tall stack */
    body.sidebar-mini .nav-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    body.sidebar-mini .nav-tabs::-webkit-scrollbar { display: none; }
    body.sidebar-mini .nav-tabs > li { float: none; flex: 0 0 auto; }
}

/* ==========================================================================
   SMALL PHONES  (<= 400px)
   ========================================================================== */
@media (max-width: 400px) {
    body.sidebar-mini .small-box h3 { font-size: 22px; }
    body.sidebar-mini .content-header > h1 { font-size: 18px; }
}

/* ------------------------------------------------------------- printing */
@media print {
    body.sidebar-mini .box,
    body.sidebar-mini .small-box {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
