/* Universal Dark Theme */
body {
    background: #222a42 !important;
    color: #fff;
    font-family: 'Poppins', sans-serif;
    margin: 0 !important;
    padding: 0 !important;
}

.wrapper {
    min-height: 100vh !important;
    display: flex !important;
    flex-direction: row !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Fixed width sidebar with collapse functionality */
nav.sidebar {
    width: 280px !important;
    min-width: 280px !important;
    max-width: 280px !important;
    height: 100vh !important;
    background: #1f2658 !important;
    color: #fff !important;
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    transition: all 0.3s ease !important;
    z-index: 1000 !important;
}

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

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

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

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

/* Collapsed state */
nav.sidebar.collapsed {
    width: 70px !important;
    min-width: 70px !important;
    max-width: 70px !important;
}

nav.sidebar.collapsed .sidebar-header h4,
nav.sidebar.collapsed .nav-link span,
nav.sidebar.collapsed .badge,
nav.sidebar.collapsed .text-muted,
nav.sidebar.collapsed .sidebar-footer .user-role,
nav.sidebar.collapsed .sidebar-footer .small {
    display: none;
}

nav.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.55rem 0.5rem;
}

nav.sidebar.collapsed .nav-link i {
    margin-right: 0;
}

/* Sidebar toggle button */
.sidebar-toggle {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

nav.sidebar .sidebar-header {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    margin-bottom: 0.5rem;
    position: relative;
}

/* Add padding to sidebar content area */
nav.sidebar > *:last-child {
    margin-bottom: 2rem;
}

/* Dashboard - Always visible at top */
.nav-dashboard {
    margin: 0.75rem 0.5rem 1rem 0.5rem;
    border-radius: 0.5rem;
}

.nav-dashboard .nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
    margin: 0;
    border-radius: 0.5rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.nav-dashboard .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff !important;
}

.nav-dashboard .nav-link.active {
    background: #dc3545;
    border-color: #dc3545;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.4);
}

.nav-dashboard .nav-link i {
    font-size: 1.1rem;
}

nav.sidebar.collapsed .nav-dashboard {
    margin: 0.75rem 0.25rem 1rem 0.25rem;
}

nav.sidebar.collapsed .nav-dashboard .nav-link {
    justify-content: center;
    padding: 0.75rem 0.5rem;
}

/* Notification bell */
.notification-bell {
    position: relative;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 50%;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 0.5rem;
}

.notification-bell:hover {
    background: rgba(255, 255, 255, 0.1);
}

.notification-bell i {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.8);
}

.notification-bell.has-notifications i {
    color: #ffc107;
    animation: bellShake 0.5s ease-in-out;
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: #dc3545;
    color: #fff;
    font-size: 0.65rem;
    font-weight: bold;
    padding: 0.15rem 0.35rem;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    line-height: 1;
}

@keyframes bellShake {
    0%, 100% { transform: rotate(0deg); }
    10%, 30%, 50%, 70%, 90% { transform: rotate(-10deg); }
    20%, 40%, 60%, 80% { transform: rotate(10deg); }
}

nav.sidebar.collapsed .notification-bell {
    margin-right: 0;
}

/* Notification panel */
.notification-panel {
    position: fixed;
    top: 80px;
    left: 20px;
    width: 320px;
    max-height: 500px;
    background: #27293d;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1100;
    display: flex;
    flex-direction: column;
}

.notification-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notification-header strong {
    color: #fff;
    font-size: 1rem;
}

.btn-close-notifications {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.btn-close-notifications:hover {
    color: #fff;
}

.notification-list {
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
}

.notification-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: background 0.2s ease;
    cursor: pointer;
}

.notification-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item.unread {
    background: rgba(89, 102, 255, 0.1);
}

.notification-item-title {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.notification-item-message {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.notification-item-time {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
}

.notification-item-icon {
    display: inline-block;
    width: 20px;
    margin-right: 0.5rem;
}

.notification-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    text-align: center;
}

.notification-footer a {
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: 0.85rem;
}

.notification-footer a:hover {
    color: #fff;
}

nav.sidebar .nav {
    padding: 0;
    margin-bottom: 0.5rem;
}

nav.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.82);
    border-radius: 0.5rem;
    margin: 0.1rem 0.75rem;
    padding: 0.5rem 0.85rem;
    display: flex;
    align-items: center;
    transition: background 0.2s ease, color 0.2s ease;
    white-space: nowrap;
    font-size: 0.825rem;
}

nav.sidebar .nav-link i {
    width: 1.25rem;
    text-align: center;
    margin-right: 0.65rem;
    flex-shrink: 0;
}

