/* ==========================================================
   APP LAYOUT CSS - MODERN RESPONSIVE POS SIDEBAR
   ========================================================== */

* {
    box-sizing: border-box;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    background-color: #f8fafc;
    color: #334155;
    font-size: 0.875rem;
}


/* ==========================================================
   SIDEBAR
   ========================================================== */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;

    width: 250px;
    height: 100vh;
    height: 100dvh;

    overflow-y: auto;
    overflow-x: hidden;

    z-index: 1040;

    background-color: #1e293b;
    color: #94a3b8;

    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);

    transition:
        width 0.25s ease,
        left 0.25s ease;
}


/* Sidebar scrollbar */

.sidebar::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.3);
}


/* ==========================================================
   SIDEBAR BRAND
   ========================================================== */

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;

    height: 56px;

    color: #ffffff;
    text-decoration: none;

    font-weight: 700;
    font-size: 1rem;

    letter-spacing: 0.03rem;

    border-bottom: 1px solid rgba(255, 255, 255, 0.05);

    white-space: nowrap;
}

.sidebar-brand-text {
    white-space: nowrap;
}


/* ==========================================================
   SIDEBAR DIVIDER
   ========================================================== */

.sidebar-divider {
    margin: 0.5rem 1rem;

    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}


/* ==========================================================
   SIDEBAR HEADING
   ========================================================== */

.sidebar-heading {
    padding: 0.4rem 1.25rem;

    font-size: 0.6rem;
    font-weight: 700;

    text-transform: uppercase;

    color: #64748b;

    letter-spacing: 0.05rem;

    white-space: nowrap;
}


/* ==========================================================
   SIDEBAR NAV
   ========================================================== */

.sidebar-nav {
    list-style: none;

    margin: 0;
    padding: 0;

    width: 100%;
}

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


/* ==========================================================
   MAIN NAV LINKS
   ========================================================== */

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;

    width: 100%;
    min-width: 0;

    gap: 0.75rem;

    padding: 0.6rem 1.25rem;

    color: #94a3b8;

    text-decoration: none;

    font-size: 0.82rem;
    font-weight: 500;

    /*
     * IMPORTANT:
     * Prevent text from going to a second line.
     */
    white-space: nowrap;

    border-left: 3px solid transparent;

    transition:
        background-color 0.15s ease,
        color 0.15s ease;

    cursor: pointer;

    touch-action: manipulation;

    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.15);
}


/* ==========================================================
   NAV ICONS
   ========================================================== */

.sidebar-nav .nav-link i {
    font-size: 1.05rem;

    min-width: 1.25rem;

    flex: 0 0 auto;

    text-align: center;

    color: #64748b;

    transition: color 0.2s ease;
}


/* ==========================================================
   NAV TEXT
   ========================================================== */

/*
 * IMPORTANT:
 * Text remains on ONE horizontal line.
 *
 * Examples:
 *
 * New Sale (POS)
 * Sales History
 * Credit & Debts
 * SMS Management
 * Roles & Permissions
 *
 * They will NOT become:
 *
 * Roles &
 * Permissions
 */

.sidebar-nav .nav-link span {
    flex: 1 1 auto;

    min-width: 0;

    white-space: nowrap;

    word-break: normal;

    overflow-wrap: normal;

    overflow: visible;

    text-overflow: unset;

    font-family: inherit;
}


/* ==========================================================
   HOVER
   ========================================================== */

.sidebar-nav .nav-link:hover {
    color: #f8fafc;

    background-color: rgba(255, 255, 255, 0.04);
}

.sidebar-nav .nav-link:hover i {
    color: #38bdf8;
}


/* ==========================================================
   ACTIVE ITEM
   ========================================================== */

.sidebar-nav .nav-item.active .nav-link {
    color: #ffffff;

    background-color: #0f172a;

    border-left-color: #3b82f6;

    font-weight: 600;
}

.sidebar-nav .nav-item.active .nav-link i {
    color: #3b82f6;
}


/* ==========================================================
   DROPDOWN CHEVRON
   ========================================================== */

