/* ========================================
   GLOBAL RESET & BASE STYLES
   ======================================== */
:root {
    /* Layout */
    --navbar-height: 60px;
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 60px;
    /*--sidebar-width: 220px;*/
    --font-size-base: 0.9rem;
    /* Spacing */
    --spacing-sm: 0.4rem;
    --spacing-md: 1rem;
    --spacing-lg: 2rem;
    
    /* Transitions */
    --transition-fast: 0.2s;
    --transition-normal: 0.5s;
}
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;

}

/* ========================================
   NAVBAR STYLES - UPDATED DESIGN
   ======================================== */
.navbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--navbar-height);
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1000;
    box-shadow: var(--shadow);
    transition: left var(--transition-normal);
    border-bottom: 1px solid var(--border-color);
}

/* CHANGED: Adjust navbar when body has sidebar-collapsed class */
body.sidebar-collapsed .navbar {
    left: var(--sidebar-collapsed-width);
}

/* Mobile Toggle Button */
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background-color 0.3s ease;
    color: var(--text-primary);
}

.mobile-toggle:hover {
    background: var(--hover-background);
}

.mobile-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--icon-primary-color);
    font-size: 20px;
    font-weight: bold;
}

/* Navbar page Title */
.nvbar_page-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
    margin: 0;
}

/* User Info Section */
.navbar_user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Icon Buttons (Notifications & Messages) */
.icon-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.icon-button:hover {
    background: var(--hover-background);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    background: var(--danger);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    color: var(--white);
    padding: 0 5px;
}

/* Coin Balance */
.coin-balance {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.coin-balance i {
    color: var(--coin-color);
    font-size: 1rem;
}

/* User Avatar */
.navbar_user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--icon-primary-color);
    font-size: 1.9rem;
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

/* Logo Image */
.navbar-logo {
    height: 40px;
    width: auto;
    object-fit: contain;
}

/* ========================================
   NAV ITEMS & SUBMENU
   ======================================== */
.nav-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 1rem; /* REDUCED: from 12px */
    cursor: pointer;
    color: var(--text-primary);
    transition: background 0.3s, color 0.3s;
    position: relative;
}

.nav-item:hover {
    background: var(--hover-background);
    color: var(--primary-color);
}

.nav-text {
    flex: 1;
    margin-left: 10px;
    transition: opacity 0.3s;
}

