/* ================================================================
   BusinessPlus - Application Styles
   Mobile-first with sidebar + bottom nav pattern
   ================================================================ */

/* ---- CSS Variables ---- */
:root {
    --primary: #16426d;
    --primary-light: #1a5276;
    --secondary: #d4b483;
    --sidebar-bg: #164e63;
    --sidebar-hover: #2c7a7b;
    --sidebar-active: #38b2ac;
    --topbar-gradient-start: #1a5276;
    --topbar-gradient-mid: #2c7a7b;
    --topbar-gradient-end: #38b2ac;
    --text-light: #cbd5e1;
    --text-white: #ffffff;
    --bottom-nav-height: 60px;
    --sidebar-width: 230px;
}

/* ---- Base ---- */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    display: flex;
    flex-wrap: wrap;
    min-height: 100vh;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f4f7f9;
}

/* ---- Top Bar ---- */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--topbar-gradient-start) 0%, var(--topbar-gradient-mid) 50%, var(--topbar-gradient-end) 100%);
    color: var(--text-white);
    padding: 0 16px;
    height: 48px !important;
    max-height: 48px !important;
    font-weight: 500;
    width: 100%;
    flex-shrink: 0;
    z-index: 1030;
    box-sizing: border-box;
}

.top-bar .app-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 18px;
}

.lang-switch {
    display: flex;
    align-items: center;
    gap: 4px;
}

.lang-link {
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.lang-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.15);
}

.lang-active {
    color: #fff !important;
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.4);
    pointer-events: none;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    white-space: nowrap;
}

.btn-logout {
    color: #fff !important;
    text-decoration: underline !important;
    margin-left: 5px;
    font-size: 13px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.btn-logout:hover {
    color: var(--secondary) !important;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    padding-top: 5px;
    color: var(--text-white);
    overflow-y: auto;
    overflow-x: hidden;
}

/* ---- Menu ---- */
.menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu li {
    padding: 0;
}

.menu li a {
    display: block;
    padding: 10px 20px;
    color: var(--text-light);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    font-size: 14px;
    white-space: nowrap;
}

.menu li a:hover {
    background: var(--sidebar-hover);
    border-left-color: var(--secondary);
    color: #fff;
}

/* Active Link */
.menu li a.active {
    background: var(--sidebar-active);
    color: #fff;
    border-left: 4px solid var(--secondary);
    font-weight: 600;
}

/* Submenu */
.submenu {
    display: none;
    background: #0e3b47;
    list-style: none;
    padding: 0;
    margin: 0;
}

.submenu li a {
    padding-left: 35px;
    font-size: 13px;
}

/* Arrow */
.arrow {
    float: right;
    transition: transform 0.3s;
}

.menu-item.open .arrow {
    transform: rotate(180deg);
}

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    overflow-x: auto;
    padding-bottom: calc(var(--bottom-nav-height) + 14px); /* space for bottom nav on mobile */
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 8px;
}

.page-title {
    margin: 0;
    color: var(--primary);
    font-weight: 600;
}

/* ---- Bottom Navigation (Mobile) ---- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--sidebar-bg);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1020;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    text-decoration: none;
    font-size: 11px;
    padding: 6px 8px;
    border-radius: 8px;
    transition: all 0.2s;
    background: none;
    border: none;
    cursor: pointer;
    min-width: 56px;
}

.bottom-nav-item:hover,
.bottom-nav-item.active {
    color: #fff;
    background: var(--sidebar-hover);
}

.bottom-nav-icon {
    font-size: 20px;
    margin-bottom: 2px;
}

.bottom-nav-label {
    white-space: nowrap;
    font-size: 10px;
}

/* ---- Hide number input spinners ---- */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

/* ---- Responsive ---- */

/* Desktop: Show sidebar, hide bottom nav */
@media (min-width: 768px) {
    .bottom-nav {
        display: none !important;
    }
    .main-content {
        padding-bottom: 20px;
    }
    .sidebar {
        display: block !important;
    }
}

/* Mobile: Hide sidebar by default, show bottom nav */
@media (max-width: 767.98px) {
    .sidebar {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 1050;
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
        overflow-y: auto;
    }

    .sidebar.show {
        display: block;
    }

    .top-bar {
        padding: 8px 12px;
    }

    .top-bar .app-name {
        font-size: 14px;
    }

    .user-info {
        font-size: 12px;
    }

    .lang-link {
        font-size: 11px;
        padding: 2px 6px;
    }

    .main-content {
        padding: 12px;
    }
}

