/* =========================================================
   ROOT VARIABLES
========================================================= */
:root{
    --sidebar-width: 250px;
    --header-height: 70px;
    --border-color: #e5e7eb;
    --text-color: #111827;
    --muted-color: #6b7280;
    --bg-color: #ffffff;
    --bg-soft: #f8f9fa;
    --hover-bg: #f3f4f6;
    --active-bg: #eef2ff;
    --shadow-soft: 0 8px 24px rgba(0,0,0,0.06);
    --transition: 0.25s ease;
}

/* =========================================================
   RESET
========================================================= */
*,
*::before,
*::after{
    box-sizing: border-box;
}

html,
body{
    width: 100%;
    min-height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    background: var(--bg-color);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: var(--text-color);
}

/* Prevent accidental horizontal space */
body{
    position: relative;
}

/* =========================================================
   GLOBAL CONTAINERS
========================================================= */
.wrapper{
    display: flex;
    min-height: 100vh;
    width: 100%;
    background: var(--bg-color);
}

body,
.wrapper,
.content-wrapper,
.main-sidebar,
.main-header,
.main-footer,
.card,
.modal-content,
.dropdown-menu{
    background: var(--bg-color) !important;
}

/* =========================================================
   SIDEBAR
========================================================= */
.main-sidebar{
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1030;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg-color);
    transition: transform var(--transition);
    will-change: transform;
}

.brand-link{
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-color);
    font-weight: 700;
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar{
    padding: 12px 0;
}

/* Sidebar close button area */
.sidebar-close{
    padding: 10px 14px;
    text-align: right;
}

.sidebar-close a{
    font-size: 20px;
    color: #fff;
    display: inline-block;
    text-decoration: none;
}

/* =========================================================
   SIDEBAR MENU
========================================================= */
.nav-sidebar{
    width: 100%;
    padding: 0;
    margin: 0;
}

.nav-sidebar .nav-item{
    width: 100%;
}

.nav-sidebar .nav-link{
    display: flex;
    align-items: center;
    gap: 10px;
    width: calc(100% - 20px);
    margin: 4px 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #374151;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    font-weight: 500;
    min-height: 44px;
}

.nav-sidebar .nav-link i{
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    font-size: 15px;
}

.nav-sidebar .nav-link p{
    margin: 0;
    line-height: 1.3;
}

.nav-sidebar .nav-link:hover{
    background: var(--hover-bg);
    color: #111827;
}

.nav-sidebar .nav-link.active{
    background: var(--active-bg);
    color: #111827;
    font-weight: 600;
}

/* Sidebar section titles */
.nav-header{
    font-size: 11px;
    font-weight: 700;
    color: #9ca3af;
    padding: 14px 18px 6px !important;
    margin-top: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* =========================================================
   HEADER
========================================================= */
.main-header{
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--header-height);
    z-index: 1020;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 20px;
    background: var(--bg-color);
    transition: left var(--transition), width var(--transition);
    overflow: hidden;
}

/* =========================================================
   CONTENT WRAPPER
========================================================= */
.content-wrapper{
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    padding-top: var(--header-height);
    overflow-x: hidden;
    background: var(--bg-color);
    transition: margin-left var(--transition), width var(--transition);
}

.content{
    width: 100%;
    padding: 20px;
}

.container-fluid{
    width: 100%;
    max-width: 100%;
    padding-left: 0;
    padding-right: 0;
}

/* =========================================================
   CARDS
========================================================= */
.card{
    border: 1px solid var(--border-color) !important;
    border-radius: 12px !important;
    overflow: hidden;
}

.card-header{
    background: #ffffff !important;
    border-bottom: 1px solid var(--border-color);
    padding: 14px 18px;
}

.card-body{
    padding: 18px;
}

/* =========================================================
   TABLES
========================================================= */
.table{
    width: 100%;
    margin-bottom: 0;
    border-color: var(--border-color);
}

.table th{
    background: var(--bg-soft);
    font-weight: 600;
    white-space: nowrap;
}

.table td,
.table th{
    vertical-align: middle;
    padding: 12px;
}

