html,
body {
    background: #ffffff;
    font-family: 'Montserrat', serif;
    min-height: 100%;
    transition: background 0.2s, color 0.2s;

}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Montserrat', serif;
    color: #60599e;
    font-weight: bolder;
}

table th,
table td {
    font-size: 14px !important;
}

table th {
    font-weight: bold !important;
}

body.dark-theme {
    background: #181a1b !important;
    color: #f6f6f6 !important;
}

body.dark-theme .custom-navbar {
    background-color: #23272b !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
}

body.dark-theme .navbar-brand,
body.dark-theme .nav-link,
body.dark-theme .dropdown-menu {
    color: #f6f6f6 !important;
    background: #23272b !important;
}

body.dark-theme .dropdown-menu {
    border-color: #444;
}

body.dark-theme .btn-secondary {
    background: #444 !important;
    color: #fff !important;
    border-color: #666 !important;
}

body.dark-theme .btn-danger {
    background: #a33 !important;
    border-color: #a33 !important;
}

body.dark-theme .badge.bg-info {
    background: #444 !important;
    color: #fff !important;
}

/* Sidebar layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: 260px;
    background: #fff;
    border-right: 1px solid rgba(0,0,0,0.05);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    padding: 1rem 0.5rem;
    z-index: 1030;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-x: hidden; /* prevent horizontal scroll */
}

.app-sidebar .sidebar-header {
    padding: 0.5rem 1rem 1rem 1rem;
}

.app-sidebar .logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.app-sidebar .logo img {
    height: 34px;
}

.app-sidebar .brand {
    font-weight: 700;
    color: #60599e;
}

.main-content {
    margin-left: 260px;
    padding: 1.25rem;
    flex: 1 1 auto;
    transition: margin-left 210ms ease;
}

/* Collapsed sidebar styles */
.app-sidebar.collapsed {
    width: 72px;
}

.app-sidebar.collapsed .brand,
.app-sidebar.collapsed .app-name,
.app-sidebar.collapsed .user-meta {
    display: none;
}

.app-sidebar.collapsed .logo img { height: 36px; }

.app-sidebar.collapsed .app-icon { font-size: 1.25rem; }

.app-sidebar.collapsed .btn-toggle-pages { display: none; }

.main-content.sidebar-collapsed { margin-left: 72px; }

/* Hide application sub-pages when sidebar is collapsed */
.app-sidebar.collapsed .app-pages { display: none; }

/* Top and bottom areas in sidebar */
.app-sidebar .sidebar-top { display:flex; align-items:center; gap:0.5rem; padding:0.5rem; }
.sidebar-toggle { background:transparent; border:none; font-size:1.1rem; color: #60599e; }
.sidebar-toggle:focus { outline: none; box-shadow: none; }

.logo { display:flex; align-items:center; gap:0.5rem; text-decoration:none; }
.logo img { height:36px; }

.sidebar-nav { margin-top: 0.5rem; margin-left: 0.5rem; }
.sidebar-bottom { margin-top: auto; padding: 0.75rem; border-top: 1px solid rgba(0,0,0,0.03); }
.sidebar-bottom .user-info { display:flex; gap:0.75rem; align-items:center; padding:0.25rem 0; }
.user-avatar { font-size:2rem; color:#7b74c8; }
.user-meta .user-name { font-weight:700; }
.user-meta .user-sub { font-size:0.85rem; color:#666; }

.sidebar-controls { display:flex; gap:0.5rem; align-items:center; margin-top:0.5rem; }
.theme-toggle { border-radius:6px; }
.logout-form { margin-left:auto; }
 .logout-btn { white-space:nowrap; }

/* Modern look tweaks */
.app-sidebar { box-shadow: 2px 0 8px rgba(96,89,158,0.06); transition: width 210ms ease, background 210ms ease; }
.app-sidebar .app-row:hover { background: rgba(0,0,0,0.02); border-radius:6px; }

@media (max-width: 768px) {
    .app-sidebar { position: relative; width: 100%; height: auto; }
    .main-content { margin-left: 0; }
}

/* Active item styles */
.sidebar-nav .app-link.active,
.sidebar-nav .page-link.active {
    font-weight: 700;
    color: #60599e;
    background: rgba(96,89,158,0.06);
    border-radius: 6px;
}

.sidebar-nav .app-link.active .app-icon,
.sidebar-nav .page-link.active { color: #60599e; }

/* When collapsed keep icon highlighted */
.app-sidebar.collapsed .app-link.active .app-icon {
    color: #60599e;
}


.sidebar-nav .app-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 0.75rem;
    box-sizing: border-box;
    min-width: 0; /* allow children to shrink to avoid overflow */
}

.sidebar-nav .app-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: inherit;
    text-decoration: none;
    min-width: 0;
    overflow: hidden;
}

.app-icon { font-size: 1.05rem; }

.btn-toggle-pages {
    background: transparent;
    border: none;
    color: inherit;
}

.app-pages { padding-left: 0.75rem; }
.app-pages .page-link { display: block; padding: 0.25rem 0.75rem; color: #444; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-pages .page-link:hover { text-decoration: underline; }

body.dark-theme .app-sidebar { background: #111217; border-color: rgba(255,255,255,0.04); }
body.dark-theme .app-pages .page-link { color: #ddd; }

/* Make the nav scroll vertically while top and bottom stay fixed */
.sidebar-nav { overflow-y: auto; overflow-x: hidden; flex: 1 1 auto; }
.sidebar-top { flex: 0 0 auto; }
.sidebar-bottom { flex: 0 0 auto; }

/* Hide logo image when collapsed */
.app-sidebar.collapsed .brand,
.app-sidebar.collapsed .app-name,
.app-sidebar.collapsed .user-meta,
.app-sidebar.collapsed .logo img {
    display: none;
}

/* Prevent wide controls from forcing horizontal scroll */
.app-sidebar, .sidebar-nav, .app-row, .app-link { -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale; }
.app-sidebar * { box-sizing: border-box; }

/* Ensure text truncation for small widths */
.app-sidebar .user-meta { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 768px) {
    .app-sidebar { position: relative; width: 100%; height: auto; }
    .main-content { margin-left: 0; }
}