/* ============================================================================
   PACIOLI ERP — Layout
   Sidebar, topbar, main-content, page-footer.
   Depends on: pacioli.tokens.css
   ============================================================================ */

/* ========================================================================
   1. SIDEBAR
   ======================================================================== */
.sidebar-wrapper {
    font-family: var(--pacioli-font-sans);
    width: 260px;
    background: var(--pacioli-sidebar-bg);
    color: #fff;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: var(--pacioli-z-sidebar);
    transition: var(--pacioli-transition-sidebar);
    box-shadow: 2px 0 14px rgba(0, 0, 0, 0.08);
    overflow-y: auto;
    overflow-x: hidden;
}

/* --- Brand --- */
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    height: 70px;
    padding: 0 16px;
    position: sticky;
    top: 0;
    background: var(--pacioli-sidebar-bg);
    z-index: 2;
    box-sizing: border-box;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #fff;
    flex: 1;
}

.brand-icon {
    display: block;
    width: 40px;
    height: 40px;
    border-radius: var(--pacioli-radius-sm);
    object-fit: cover;
    flex-shrink: 0;
}

.brand-text {
    display: inline-block;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

/* --- Close button (mobile only) --- */
.sidebar-close {
    display: none;
    width: 36px;
    height: 36px;
    padding: 0;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.sidebar-close .material-icons-outlined {
    font-size: 20px;
}

/* --- Navigation --- */
.sidebar-nav {
    padding: 0.5rem 0.25rem 1rem 0.25rem;
    height: calc(100vh - 70px);
    overflow-y: auto;
    overflow-x: hidden;
}

/* MetisMenu in sidebar */
.sidebar-wrapper .metismenu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-wrapper .metismenu > li > a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.9rem;
    border-radius: var(--pacioli-radius);
    color: #e7eaff;
    text-decoration: none;
    transition: background 0.18s ease, color 0.18s ease;
    cursor: pointer;
    min-height: 44px;
}

.sidebar-wrapper .metismenu > li > a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.sidebar-wrapper .metismenu > li > a:active {
    background: rgba(255, 255, 255, 0.18);
}

.sidebar-wrapper .metismenu li.active > a,
.sidebar-wrapper .metismenu li.mm-active > a {
    background: #ffffff;
    color: var(--pacioli-primary) !important;
    font-weight: 600;
}

.sidebar-wrapper .metismenu .menu-label {
    padding: 0.75rem 0.9rem 0.25rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    opacity: 0.7;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.menu-ico {
    font-size: 20px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.menu-text {
    font-weight: 600;
    font-size: 0.94rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Submenu */
.sidebar-wrapper .metismenu ul {
    padding-left: 2.1rem;
    list-style: none;
}

.sidebar-wrapper .metismenu ul li a {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0;
    color: #d9defb;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    min-height: 40px;
    transition: color 0.15s ease;
}

.sidebar-wrapper .metismenu ul li a:hover {
    color: #fff;
}

.sidebar-wrapper .metismenu ul li a:active {
    color: #ffffff;
    opacity: 0.9;
}

.sidebar-wrapper .metismenu ul .active > a {
    color: #fff;
    font-weight: 600;
}

/* Submenu arrow */
.sidebar-wrapper .metismenu .has-arrow::after {
    content: '';
    position: relative;
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: auto;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid currentColor;
    transition: transform 0.2s ease;
}

.sidebar-wrapper .metismenu li.mm-active > .has-arrow::after {
    transform: rotate(180deg);
}

/* Scrollbar */
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

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

/* ========================================================================
   2. MAIN CONTENT AREA
   ======================================================================== */
.main-content {
    padding: 1.5rem;
}

.card-body {
    padding: 1.75rem;
}

/* ========================================================================
   3. RESPONSIVE LAYOUT
   ======================================================================== */

/* DESKTOP LARGE (1280px+) */
@media (min-width: 1280px) {
    .sidebar-wrapper {
        transform: translateX(0);
        left: 0;
    }

    .main-wrapper {
        margin-left: 260px;
    }

    .top-header .navbar {
        left: 260px;
    }

    .page-footer {
        left: 260px;
    }

    .sidebar-close {
        display: none !important;
    }
}

/* DESKTOP SMALL / TABLET LANDSCAPE (max 1279px) */
@media (max-width: 1279px) {
    .sidebar-wrapper {
        left: -260px;
    }

    .main-wrapper {
        margin-left: 0 !important;
    }

    .top-header .navbar {
        left: 0 !important;
    }

    .page-footer {
        left: 0;
    }

    .toggled .sidebar-wrapper {
        left: 0;
        transform: translateX(0);
    }

    .sidebar-close {
        display: flex !important;
    }

    .main-content {
        padding: 1rem;
    }

    .card {
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Overlay */
    .toggled .overlay {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: var(--pacioli-z-overlay);
        display: block;
        cursor: pointer;
    }
}

/* TABLET PORTRAIT (max 1023px) */
@media (max-width: 1023px) {
    .sidebar-brand {
        height: 60px;
    }

    .brand-icon {
        width: 36px;
        height: 36px;
    }

    .brand-text {
        font-size: 1.05rem;
    }

    .sidebar-nav {
        height: calc(100vh - 60px);
    }

    .sidebar-wrapper .metismenu > li > a {
        padding: 0.65rem 0.85rem;
    }

    .menu-text {
        font-size: 0.9rem;
    }

    .top-header {
        height: 60px;
    }

    .main-wrapper {
        margin-top: 60px;
    }
}

/* MOBILE (max 767px) */
@media (max-width: 767px) {
    .sidebar-wrapper {
        width: 280px;
        max-width: 85vw;
    }

    .sidebar-brand {
        height: 56px;
        padding: 0 12px;
    }

    .brand-icon {
        width: 32px;
        height: 32px;
    }

    .brand-text {
        font-size: 1rem;
        max-width: 150px;
    }

    .sidebar-nav {
        height: calc(100vh - 56px);
        padding: 0.5rem 0.15rem 1rem 0.15rem;
    }

    .sidebar-wrapper .metismenu > li > a {
        padding: 0.875rem 0.75rem;
        min-height: 48px;
    }

    .menu-ico {
        font-size: 22px;
        width: 22px;
    }

    .menu-text {
        font-size: 0.9rem;
    }

    .sidebar-wrapper .metismenu ul li a {
        padding: 0.65rem 0;
        min-height: 44px;
    }

    .sidebar-close {
        width: 40px;
        height: 40px;
    }

    .sidebar-close .material-icons-outlined {
        font-size: 22px;
    }

    .top-header {
        height: 56px;
        padding: 0 0.5rem;
    }

    .main-wrapper {
        margin-top: 56px;
        padding: 0;
    }

    .main-content {
        padding: 0.75rem;
    }

    .row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 0.75rem;
    }

    .card {
        border-radius: var(--pacioli-radius-sm);
        margin-bottom: 0.75rem;
    }

    .card-body {
        padding: 0.75rem;
    }

    .toggled .sidebar-wrapper {
        width: 280px;
        max-width: 85vw;
    }
}

/* MOBILE SMALL (max 575px) */
@media (max-width: 575px) {
    .sidebar-wrapper {
        max-width: 90vw;
    }

    .sidebar-brand {
        height: 50px;
    }

    .sidebar-nav {
        height: calc(100vh - 50px);
    }

    .sidebar-wrapper .metismenu .menu-label {
        font-size: 0.7rem;
        padding: 0.65rem 0.75rem 0.2rem;
    }

    .top-header {
        height: 50px;
        padding: 0 0.5rem;
    }

    .main-wrapper {
        margin-top: 50px;
    }

    .main-content {
        padding: 0.5rem;
    }

    .card-body {
        padding: 0.5rem;
    }
}

/* LANDSCAPE */
@media (max-width: 1023px) and (orientation: landscape) {
    .sidebar-wrapper {
        width: 240px;
    }

    .sidebar-brand {
        height: 50px;
    }

    .sidebar-nav {
        height: calc(100vh - 50px);
    }

    .sidebar-wrapper .metismenu > li > a {
        padding: 0.55rem 0.75rem;
    }

    .sidebar-wrapper .metismenu ul li a {
        padding: 0.4rem 0;
    }

    .main-content {
        padding: 0.5rem;
    }

    .card-body {
        padding: 0.75rem;
    }
}

/* TOUCH IMPROVEMENTS */
@media (hover: none) and (pointer: coarse) {
    .sidebar-wrapper .metismenu > li > a {
        min-height: 48px;
        padding: 0.875rem 0.9rem;
    }

    .sidebar-wrapper .metismenu ul li a {
        min-height: 44px;
    }

    .sidebar-wrapper .metismenu > li > a:hover {
        background: transparent;
    }

    .sidebar-wrapper .metismenu > li > a:active {
        background: rgba(255, 255, 255, 0.18);
    }
}
