:root {
  --sidebar-width: 260px;
  --header-height: 70px;
  --primary: #ff9f43;
  --primary-hover: #e68a2c;
  --text-color: #6e84a3;
  --heading-color: #3c4858;
  --bg-color: #f7f8fa;
  --sidebar-bg: #ffffff;
  --sidebar-link-color: #525f7f;
  --sidebar-link-active-color: var(--primary);
  --sidebar-link-active-bg: #fff2e7;
  --border-color: #e9ecef;
  --card-shadow: 0 0 35px 0 rgba(154, 161, 171, .15);
  --transition-speed: 0.3s;

  /* Status Colors */
  --success-bg: #e6f7f0;
  --success-text: #28a745;
  --danger-bg: #fdeaea;
  --danger-text: #f44336;
  --info-bg: #e8f7fe;
  --info-text: #03a9f4;
  --warning-bg: #fff8e1;
  --warning-text: #ff9800;

  /* Dashboard Card Colors */
  --card-color-1: #ff9f43;
  --card-color-2: #2c3e50;
  --card-color-3: #1abc9c;
  --card-color-4: #3498db;
}

body {
  background-color: var(--bg-color);
  font-family: 'Poppins', sans-serif;
  color: var(--text-color);
  margin: 0;
}

/* Sidebar Container  */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg); /* Variable Updated */
  border-right: 1px solid var(--border-color);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1045;
  display: flex;
  flex-direction: column;
  transition: all var(--transition-speed) ease;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
}

.main-content-wrapper {
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition-speed) ease;
  min-height: 100vh;
  padding-bottom: 20px;
}

.sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-width));
}

.main-content-wrapper.expanded {
  margin-left: 0;
}

.sidebar-header {
  height: auto;
  min-height: var(--header-height);
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--heading-color); /* Updated: Dark mode එකේදි පේන්න */
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.brand-dot {
  color: var(--primary);
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-color); /* Updated */
  display: block;
  font-weight: 500;
}

.sidebar-nav-container {
  flex-grow: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
}

.sidebar-nav-container::-webkit-scrollbar {
  width: 5px;
}

.sidebar-nav-container::-webkit-scrollbar-thumb {
  background: var(--border-color); /* Updated */
  border-radius: 10px;
}

.sidebar .dropdown-toggle::after {
  display: none !important;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  background: var(--sidebar-bg); /* Updated from #fdfdfd */
  flex-shrink: 0;
}

.sidebar-heading {
  color: var(--text-color); /* Updated */
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.5rem 10px;
  margin-top: 10px;
  opacity: 0.8;
}

.nav-link {
  color: var(--sidebar-link-color);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 8px;
  padding: 10px 15px;
  margin-bottom: 4px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
}

.nav-link:hover {
  color: var(--primary);
  background: var(--bg-color);
  transform: translateX(5px);
}

.nav-link.active {
  color: var(--sidebar-link-active-color);
  background: var(--sidebar-link-active-bg);
  font-weight: 600;
}

.nav-link i {
  width: 25px;
  text-align: center;
}

.submenu-container {
  display: none;
  padding-left: 10px;
  background: transparent;
  margin-left: 10px;
  border-left: 2px solid var(--border-color);
}

.submenu-container.show {
  display: block;
  animation: slideDown 0.3s ease;
}

.submenu-link {
  font-size: 0.85rem !important;
  padding: 8px 15px !important;
  color: var(--text-color) !important; /* Updated */
}

.submenu-link.active {
  color: var(--primary) !important;
  font-weight: 600;
}

.arrow-icon {
  margin-left: auto;
  font-size: 0.7rem;
  transition: transform 0.3s ease;
}

.nav-link[aria-expanded="true"] .arrow-icon {
  transform: rotate(90deg);
}

/* Header Container */
.main-header {
  height: var(--header-height);
  background: var(--sidebar-bg); /* Updated from #ffffff */
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.04);
  z-index: 1030;
  transition: margin-left var(--transition-speed) ease;
  border-bottom: 1px solid var(--border-color); /* Added border consistency */
}

/* Sidebar Toggle Button */
.sidebar-toggle {
  color: var(--heading-color);
  padding: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transition: background 0.3s;
}

.sidebar-toggle:hover {
  background-color: var(--bg-color);
  color: var(--primary);
}

/* Header Stat Pills */
.header-stat-pill {
  padding: 6px 15px;
  border-radius: 30px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  background: var(--bg-color); /* Added background for visibility */
}

/* Icon Buttons */
.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-color) !important;
  transition: all 0.2s;
}