.nav-arrow {
    transition: transform 0.3s ease;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.submenu {
    max-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-left: 3px solid var(--primary-color);
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
    padding: 0;
    margin-left: 0;
}

.nav-item.active + .submenu {
    max-height: 500px;
    padding: 4px 0; /* REDUCED: from 5px */
}

.nav-item.active .nav-arrow {
    transform: rotate(90deg);
    color: var(--primary-color);
}

.submenu-item {
    padding: 8px 2rem; /* REDUCED: from 10px */
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.85rem; /* REDUCED: from 0.9rem */
    transition: all 0.2s;
    display: block;
}

.submenu-item:hover {
    background: var(--hover-background);
    color: var(--primary-color);
}

.submenu-item.active {
    background: var(--hover-background);
    color: var(--primary-color);
    font-weight: 600;
    border-left: 3px solid var(--primary-color);
}

/* ========================================
   LAYOUT STRUCTURE - FIXED
   ======================================== */
.layout {
    display: flex;
    margin-top: var(--navbar-height);
    margin-left: var(--sidebar-width);
    min-height: calc(100vh - var(--navbar-height));
    transition: margin-left var(--transition-normal);
}

/* CHANGED: Adjust layout when body has sidebar-collapsed class */
body.sidebar-collapsed .layout {
    margin-left: var(--sidebar-collapsed-width);
}

/* =============================================
   ✅ THEME-AWARE TOAST STYLES
   ============================================= */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast-message {
  background-color: var(--primary-color, #2563eb);
  color: var(--text-on-primary, #ffffff);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md, 0.75rem);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 240px;
  opacity: 0.97;
  transition: opacity 0.5s ease, transform 0.5s ease;
  backdrop-filter: blur(6px);
}

/* 🌗 Auto-dark/light adjustments */
[data-theme="dark"] .toast-message {
  background-color: var(--primary-color-dark, #1d4ed8);
  color: var(--text-on-dark, #e5e7eb);
  box-shadow: 0 2px 8px rgba(255,255,255,0.1);
}

[data-theme="light"] .toast-message {
  background-color: var(--primary-color-light, #3b82f6);
  color: var(--text-on-light, #fff);
}

.toast-message.fade-out {
  opacity: 0;
  transform: translateY(-10px);
}

.toast-progress {
  height: 4px;
  background-color: rgba(255,255,255,0.85);
  border-radius: 2px;
  width: 100%;
  transition: width 0s;
}

.academic-section-banner {
  background: var(--primary-bg);
  color: var(--text-light);
  padding: 0.4rem 0.8rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  margin: 0.8rem 1rem;
  display: inline-block;
}
.academic-section-banner .label {
  opacity: 0.8;
  font-weight: 400;
  margin-right: 0.3rem;
}



/* ========================================
   SIDEBAR STYLES - OPTIMIZED SPACING
   ======================================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-right: 1px solid var(--border-color);
    transition: width var(--transition-normal);
    overflow-x: hidden;
    overflow-y: auto;
    z-index: 1001;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .institution-name,
.sidebar.collapsed .user-name,
.sidebar.collapsed .coin-text {
    display: none;
}

.sidebar.collapsed .submenu {
    display: none;
}

.sidebar.collapsed .nav-arrow {
    display: none;
}

/* REDUCED: Sidebar header padding */
.sidebar-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0.25rem 0.5rem;
    margin-bottom: 0;
}

.desktop-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease-in-out;
}

.desktop-toggle:hover {
    background-color: var(--hover-background);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.desktop-toggle:active {
    transform: scale(0.95);
}

.desktop-toggle i {
    font-size: 12px;
}

/* REDUCED: Proper alignment when sidebar is collapsed */
.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0.25rem;
}

.sidebar.collapsed .desktop-toggle {
    width: 24px;
    height: 24px;
}

/* REDUCED: Top section padding */
.sidebar-top {
    text-align: center;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

/* The wallet */
.sidebar-top .wallet i {
    color: var(--coin-color);
}

.sidebar-top .coin-text {
    color: var(--text-primary);
}

/* REDUCED: Profile image sizes */
.institution-logo, .profile-pic-lg {
    width: 60px; /* REDUCED: from 80px */
    height: 60px; /* REDUCED: from 80px */
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 0.4rem; /* REDUCED: from 0.5rem */
    transition: all 0.3s;
    border: 2px solid var(--border-color);
}

.sidebar.collapsed .institution-logo, 
.sidebar.collapsed .profile-pic-lg {
    width: 35px; /* REDUCED: from 40px */
    height: 35px; /* REDUCED: from 40px */
    margin-bottom: 0.15rem; /* REDUCED: from 0.2rem */
}

/* REDUCED: Text sizes */
.institution-name, .user-name {
    font-size: 0.9rem; /* REDUCED: from 1rem */
    margin: 0.15rem 0; /* REDUCED: from 0.2rem */
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.sidebar.collapsed .wallet {
    justify-content: center;
}

/* OPTIMIZED: Menu section - more compact */
.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.25rem 0; /* ADDED: Small vertical padding */
}

/* REDUCED: Menu item padding */
.sidebar-menu a:not(.submenu-item) {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 1rem; /* REDUCED: from 12px 1rem */
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
    border-left: 3px solid transparent;
    margin: 0.1rem 0; /* ADDED: Small margin between items */
}

.sidebar-menu a:not(.submenu-item):hover {
    background: var(--hover-background);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.sidebar-menu a:not(.submenu-item).active {
    background: var(--hover-background);
    border-left-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 600;
}

.sidebar-menu a:not(.submenu-item) i {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    color: var(--text-muted);
}

.sidebar-menu a:not(.submenu-item):hover i,
.sidebar-menu a:not(.submenu-item).active i {
    color: var(--primary-color);
}

/* REDUCED: Bottom section padding */
.sidebar-bottom {
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.4rem; /* REDUCED: from 0.5rem */
}

.profile-pic-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 8px;
    vertical-align: middle;
    border: 1px solid var(--border-color);
}

/* REDUCED: Bottom link padding */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px; /* REDUCED: from 8px 12px */
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
    border-radius: 6px;
}

.sidebar-link:hover {
    color: var(--primary-color);
    background: var(--hover-background);
}

.sidebar-link i {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    color: var(--text-muted);
}

.sidebar-logoutlink {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px; /* REDUCED: from 8px 12px */
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
    border-radius: 6px;
}

.sidebar-logoutlink:hover {
    color: var(--danger);
    background: var(--form-error-bg);
}

.sidebar-logoutlink i {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    color: var(--text-muted);
}

/* REDUCED: Theme switcher spacing */
.sidebar-theme-switcher {
    display: flex;
    justify-content: center;
    margin-top: 0.4rem; /* REDUCED: from 0.5rem */
    padding-top: 0.4rem; /* REDUCED: from 0.5rem */
    border-top: 1px solid var(--border-color);
}

.sidebar-theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 36px; /* REDUCED: from 40px */
    height: 36px; /* REDUCED: from 40px */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    color: var(--text-primary);
}

.sidebar-theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.sidebar-theme-toggle::before {
    content: '🌙';
    font-size: 1rem; /* REDUCED: from 1.1rem */
}

[data-theme="dark"] .sidebar-theme-toggle::before {
    content: '☀️';
}

/* Sidebar Scrollbar Styling */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========================================
   MAIN CONTENT AREA - FIXED
   ======================================== */
.content {
    flex: 1;
    padding: var(--spacing-lg);
    overflow-y: auto;
    background: var(--bg-secondary);
    width: 100%;
}

/* Content Container */
.content-container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Tablet */
@media (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }
    
    .content {
        padding: var(--spacing-md);
    }
}

/* Mobile */
@media (max-width: 768px) {
    .layout {
        margin-left: 0;
    }
    
    .navbar {
        left: 0;
        right: 0;
        padding: 0 1rem;
    }
    
    .mobile-toggle {
        display: flex;
    }
    
    .desktop-toggle {
        display: none;
    }
    
    .nvbar_page-title {
        display: none;
    }
    
    .user-name {
        display: none;
    }
    
    .user-actions {
        gap: 0.5rem;
    }
    
    .coin-balance {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .icon-button {
        width: 36px;
        height: 36px;
    }
    
    .sidebar {
        left: -250px; /* hidden */
        position: fixed;
        top: 0;
        width: 250px;
        height: 100%;
        z-index: 1002;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5);
        opacity: 0;
        visibility: hidden;
        z-index: 1001;
        transition: all 0.2s ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    .content {
        padding: var(--spacing-md) var(--spacing-sm);
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .navbar .logo {
        font-size: 1rem;
    }
    
    .nav-btn {
        font-size: 1.3rem;
        margin-right: var(--spacing-sm);
    }
    
    .content {
        padding: var(--spacing-sm);
    }
}

/* ADDED: Dynamic height adjustments */
@media (min-height: 900px) {
    .sidebar-top {
        padding: 1rem; /* Slightly more space on tall screens */
    }
    
    .sidebar-menu a:not(.submenu-item) {
        padding: 11px 1rem; /* Slightly more space on tall screens */
    }
}

@media (max-height: 600px) {
    .sidebar-header {
        padding: 0.5rem 1rem 0.25rem;
    }
    
    .sidebar-top {
        padding: 0.5rem 1rem;
    }
    
    .institution-logo, .profile-pic-lg {
        width: 50px;
        height: 50px;
        margin-bottom: 0.25rem;
    }
    
    .sidebar-menu a:not(.submenu-item) {
        padding: 8px 1rem;
    }
    
    .sidebar-bottom {
        padding: 0.5rem 1rem;
    }
}

/* ===== THEME TRANSITION ===== */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    :root {
        --background-color: white !important;
        --text-secondary: black !important;
        --shadow: none !important;
    }
    
    [data-theme="dark"] {
        --background-color: white !important;
        --text-secondary: black !important;
    }
}