/* ---- Utility: Table responsive wrapper ---- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---- Card styling ---- */
.card {
    border: 1px solid #e0e5ec;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-header {
    background: #f8f9fa;
    border-bottom: 1px solid #e0e5ec;
    font-weight: 600;
    color: var(--primary);
}

/* ---- Pagination Styles ---- */
.pagination {
    margin-bottom: 0;
    gap: 2px;
}

.pagination .page-item .page-link {
    color: var(--primary);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
}

.pagination .page-item.active .page-link {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.pagination .page-item .page-link:hover {
    background-color: var(--sidebar-hover);
    color: #ffffff;
    border-color: var(--sidebar-hover);
}

.pagination svg {
    width: 1rem !important;
    height: 1rem !important;
    max-width: 1rem !important;
    max-height: 1rem !important;
    vertical-align: middle;
}

/* ---- Sticky Floating Action Bar ---- */
.fixed-bottom-bar {
    position: fixed !important;
    bottom: 0 !important;
    right: 0 !important;
    left: var(--sidebar-width) !important;
    z-index: 1050 !important;
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(12px) !important;
    border-top: 1px solid #cbd5e1 !important;
    box-shadow: 0 -4px 25px rgba(0, 0, 0, 0.12) !important;
    padding: 14px 28px !important;
    margin: 0 !important;
}

@media (max-width: 991.98px) {
    .fixed-bottom-bar {
        left: 0 !important;
    }
}

/* ---- Upgraded Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    padding: 12px 8px;
    color: var(--text-white);
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
}

.sidebar-user-card {
    background: rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(255,255,255,0.12);
}

.sidebar-section-header {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: rgba(255,255,255,0.55);
    letter-spacing: 0.8px;
    padding: 10px 12px 4px 12px;
}

.menu li a {
    border-radius: 8px;
    margin-bottom: 2px;
    padding: 9px 14px;
    border-left: none !important;
    font-weight: 500;
}

.menu li a.active {
    background: var(--sidebar-active) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.menu li a:hover {
    background: rgba(255,255,255,0.12) !important;
}

/* ---- Dark Mode Overrides ---- */
[data-bs-theme="dark"], body.dark-theme {
    background-color: #0f172a !important;
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .card,
body.dark-theme .card {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .card-header,
body.dark-theme .card-header {
    background-color: #0f172a !important;
    border-bottom-color: #334155 !important;
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .table,
body.dark-theme .table {
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .table-light,
body.dark-theme .table-light,
[data-bs-theme="dark"] .table-light th,
body.dark-theme .table-light th {
    background-color: #1e293b !important;
    color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
body.dark-theme .form-control,
body.dark-theme .form-select {
    background-color: #0f172a !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .text-dark,
body.dark-theme .text-dark {
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .bg-white,
body.dark-theme .bg-white {
    background-color: #1e293b !important;
}

[data-bs-theme="dark"] .bg-light,
body.dark-theme .bg-light {
    background-color: #0f172a !important;
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .text-muted,
body.dark-theme .text-muted {
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .modal-content,
body.dark-theme .modal-content {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .modal-header,
body.dark-theme .modal-header {
    border-bottom-color: #334155 !important;
}

[data-bs-theme="dark"] .modal-footer,
body.dark-theme .modal-footer {
    border-top-color: #334155 !important;
    background-color: #0f172a !important;
}

[data-bs-theme="dark"] .dropdown-menu,
body.dark-theme .dropdown-menu {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .dropdown-item,
body.dark-theme .dropdown-item {
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .dropdown-item:hover,
body.dark-theme .dropdown-item:hover {
    background-color: #334155 !important;
}

[data-bs-theme="dark"] .fixed-bottom-bar,
body.dark-theme .fixed-bottom-bar {
    background: rgba(30, 41, 59, 0.95) !important;
    border-top-color: #334155 !important;
}

[data-bs-theme="dark"] .pos-product-card,
body.dark-theme .pos-product-card {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .pos-cart-panel,
body.dark-theme .pos-cart-panel {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

/* ---- Total 100% Sidebar Collapse Mode (Zero Space Gap) ---- */
.sidebar {
    transition: all 0.2s ease-in-out;
}

body.sidebar-collapsed .sidebar {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
}

body.sidebar-collapsed .main-content {
    flex: 1 1 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
}

