/* ========================================
   AIERPP Dark Bluish Theme
   Modern, Premium Dark Theme with Sidebar Layout
   ======================================== */

/* ========================================
   Layout Variables Only (No Colors)
   ======================================== */
:root {
    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    
    /* Topbar */
    --topbar-height: 64px;
    
    /* Transitions */
    --transition-speed: 0.3s;
}

/* Note: All colors are now defined in theme-tokens.css */

/* ========================================
   Global Styles
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-muted);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

/* ========================================
   Sidebar Styles
   ======================================== */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-speed) ease, transform var(--transition-speed) ease;
    z-index: 1000;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Sidebar Header */
.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--sidebar-border);
    gap: 12px;
    position: relative;
}

.sidebar-logo {
    height: 32px;
    width: auto;
    flex-shrink: 0;
}

.sidebar-logo-icon {
    font-size: 24px;
    color: var(--primary);
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--sidebar-text);
    white-space: nowrap;
    transition: opacity var(--transition-speed) ease;
}

.sidebar.collapsed .sidebar-title {
    opacity: 0;
    display: none;
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
    margin-left: auto;
}

.sidebar-toggle-btn:hover {
    background-color: var(--sidebar-hover);
    color: var(--text);
}

.sidebar.collapsed .sidebar-toggle-btn i {
    transform: rotate(180deg);
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 0;
}

/* Sidebar Search */
.sidebar-search-wrapper {
    padding: 0 16px 16px;
    position: relative;
}

.sidebar-search {
    width: 100%;
    padding: 10px 12px 10px 38px;
    background-color: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    transition: all 0.2s ease;
}

.sidebar-search:focus {
    outline: none;
    border-color: var(--primary);
    background-color: var(--surface-hover);
    box-shadow: var(--focus-ring);
}

.sidebar-search-icon {
    position: absolute;
    left: 28px;
    top: 12px;
    color: var(--text-muted);
    font-size: 14px;
    pointer-events: none;
}

.sidebar.collapsed .sidebar-search-wrapper {
    display: none;
}

/* Sidebar Menu */
.sidebar-menu {
    list-style: none;
    padding: 0 12px;
}

.sidebar-menu-item {
    margin-bottom: 4px;
}

.sidebar-menu-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none !important;
    border-radius: 8px;
    transition: all 0.2s ease;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
}

.sidebar-menu-link:hover,
.sidebar-menu-link:focus {
    text-decoration: none !important;
}