.icon-btn:hover,
.icon-btn[aria-expanded="true"] {
  background-color: var(--info-bg);
  color: var(--primary) !important;
}

/* User Avatar */
.user-avatar-container {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  border: 2px solid var(--sidebar-bg); /* Updated */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-initials {
  width: 100%;
  height: 100%;
  background-color: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.1rem;
}

/* Dropdowns Animation */
.dropdown-menu {
  animation: slideUp 0.3s ease;
  border-radius: 10px;
  background-color: var(--sidebar-bg); /* Updated */
  border-color: var(--border-color);
}

.dropdown-item {
    color: var(--text-color);
}

.dropdown-item:hover {
    background-color: var(--bg-color);
    color: var(--heading-color);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-item:active {
  background-color: var(--sidebar-link-active-bg);
  color: var(--primary);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header h1,
.page-header h2 {
  color: var(--heading-color);
}

/* Cards */
.card {
  border: none;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  margin-bottom: 1.5rem;
  background-color: var(--sidebar-bg); /* Very Important Update */
  color: var(--text-color);
}

.card-header {
  background-color: var(--sidebar-bg) !important; /* Updated from #ffffff */
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem;
  color: var(--heading-color);
}

.table-light {
  background-color: var(--bg-color) !important; /* Updated from #f8f9fc */
  color: var(--heading-color);
}

table.dataTable {
  border-collapse: collapse !important;
}

table.dataTable thead th {
  font-weight: 600;
  color: var(--heading-color);
  border-bottom: 2px solid var(--border-color) !important;
  padding: 12px;
}

table.dataTable tbody td {
  vertical-align: middle;
  padding: 12px;
  color: var(--text-color);
  border-bottom: 1px solid var(--border-color);
}

.action-btn {
  color: var(--text-color);
  border-radius: 6px;
  padding: 5px 10px;
  transition: 0.2s;
}

.action-btn:hover {
  background-color: var(--bg-color);
  color: var(--primary);
}

.dataTables_wrapper .dataTables_paginate .page-link {
  color: var(--primary);
  background-color: var(--sidebar-bg); /* Updated */
  border-radius: 50% !important;
  margin: 0 3px;
  border: none;
  width: 35px;
  height: 35px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dataTables_wrapper .dataTables_paginate .page-item.active .page-link {
  background-color: var(--primary);
  color: #fff;
}

/* Badges */
.badge.status-badge,
.badge.payment-badge {
  padding: 6px 12px;
  border-radius: 30px;
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.3px;
}

.badge.status-badge.success,
.badge.status-badge.active,
.badge.status-badge.completed,
.badge.payment-badge.success,
.badge.payment-badge.paid {
  background-color: var(--success-bg);
  color: var(--success-text);
}

.badge.status-badge.danger,
.badge.status-badge.inactive,
.badge.status-badge.cancelled,
.badge.payment-badge.danger,
.badge.payment-badge.unpaid {
  background-color: var(--danger-bg);
  color: var(--danger-text);
}

.badge.status-badge.pending,
.badge.payment-badge.pending {
  background-color: var(--info-bg);
  color: var(--info-text);
}

.badge.payment-badge.warning,
.badge.payment-badge.partial {
  background-color: var(--warning-bg);
  color: var(--warning-text);
}

/* Stat Cards */
.stat-card {
  border-radius: 12px;
  padding: 25px;
  color: #fff;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.stat-card .stat-icon {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  background-color: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  margin-top: 15px;
  display: block;
}

/* Stat Card Colors - Keeping original specific colors */
.stat-card.bg-orange { background-color: var(--card-color-1); }
.stat-card.bg-dark-blue { background-color: var(--card-color-2); }
.stat-card.bg-teal { background-color: var(--card-color-3); }
.stat-card.bg-blue { background-color: var(--card-color-4); }

.user-avatar {
  width: 35px;
  height: 35px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid var(--sidebar-bg); /* Updated */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* --- FOOTER STYLES --- */

.main-footer {
  background-color: var(--sidebar-bg); /* Updated from #ffffff */
  border-top: 1px solid var(--border-color);
  padding: 15px 0;
  position: fixed;
  bottom: 0;
  right: 0;
  left: 260px;
  z-index: 1000;
  transition: left 0.3s ease;
  color: var(--text-color);
}

.footer-link {
  color: var(--primary) !important;
  text-decoration: underline !important;
}

.footer-link:hover {
  color: var(--primary-hover) !important;
  text-decoration: underline !important;
}

.main-content-wrapper.expanded ~ .main-footer,
.main-content-wrapper.expanded .main-footer {
  left: 0;
}