.sidebar-nav .nav-link[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

.sidebar-nav .nav-link .bi-chevron-down {
    transition: transform 0.2s ease;

    font-size: 0.7rem !important;

    min-width: auto;

    flex: 0 0 auto;

    margin-left: auto;
}


/* ==========================================================
   BADGES
   ========================================================== */

.sidebar-nav .nav-link .badge {
    flex: 0 0 auto;

    white-space: nowrap;
}


/* ==========================================================
   SUBMENU
   ========================================================== */

.sidebar-submenu {
    border-left-color: rgba(255, 255, 255, 0.15) !important;

    width: auto;

    min-width: 0;
}

.sidebar-submenu .sub-link {
    display: flex;
    align-items: center;

    width: 100%;

    color: #cbd5e1 !important;

    font-weight: 500;

    border-radius: 4px;

    padding: 0.4rem 0.6rem !important;

    text-decoration: none;

    transition:
        background-color 0.2s ease,
        color 0.2s ease;

    /*
     * Submenu text also stays horizontal.
     */
    white-space: nowrap !important;

    word-break: normal !important;

    overflow-wrap: normal !important;
}

.sidebar-submenu .sub-link i {
    flex: 0 0 auto;

    white-space: nowrap;
}

.sidebar-submenu .sub-link small {
    white-space: nowrap !important;
}


/* Submenu hover */

.sidebar-submenu .sub-link:hover {
    color: #ffffff !important;

    background-color: rgba(255, 255, 255, 0.06);
}


/* Active submenu */

.sidebar-submenu .sub-link.active-sub {
    color: #ffffff !important;

    background-color: #0f172a;

    font-weight: 700;

    border-left: 2px solid #3b82f6;

    padding-left: calc(0.6rem - 2px) !important;
}


/* ==========================================================
   TOPBAR
   ========================================================== */

.topbar {
    position: fixed;

    top: 0;
    left: 250px;
    right: 0;

    width: calc(100% - 250px);

    height: 56px;

    z-index: 1020;

    padding: 0 1.2rem;

    display: flex;

    align-items: center;

    background-color: #ffffff;

    border-bottom: 1px solid #e2e8f0;

    transition:
        left 0.25s ease,
        width 0.25s ease;
}


/* ==========================================================
   HAMBURGER BUTTON
   ========================================================== */

.hamburger-btn {
    font-size: 1.2rem;

    width: 2.2rem;
    height: 2.2rem;

    display: flex;

    align-items: center;
    justify-content: center;

    color: #64748b;

    background: transparent;

    border: none;

    cursor: pointer;

    border-radius: 50%;

    transition:
        background-color 0.2s ease,
        color 0.2s ease;

    touch-action: manipulation;

    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

.hamburger-btn:hover {
    background-color: #f1f5f9;

    color: #0f172a;
}


/* ==========================================================
   MAIN CONTENT
   ========================================================== */

main,
.main-content {
    margin-left: 250px;

    margin-top: 56px;

    padding: 1.2rem;

    width: calc(100% - 250px);

    min-height: calc(100vh - 56px);
    min-height: calc(100dvh - 56px);

    box-sizing: border-box;

    transition:
        margin-left 0.25s ease,
        width 0.25s ease;
}


.main-content .container-fluid {
    padding-left: 0 !important;
    padding-right: 0 !important;
}


.main-content .row {
    margin-left: -0.5rem;
    margin-right: -0.5rem;
}


.main-content .row > [class*="col-"] {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}


.main-content img,
.main-content table {
    max-width: 100%;
}


.main-content .table-responsive {
    -webkit-overflow-scrolling: touch;
}


.main-content button,
.main-content a,
.main-content input,
.main-content select,
.main-content textarea,
.main-content [role="button"] {
    touch-action: manipulation;
}


/* ==========================================================
   FOOTER
   ========================================================== */

.footer {
    margin-left: 250px;

    width: calc(100% - 250px);

    padding: 12px 15px;

    text-align: center;

    color: #64748b;

    border-top: 1px solid #e2e8f0;

    transition:
        margin-left 0.25s ease,
        width 0.25s ease;

    font-size: 0.78rem;
}


/* ==========================================================
   DESKTOP SIDEBAR COLLAPSE
   ========================================================== */

body.sidebar-toggled .sidebar {
    width: 70px !important;

    left: 0 !important;
}


body.sidebar-toggled .topbar {
    left: 70px !important;

    width: calc(100% - 70px) !important;
}


body.sidebar-toggled main,
body.sidebar-toggled .main-content,
body.sidebar-toggled .footer {
    margin-left: 70px !important;

    width: calc(100% - 70px) !important;
}


/* Hide text on collapsed desktop sidebar */

body.sidebar-toggled .sidebar .sidebar-heading,
body.sidebar-toggled .sidebar .nav-link span,
body.sidebar-toggled .sidebar .sidebar-brand-text,
body.sidebar-toggled .sidebar .bi-chevron-down {
    display: none !important;
}


/* Center icons */

body.sidebar-toggled .sidebar .nav-link {
    justify-content: center;

    padding: 0.7rem 0;

    border-left: none;
}


body.sidebar-toggled .sidebar .nav-link i {
    font-size: 1.2rem;

    margin: 0;
}


/* Hide dropdowns when desktop sidebar collapsed */

body.sidebar-toggled .sidebar .collapse {
    display: none !important;
}


/* ==========================================================
   MOBILE / TABLET
   <= 1024px
   ========================================================== */

@media (max-width: 1024px) {

    /*
     * Desktop sidebar disappears outside the screen.
     */

    .topbar {
        left: 0 !important;

        width: 100% !important;
    }


    main,
    .main-content,
    .footer {
        margin-left: 0 !important;

        width: 100% !important;
    }


    /*
     * Mobile sidebar.
     *
     * 300px gives enough room for:
     *
     * Roles & Permissions
     * SMS Management
     * New Sale (POS)
     * Stock & Batches
     *
     * without breaking the words.
     */

    .sidebar {
        width: min(300px, 88vw);

        left: -320px;

        height: 100vh;
        height: 100dvh;

        transition: left 0.25s ease;
    }


    /*
     * Open sidebar.
     */

    body.sidebar-toggled .sidebar {
        left: 0 !important;

        width: min(300px, 88vw) !important;
    }


    /*
     * IMPORTANT:
     * On mobile hamburger means FULL sidebar,
     * with text visible.
     */

    body.sidebar-toggled .sidebar .sidebar-heading,
    body.sidebar-toggled .sidebar .nav-link span,
    body.sidebar-toggled .sidebar .sidebar-brand-text,
    body.sidebar-toggled .sidebar .bi-chevron-down {
        display: block !important;
    }


    /*
     * Keep every label on one horizontal line.
     */

    body.sidebar-toggled .sidebar .nav-link span {
        white-space: nowrap !important;

        word-break: normal !important;

        overflow-wrap: normal !important;

        overflow: visible !important;

        text-overflow: unset !important;
    }


    /*
     * Normal mobile nav alignment.
     */

    body.sidebar-toggled .sidebar .nav-link {
        justify-content: flex-start;

        align-items: center;

        width: 100%;

        padding: 0.6rem 1rem;

        font-size: 0.8rem;

        white-space: nowrap;
    }


    body.sidebar-toggled .sidebar .nav-link i {
        margin-top: 0;

        flex: 0 0 auto;
    }


    /*
     * Dropdown arrow must remain on the right.
     */

    body.sidebar-toggled .sidebar .nav-link .bi-chevron-down {
        display: block !important;

        margin-left: auto;

        flex: 0 0 auto;
    }


    /*
     * Dropdown submenu.
     */

    body.sidebar-toggled .sidebar .collapse.show {
        display: block !important;
    }


    /*
     * Submenu text must remain horizontal.
     */

    body.sidebar-toggled .sidebar .sidebar-submenu .sub-link {
        white-space: nowrap !important;

        word-break: normal !important;

        overflow-wrap: normal !important;

        display: flex !important;

        align-items: center;
    }


    body.sidebar-toggled .sidebar .sidebar-submenu small {
        white-space: nowrap !important;
    }


    /*
     * Backdrop.
     */

    .sidebar-backdrop {
        display: none;
    }


    body.sidebar-toggled .sidebar-backdrop {
        display: block;

        position: fixed;

        top: 0;
        left: 0;

        width: 100vw;
        height: 100vh;
        height: 100dvh;

        background: rgba(15, 23, 42, 0.5);

        z-index: 1035;
    }
}


/* ==========================================================
   TABLETS / NORMAL PHONES
   481px - 767px
   ========================================================== */

@media (max-width: 767px) and (min-width: 481px) {

    body {
        font-size: 0.82rem;
    }


    .topbar {
        height: 52px;

        padding: 0 1rem;
    }


    main,
    .main-content {
        margin-top: 52px;

        padding: 1rem;

        min-height: calc(100vh - 52px);
        min-height: calc(100dvh - 52px);
    }


    .sidebar {
        width: min(300px, 88vw);

        left: -320px;
    }


    body.sidebar-toggled .sidebar {
        width: min(300px, 88vw) !important;

        left: 0 !important;
    }


    .sidebar-nav .nav-link {
        font-size: 0.8rem;

        white-space: nowrap;
    }


    .sidebar-nav .nav-link span {
        white-space: nowrap !important;

        word-break: normal !important;
    }


    .sidebar-submenu .sub-link {
        white-space: nowrap !important;
    }


    .sidebar-submenu .sub-link small {
        white-space: nowrap !important;
    }
}


/* ==========================================================
   SMALL PHONES
   <= 480px
   ========================================================== */

@media (max-width: 480px) {

    body {
        font-size: 0.8rem;
    }


    /*
     * Slightly wider sidebar.
     *
     * This is intentional because we want complete labels.
     */

    .sidebar {
        width: min(320px, 90vw);

        left: -340px;
    }


    body.sidebar-toggled .sidebar {
        width: min(320px, 90vw) !important;

        left: 0 !important;
    }


    /*
     * Topbar.
     */

    .topbar {
        height: 50px;

        padding: 0 0.8rem;
    }


    .topbar .hamburger-btn {
        font-size: 1rem;

        width: 2rem;
        height: 2rem;
    }


    /*
     * Main content.
     */

    main,
    .main-content {
        margin-top: 50px;

        padding: 0.8rem;

        min-height: calc(100vh - 50px);
        min-height: calc(100dvh - 50px);
    }


    /*
     * Sidebar brand.
     */

    .sidebar-brand {
        font-size: 0.9rem;

        height: 50px;

        white-space: nowrap;
    }


    /*
     * Main navigation.
     */

    .sidebar-nav .nav-link {
        font-size: 0.75rem;

        padding: 0.5rem 0.9rem;

        gap: 0.6rem;

        white-space: nowrap;
    }


    /*
     * Navigation text NEVER wraps.
     */

    .sidebar-nav .nav-link span {
        white-space: nowrap !important;

        word-break: normal !important;

        overflow-wrap: normal !important;

        overflow: visible !important;
    }


    /*
     * Icons.
     */

    .sidebar-nav .nav-link i {
        font-size: 0.95rem;

        min-width: 1rem;

        flex: 0 0 auto;
    }


    /*
     * Sidebar headings.
     */

    .sidebar-heading {
        font-size: 0.55rem;

        padding: 0.3rem 0.9rem;

        white-space: nowrap;
    }


    /*
     * Submenu.
     */

    .sidebar-submenu .sub-link {
        font-size: 0.72rem;

        padding: 0.4rem 0.5rem !important;

        white-space: nowrap !important;

        word-break: normal !important;

        overflow-wrap: normal !important;
    }


    .sidebar-submenu .sub-link small {
        white-space: nowrap !important;
    }


    /*
     * Footer.
     */

    .footer {
        font-size: 0.7rem;

        padding: 10px;
    }
}


/* ==========================================================
   VERY SMALL PHONES
   <= 360px
   ========================================================== */

@media (max-width: 360px) {

    /*
     * Use almost the entire phone width.
     * This keeps long menu names readable.
     */

    .sidebar {
        width: 92vw;

        left: -100vw;
    }


    body.sidebar-toggled .sidebar {
        width: 92vw !important;

        left: 0 !important;
    }


    .sidebar-nav .nav-link {
        font-size: 0.73rem;

        padding-left: 0.8rem;
        padding-right: 0.8rem;
    }


    .sidebar-nav .nav-link i {
        font-size: 0.9rem;

        min-width: 1rem;
    }


    .sidebar-heading {
        font-size: 0.52rem;

        padding-left: 0.8rem;
        padding-right: 0.8rem;
    }


    .sidebar-submenu .sub-link {
        font-size: 0.7rem !important;

        white-space: nowrap !important;
    }
}


/* ==========================================================
   EXTRA LARGE SCREENS
   >= 1600px
   ========================================================== */

@media (min-width: 1600px) {

    main,
    .main-content {
        padding: 1.5rem 2rem;
    }
}
/* ==========================================================
   SOKOTRACK BRAND COLORS - Override Bootstrap Blue
   ========================================================== */

:root {
    /* Primary = Teal (kutoka logo) */
    --bs-primary: #0f6e5f;
    --bs-primary-rgb: 15, 110, 95;
    --bs-primary-text-emphasis: #0a4a40;
    --bs-primary-bg-subtle: #d6ece8;
    --bs-primary-border-subtle: #9ecfc5;

    /* Secondary = Charcoal/Dark (kama "Soko" kwenye wordmark) */
    --bs-secondary: #1c2a27;
    --bs-secondary-rgb: 28, 42, 39;
    --bs-secondary-text-emphasis: #141e1b;
    --bs-secondary-bg-subtle: #e4e7e6;
    --bs-secondary-border-subtle: #b8c0be;

    /* Accent = Machungwa (kutoka dot ya logo) - kwa highlights/badges maalum */
    --sokotrack-accent: #f2994a;
}

/* ---------- BUTTONS ---------- */
.btn-primary {
    background-color: #0f6e5f;
    border-color: #0f6e5f;
    color: #ffffff;
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: #0a4a40 !important;
    border-color: #0a4a40 !important;
    color: #ffffff;
}

.btn-outline-primary {
    color: #0f6e5f;
    border-color: #0f6e5f;
}
.btn-outline-primary:hover {
    background-color: #0f6e5f;
    border-color: #0f6e5f;
    color: #ffffff;
}

.btn-secondary {
    background-color: #1c2a27;
    border-color: #1c2a27;
    color: #ffffff;
}
.btn-secondary:hover,
.btn-secondary:focus {
    background-color: #0f1917 !important;
    border-color: #0f1917 !important;
}

.btn-outline-secondary {
    color: #1c2a27;
    border-color: #1c2a27;
}
.btn-outline-secondary:hover {
    background-color: #1c2a27;
    border-color: #1c2a27;
    color: #ffffff;
}

/* ---------- TEXT / BACKGROUND / BORDER UTILITIES ---------- */
.text-primary { color: #0f6e5f !important; }
.bg-primary { background-color: #0f6e5f !important; }
.border-primary { border-color: #0f6e5f !important; }

.text-secondary { color: #1c2a27 !important; }
.bg-secondary { background-color: #1c2a27 !important; }
.border-secondary { border-color: #1c2a27 !important; }

.bg-primary-subtle { background-color: #d6ece8 !important; }
.text-primary-emphasis { color: #0a4a40 !important; }

/* ---------- LINKS ---------- */
a {
    color: #0f6e5f;
}
a:hover {
    color: #0a4a40;
}

/* ---------- BADGES / PILLS ---------- */
.badge.bg-primary { background-color: #0f6e5f !important; }
.badge.bg-primary-subtle { 
    background-color: #d6ece8 !important; 
    color: #0a4a40 !important; 
}

/* ---------- FORM FOCUS STATES ---------- */
.form-control:focus,
.form-select:focus {
    border-color: #0f6e5f;
    box-shadow: 0 0 0 0.25rem rgba(15, 110, 95, 0.15);
}

.form-check-input:checked {
    background-color: #0f6e5f;
    border-color: #0f6e5f;
}

/* ---------- NAV / TABS ---------- */
.nav-tabs .nav-link.active {
    color: #0f6e5f;
    border-color: #0f6e5f #0f6e5f #fff;
}

.page-link {
    color: #0f6e5f;
}
.page-item.active .page-link {
    background-color: #0f6e5f;
    border-color: #0f6e5f;
}

/* ---------- SPINNERS / PROGRESS ---------- */
.spinner-border.text-primary,
.spinner-grow.text-primary {
    color: #0f6e5f !important;
}
.progress-bar {
    background-color: #0f6e5f;
}

/* ---------- ACCENT (machungwa) kwa maeneo maalum tu ---------- */
.badge.bg-accent {
    background-color: #f2994a !important;
    color: #7a3d0f !important;
}