.sidebar-menu-link i {
    font-size: 18px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-menu-link span {
    white-space: nowrap;
    transition: opacity var(--transition-speed) ease;
}

.sidebar.collapsed .sidebar-menu-link span {
    opacity: 0;
    display: none;
}

.sidebar.collapsed .sidebar-menu-link .submenu-arrow {
    display: none;
}

.sidebar-menu-link:hover {
    background-color: var(--sidebar-hover);
    color: var(--text);
    text-decoration: none;
}

.sidebar-menu-link.active {
    background-color: var(--sidebar-active);
    color: var(--primary);
    border-left: 3px solid var(--primary);
}

.sidebar-menu-link.active i {
    color: var(--primary-contrast);
}

.sidebar-menu-item.hidden {
    display: none;
}

/* Submenu Styles */
.sidebar-menu-item.has-submenu .sidebar-menu-link {
    position: relative;
}

.sidebar-menu-link .submenu-arrow {
    margin-left: auto;
    font-size: 12px;
    transition: transform 0.3s ease;
}

.sidebar-menu-item.has-submenu .sidebar-menu-link.active .submenu-arrow {
    transform: rotate(180deg);
}

.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sidebar-submenu.show {
    max-height: 500px;
}

.sidebar-submenu-item {
    margin: 0;
}

.sidebar-submenu-link {
    display: block;
    padding: 10px 16px 10px 52px;
    color: var(--text-muted);
    text-decoration: none !important;
    font-size: 13px;
    transition: all 0.2s ease;
    border-radius: 8px;
    margin: 2px 12px;
}

.sidebar-submenu-link:hover,
.sidebar-submenu-link:focus {
    background-color: var(--surface-hover);
    color: var(--text);
    text-decoration: none !important;
}

.sidebar-submenu-link.active {
    background-color: var(--primary);
    color: var(--primary-contrast);
}

.sidebar.collapsed .sidebar-submenu {
    display: none;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-user-avatar i {
    color: var(--primary-contrast);
    font-size: 18px;
}

.sidebar-user-info {
    overflow: hidden;
    transition: opacity var(--transition-speed) ease;
}

.sidebar.collapsed .sidebar-user-info {
    opacity: 0;
    display: none;
}

.sidebar-user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========================================
   Main Content Styles
   ======================================== */

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-speed) ease;
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* ========================================
   Topbar Styles
   ======================================== */

.topbar {
    height: var(--topbar-height);
    background-color: var(--topbar-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mobile-toggle-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.mobile-toggle-btn:hover {
    background-color: var(--surface-hover);
    color: var(--text);
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Topbar Search */
.topbar-search {
    position: relative;
    display: flex;
    align-items: center;
}

.topbar-search i {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 14px;
}

.topbar-search input {
    padding: 8px 16px 8px 36px;
    width: 280px;
    background-color: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    transition: all 0.2s ease;
}

.topbar-search input:focus {
    outline: none;
    border-color: var(--primary);
    width: 320px;
}

/* Topbar Icon Buttons */
.topbar-icon-btn {
    position: relative;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.topbar-icon-btn:hover {
    background-color: var(--surface-hover);
    color: var(--text);
}

.badge-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background-color: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--topbar-bg);
}

.notification-dropdown .dropdown-menu {
    width: 340px;
    padding: 0;
    border-radius: 12px;
    background-color: var(--bg-muted);
    border: 1px solid var(--border);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.35);
    overflow: hidden;
    max-height: 420px;
}

.notification-menu-header,
.notification-menu-footer {
    padding: 12px 16px;
    background-color: var(--surface-alt);
    border-bottom: 1px solid var(--border);
}

.notification-menu-footer {
    border-top: 1px solid var(--border);
    border-bottom: none;
}

.notification-menu-body {
    max-height: 320px;
    overflow-y: auto;
}

.notification-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.notification-item {
    border-bottom: 1px solid var(--border);
}

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

.notification-item.is-unread {
    background-color: var(--surface-hover);
}

.notification-link {
    display: block;
    padding: 12px 16px;
    color: var(--text);
    text-decoration: none;
}

.notification-link:hover {
    background-color: var(--surface-hover);
    text-decoration: none;
}

.notification-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.notification-message {
    font-size: 0.8rem;
}

.notification-meta {
    font-size: 0.75rem;
    margin-top: 6px;
}

.notification-empty {
    font-size: 0.85rem;
}

.notification-menu-body::-webkit-scrollbar {
    width: 6px;
}

.notification-menu-body::-webkit-scrollbar-thumb {
    background-color: rgba(148, 163, 184, 0.4);
    border-radius: 6px;
}

/* Profile Dropdown */
.profile-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.profile-btn:hover {
    background-color: var(--surface-hover);
}

.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.sidebar-user-avatar img,
.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.profile-avatar i {
    color: var(--primary-contrast);
    font-size: 16px;
}

.profile-menu {
    background-color: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 0;
    min-width: 220px;
    margin-top: 8px;
}

.profile-menu-header {
    padding: 12px 16px;
}

.profile-menu-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.profile-menu-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.profile-menu .dropdown-item {
    padding: 10px 16px;
    color: var(--text-muted);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.profile-menu .dropdown-item:hover {
    background-color: var(--surface-hover);
    color: var(--text);
}

.profile-menu .dropdown-item i {
    width: 18px;
    text-align: center;
}

.profile-menu .dropdown-divider {
    border-color: var(--border);
    margin: 8px 0;
}

/* ========================================
   Page Content Styles
   ======================================== */

.page-content {
    flex: 1;
    padding: 24px;
    background-color: var(--bg);
}

/* ========================================
   Cards & Components
   ======================================== */

.card {
    background-color: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.2s ease;
}

.card:hover {
    border-color: var(--border-light);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Buttons */
.btn-outline-light {
    border-color: var(--primary);
    color: var(--primary);
    transition: all 0.2s ease;
}

.btn-outline-light:hover {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--primary-contrast);
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* Tables */
.table-dark {
    --bs-table-bg: var(--table-bg);
    --bs-table-striped-bg: var(--table-stripe);
    --bs-table-hover-bg: var(--table-hover);
    --bs-table-border-color: var(--table-border);
}

/* Forms */
.form-control,
.form-select {
    background-color: var(--bg-alt);
    border-color: var(--border);
    color: var(--text);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--surface-hover);
    border-color: var(--primary);
    color: var(--text);
    box-shadow: var(--input-focus-ring);
}

.form-control::placeholder {
    color: var(--text-muted);
}

/* Alerts */
.alert-warning {
    background-color: rgba(245, 158, 11, 0.1);
    border-color: var(--warning);
    color: var(--warning);
}

.alert-danger {
    background-color: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: var(--danger);
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.1);
    border-color: var(--success);
    color: var(--success);
}

/* ========================================
   Footer Styles
   ======================================== */

.page-footer {
    background-color: var(--bg-muted);
    border-top: 1px solid var(--border);
    padding: 16px 24px;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
}

.footer-right {
    display: flex;
    gap: 20px;
}

.footer-right a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-right a:hover {
    color: var(--primary);
}

/* ========================================
   Modal Styles - Override Bootstrap
   ======================================== */
.modal-content,
.modal-content.bg-dark,
.modal-content.bg-light,
div.modal-content,
.modal-dialog .modal-content {
  background-color: var(--modal-bg) !important;
  border-color: var(--card-border) !important;
  color: var(--text) !important;
}

.modal-header,
.modal-header.bg-dark,
.modal-header.bg-light,
div.modal-header {
  background-color: var(--modal-bg) !important;
  border-bottom-color: var(--border) !important;
  color: var(--text) !important;
}

.modal-body,
.modal-body.bg-dark,
.modal-body.bg-light,
div.modal-body {
  background-color: var(--modal-bg) !important;
  color: var(--text) !important;
}

.modal-footer,
.modal-footer.bg-dark,
.modal-footer.bg-light,
div.modal-footer {
  background-color: var(--modal-bg) !important;
  border-top-color: var(--border) !important;
  color: var(--text) !important;
}

.modal-title,
h5.modal-title {
  color: var(--heading) !important;
}

.modal .form-label,
.modal label.form-label,
.modal label:not(.form-check-label) {
  color: var(--text) !important;
  font-weight: 500;
}

.modal .text-muted,
.modal .text-secondary,
.modal small,
.modal .small {
  color: var(--text-muted) !important;
}

/* All text in modals - high specificity */
.modal,
.modal *:not(.btn):not(.badge):not(.alert):not(.btn-close) {
  color: var(--text);
}

.modal .text-muted,
.modal .text-secondary {
  color: var(--text-muted) !important;
}

/* Section headings like "Permissions", "Dashboard", etc. */
.modal h6,
.modal .h6,
.modal h5,
.modal .h5,
.modal strong,
.modal b {
  color: var(--text) !important;
  font-weight: 600;
}

/* Permissions section specific styling */
.modal .border.rounded {
  background-color: var(--surface-alt) !important;
  border-color: var(--border) !important;
}

.modal .border.rounded * {
  color: var(--text) !important;
}

.modal .border.rounded strong {
  color: var(--text) !important;
}

.modal .border.rounded small {
  color: var(--text-muted) !important;
}

.modal .border.rounded .form-check-label {
  color: var(--text) !important;
}

/* ========================================
   Responsive Styles
   ======================================== */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-toggle-btn {
        display: block;
    }
    
    .topbar-search {
        display: none;
    }
    
    .page-title {
        font-size: 18px;
    }
    
    .page-content {
        padding: 16px;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
}

@media (max-width: 576px) {
    .topbar {
        padding: 0 16px;
    }
    
    .topbar-right {
        gap: 8px;
    }
    
    .profile-btn span {
        display: none;
    }
}

/* ========================================
   Utilities
   ======================================== */

.text-primary { color: var(--text) !important; }
.text-secondary { color: var(--text-muted) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-accent { color: var(--primary) !important; }
.bg-primary { background-color: var(--bg) !important; }
.bg-secondary { background-color: var(--bg-muted) !important; }
.bg-tertiary { background-color: var(--bg-alt) !important; }

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