nav.sidebar .nav-link.active,
nav.sidebar .nav-link:hover,
nav.sidebar .nav-link:focus {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    text-decoration: none;
}

nav.sidebar .nav-link .badge {
    margin-left: auto;
}

/* Navigation divider */
.nav-divider {
    height: 1px;
    margin: 0.5rem 1.5rem;
    background: rgba(255, 255, 255, 0.15);
    list-style: none;
}

nav.sidebar.collapsed .nav-divider {
    margin: 0.5rem 0.5rem;
}

nav.sidebar .sidebar-footer {
    padding: 1rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    background: #1f2658;
    margin-top: 1rem;
    display: flex;
    align-items: center;
}

.min-width-0 {
    min-width: 0;
}

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-footer .user-avatar {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-footer .user-role {
    font-size: 0.85rem;
    font-weight: 500;
    color: #fff;
    line-height: 1.2;
}

.sidebar-footer .small {
    font-size: 0.75rem !important;
    color: rgba(255, 255, 255, 0.6) !important;
}

.sidebar-footer .btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
}

nav.sidebar.collapsed .sidebar-footer {
    padding: 0.75rem 0.5rem;
}

nav.sidebar.collapsed .sidebar-footer .user-role,
nav.sidebar.collapsed .sidebar-footer .small {
    display: none;
}

nav.sidebar.collapsed .sidebar-footer .user-avatar {
    margin: 0 auto;
}

/* Collapsible menu sections */
.nav-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.3s ease, border-color 0.3s ease;
    margin: 0.5rem 0.5rem 0.25rem 0.5rem;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 0.35rem;
    border-left: 3px solid #f0ad4e;
}

.nav-section-header:hover {
    background: rgba(0, 0, 0, 0.35);
}

/* Expanded state - reddish background */
.nav-section-header:not(.collapsed) {
    background: rgba(220, 53, 69, 0.2);
    border-left-color: #dc3545;
}

.nav-section-header .section-title {
    flex: 1;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 1.02rem !important;
    font-weight: 600;
    color: #f0ad4e !important;
    letter-spacing: 0.5px;
}

.nav-section-header .section-title i {
    color: #f0ad4e;
    font-size: 1.08rem;
}

.nav-section-header .toggle-icon {
    transition: transform 0.3s ease;
    font-size: 0.9rem;
    opacity: 0.7;
    margin-left: 0.5rem;
}

.nav-section-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.nav-section-content {
    overflow: visible;
    transition: all 0.3s ease;
    opacity: 1;
    max-height: none;
}

.nav-section-content.collapsed {
    display: none;
}

nav.sidebar.collapsed .nav-section-header .section-title {
    display: none;
}

nav.sidebar.collapsed .nav-section-header .toggle-icon {
    display: none;
}

nav.sidebar.collapsed .nav-section-header {
    padding: 0.25rem;
    justify-content: center;
}

.main-panel {
    background: #1e1e2f !important;
    min-height: 100vh !important;
    flex: 1 1 auto !important;
    margin-left: 280px !important;
    transition: margin-left 0.3s ease !important;
    width: calc(100% - 280px) !important;
    position: relative !important;
}

.main-panel.expanded {
    margin-left: 70px !important;
    width: calc(100% - 70px) !important;
}

.card {
    background: #27293d;
    border: none;
}

.table {
    color: #fff;
}

.form-control {
    background: #222a42;
    color: #fff;
    border: 1px solid #444;
}

.btn-danger {
    background-color: #fd5d93;
    border-color: #fd5d93;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

/* Override any Bootstrap flex utilities that might interfere */
.wrapper.d-flex,
div.wrapper.d-flex,
body > .wrapper.d-flex {
    display: flex !important;
    flex-direction: row !important;
}

.main-panel.flex-grow-1,
div.main-panel.flex-grow-1 {
    flex-grow: 1 !important;
    margin-left: 280px !important;
}

/* Ensure sidebar doesn't get flex properties from Bootstrap */
nav.sidebar.flex-grow-1,
nav.sidebar.flex-shrink-1,
.wrapper > nav.sidebar {
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
    width: 280px !important;
    min-width: 280px !important;
    max-width: 280px !important;
}

/* High specificity overrides for any theme conflicts */
body nav.sidebar#sidebar,
.wrapper nav.sidebar#sidebar,
div.wrapper nav.sidebar#sidebar {
    width: 280px !important;
    min-width: 280px !important;
    max-width: 280px !important;
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    z-index: 1000 !important;
}

body nav.sidebar#sidebar.collapsed,
.wrapper nav.sidebar#sidebar.collapsed,
div.wrapper nav.sidebar#sidebar.collapsed {
    width: 70px !important;
    min-width: 70px !important;
    max-width: 70px !important;
}