.table-responsive{
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* POS CART */
.pos-cart-table td,
.pos-cart-table th{
    vertical-align: middle;
    white-space: nowrap;
}

/* =========================================================
   FORMS
========================================================= */
.form-control,
.form-select{
    min-height: 45px;
    border-radius: 10px !important;
    border: 1px solid #d1d5db;
    font-size: 14px;
}

textarea.form-control{
    height: auto;
    min-height: 120px;
}

.form-control:focus,
.form-select:focus{
    border-color: #9ca3af;
    outline: none;
}

/* =========================================================
   BUTTONS
========================================================= */
.btn{
    border-radius: 10px !important;
    padding: 10px 16px;
    font-weight: 500;
}

/* =========================================================
   STAT BOX
========================================================= */
.stat-box{
    border: 1px solid var(--border-color);
    background: #ffffff;
    padding: 18px;
    height: 100%;
    border-radius: 12px;
}

.stat-box .h4{
    font-weight: 700;
}

/* =========================================================
   BADGES
========================================================= */
.badge-soft{
    background: var(--bg-soft);
    color: var(--text-color);
    border: 1px solid #dee2e6;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 999px;
}

/* =========================================================
   VARIANT PILLS
========================================================= */
.variant-pill{
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    margin-right: 4px;
    margin-bottom: 4px;
    border: 1px solid #dee2e6;
    background: var(--bg-soft);
    font-size: 12px;
    white-space: nowrap;
    border-radius: 999px;
}

/* =========================================================
   BARCODE INPUT
========================================================= */
.barcode-input{
    height: 60px;
    font-size: 20px;
    font-weight: 600;
    padding: 10px 16px;
    letter-spacing: 1px;
    border-radius: 12px !important;
}

/* =========================================================
   SALE ROW COLORS
========================================================= */
.sale-row-loss{
    background: #f8d7da !important;
}

.sale-row-discount{
    background: #fff3cd !important;
}

.sale-row-normal{
    background: #d1e7dd !important;
}

.sale-row-premium{
    background: #cfe2ff !important;
}

/* =========================================================
   UTILITIES
========================================================= */
.min-h-350{
    min-height: 350px;
}

/* =========================================================
   MODALS
========================================================= */
.modal-content{
    border-radius: 12px !important;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

/* =========================================================
   DROPDOWNS
========================================================= */
.dropdown-menu{
    border-radius: 12px !important;
    border: 1px solid var(--border-color);
}

/* =========================================================
   DESKTOP SIDEBAR CLOSED STATE
========================================================= */
body.sidebar-closed .main-sidebar{
    transform: translateX(calc(-1 * var(--sidebar-width)));
}

body.sidebar-closed .content-wrapper{
    margin-left: 0;
    width: 100%;
}

body.sidebar-closed .main-header{
    left: 0;
}

/* =========================================================
   MOBILE + TABLET
========================================================= */
@media (max-width: 991px){

    .main-sidebar{
        transform: translateX(calc(-1 * var(--sidebar-width)));
        z-index: 1050;
    }

    body.sidebar-open .main-sidebar{
        transform: translateX(0);
    }

    .main-header{
        left: 0;
        right: 0;
        width: 100%;
        padding: 0 15px;
    }

    .content-wrapper{
        margin-left: 0;
        width: 100%;
        padding-top: var(--header-height);
    }

    .content{
        padding: 15px;
    }

    .barcode-input{
        font-size: 18px;
    }

    .table td,
    .table th{
        padding: 10px;
    }

    body.sidebar-open::before{
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 1040;
    }
}

/* =========================================================
   SMALL MOBILE
========================================================= */
@media (max-width: 575px){

    :root{
        --header-height: 64px;
        --sidebar-width: 240px;
    }

    .brand-link{
        height: 64px;
        padding: 0 16px;
        font-size: 16px;
    }

    .main-header{
        height: var(--header-height);
        padding: 0 12px;
    }

    .content-wrapper{
        padding-top: var(--header-height);
    }

    .content{
        padding: 12px;
    }

    .nav-sidebar .nav-link{
        width: calc(100% - 16px);
        margin: 4px 8px;
        padding: 10px 11px;
    }

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

    .btn{
        width: 100%;
    }
}

/* =========================================================
   SAFETY / FIXES FOR FULL WIDTH
========================================================= */
img,
video,
canvas,
svg{
    max-width: 100%;
    height: auto;
}

input,
select,
textarea,
button{
    max-width: 100%;
}

.row{
    margin-left: 0;
    margin-right: 0;
}

[class*="col-"]{
    padding-left: 12px;
    padding-right: 12px;
}