/* Global styles */
:root {
  --sidebar-width: 260px;
  --primary-color: #1a237e;
  --secondary-color: #3949ab;
  --accent-color: #5c6bc0;
  --text-light: #e8eaf6;
  --bg-light: #f5f7fa;
  --success-color: #2e7d32;
  --danger-color: #c62828;
  --warning-color: #f57f17;
  --info-color: #0277bd;
  --chart-blue-rgb: 54, 162, 235;
  --chart-green-rgb: 75, 192, 192;
  --chart-purple-rgb: 153, 102, 255;
  --chart-orange-rgb: 242, 142, 43;
}

body {
  font-family: 'Inter', Arial, Helvetica, sans-serif;
  background: var(--bg-light);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  padding: 2rem;
  margin-top: 76px; /* Increased from 56px to match flashbar */
}

/* Center box for login & forms */
.center-box {
  max-width: 400px;
  margin: 5vh auto;
  padding: 2rem;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.1);
  border-radius: 8px;
}

/* Sidebar */
#sidebar {
  position: fixed;
  top: 0;
  left: calc(-1 * var(--sidebar-width));
  width: var(--sidebar-width);
  height: 100%;
  background: var(--primary-color);
  color: var(--text-light);
  transition: left 0.3s ease;
  z-index: 1030;
  display: flex;
  flex-direction: column;
}

#sidebar.show {
  left: 0;
}

.sidebar-header {
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand {
  font-size: 1.25rem;
  font-weight: 600;
  color: #fff;
}

.sidebar-menu {
  padding: 1rem 0;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Custom scrollbar for sidebar */
.sidebar-menu::-webkit-scrollbar {
  width: 6px;
}

.sidebar-menu::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

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

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

#sidebar a {
  color: var(--text-light);
  text-decoration: none;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.2s ease;
}

#sidebar a i {
  font-size: 1.1rem;
}

#sidebar a.active,
#sidebar a:hover {
  background: var(--secondary-color);
  color: #fff;
}

/* Sidebar Dropdown */
.sidebar-dropdown {
  position: relative;
}

.sidebar-dropdown-toggle {
  color: var(--text-light);
  text-decoration: none;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.2s ease;
  cursor: pointer;
  justify-content: space-between;
}

.sidebar-dropdown-toggle:hover {
  background: var(--secondary-color);
  color: #fff;
}

.sidebar-dropdown-toggle i:last-child {
  transition: transform 0.2s ease;
}

.sidebar-dropdown.active .sidebar-dropdown-toggle i:last-child {
  transform: rotate(180deg);
}

.sidebar-dropdown-menu {
  display: none;
  background: rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: all 0.3s ease;
}

.sidebar-dropdown.active .sidebar-dropdown-menu {
  display: block;
}

.sidebar-dropdown-item {
  color: var(--text-light);
  text-decoration: none;
  padding: 0.5rem 1.25rem 0.5rem 2.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.sidebar-dropdown-item:hover {
  background: var(--secondary-color);
  color: #fff;
}

.sidebar-dropdown-item.active {
  background: var(--accent-color);
  color: #fff;
}

/* Overlay */
#overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  z-index: 1029;
  transition: opacity 0.3s ease;
}

#overlay.show {
  display: block;
}

/* Navbar */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1020;
  background: #fff !important;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.navbar-brand {
  font-weight: 600;
}

/* Flash messages */
#flashbar {
  position: fixed;
  top: 76px; /* Increased from 56px to add spacing */
  left: 0;
  right: 0;
  z-index: 1080;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

#flashbar .alert {
  margin: 0 auto;
  max-width: 640px;
  width: 100%;
  border-radius: 0.75rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  animation: slideIn 0.3s ease-out;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-left: 4px solid;
}

@keyframes slideIn {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.alert {
  border: none;
  font-weight: 500;
}

.alert-success {
  background: #e8f5e9;
  color: var(--success-color);
  border-left-color: var(--success-color);
}

.alert-danger {
  background: #ffebee;
  color: var(--danger-color);
  border-left-color: var(--danger-color);
}

.alert-warning {
  background: #fff8e1;
  color: var(--warning-color);
  border-left-color: var(--warning-color);
}

.alert-info {
  background: #e3f2fd;
  color: var(--info-color);
  border-left-color: var(--info-color);
}

/* Tables */
.table {
  background: #fff;
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  border-collapse: separate;
  border-spacing: 0;
}

.table th {
  background: var(--bg-light);
  font-weight: 600;
  padding: 1rem;
  border-bottom: 2px solid rgba(0,0,0,0.05);
}

.table td {
  padding: 1rem;
  vertical-align: middle;
}

.table-striped > tbody > tr:nth-of-type(odd) {
  --bs-table-accent-bg: #f8f9fc;
}

.table-hover tbody tr:hover {
  background: rgba(92, 107, 192, 0.05);
}

/* Buttons */
.btn {
  border-radius: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-weight: 500;
  transition: all 0.2s ease;
  text-transform: none;
  letter-spacing: 0.3px;
}

.btn-primary {
  background: var(--secondary-color);
  border-color: var(--secondary-color);
  box-shadow: 0 2px 4px rgba(57, 73, 171, 0.2);
}

.btn-primary:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(57, 73, 171, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(57, 73, 171, 0.2);
}

/* Form controls */
.form-control {
  border-radius: 0.5rem;
  padding: 0.625rem 1rem;
  border: 1px solid rgba(0,0,0,0.1);
  transition: all 0.2s ease;
}

.form-control:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 0.2rem rgba(92, 107, 192, 0.15);
}

/* Cards */
.card {
  border-radius: 0.75rem;
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

.card-header {
  background: var(--bg-light);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  padding: 1rem 1.25rem;
  font-weight: 600;
}

/* Footer */
.footer {
  background: #fff;
  border-top: 1px solid rgba(0,0,0,0.05);
  padding: 1rem 0;
  margin-top: auto;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  main {
    padding: 1rem;
  }
  
  .table-responsive {
    margin: 0 -1rem;
  }
  
  #flashbar {
    padding: 0.5rem;
  }
}

/* Navbar dropdown fixes */
.navbar .dropdown-menu {
  z-index: 1100;
  min-width: 200px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.navbar .dropdown-menu .dropdown-item {
  transition: background 0.2s, color 0.2s;
}

.navbar .dropdown-menu .dropdown-item:hover,
.navbar .dropdown-menu .dropdown-item:focus {
  background: var(--secondary-color);
  color: #fff;
}

.navbar .dropdown-menu .dropdown-item.text-danger:hover {
  background: #f8d7da;
  color: #842029;
}

.navbar .dropdown-toggle {
  outline: none;
  box-shadow: none !important;
}

.dashboard-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

@media (min-width: 576px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 768px) {
  .dashboard-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 992px) {
  .dashboard-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  .dashboard-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.dashboard-grid-item {
  height: 100%;
}

.dashboard-grid-link {
  display: block;
  height: 100%;
  color: inherit;
}

.dashboard-grid-link:hover {
  color: inherit;
}

/* Fix for dropdown alignment for all users */
.navbar .dropdown-menu-end {
  right: 0;
  left: auto;
}

/* Ensure dropdown is always above sidebar and overlay */
.navbar, .navbar .dropdown-menu {
  z-index: 1100 !important;
}

/* Modal height and scroll fix */
.modal-dialog {
  max-width: 700px;
  margin-top: 100px;
}
.modal-content {
  max-height: 90vh;
  overflow: hidden;
}
.modal-body {
  max-height: 60vh;
  overflow-y: auto;
}

/* Ensure modal input groups align with full-width controls */
.modal-body .input-group {
  width: 100%;
}

@media (max-width: 768px) {
  .modal-dialog {
    margin-top: 120px;
  }
}

/* Pagination styles */
.pagination {
  margin: 2rem 0;
  padding: 1rem;
  background: #fff;
  border-radius: 0.75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.pagination .page-link {
  padding: 0.5rem 1rem;
  color: var(--secondary-color);
  border: 1px solid rgba(0,0,0,0.1);
  margin: 0 0.25rem;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
}

.pagination .page-link:hover {
  background: var(--secondary-color);
  color: #fff;
  border-color: var(--secondary-color);
}

.pagination .page-item.disabled .page-link {
  background: #f8f9fa;
  color: #6c757d;
  border-color: rgba(0,0,0,0.1);
}

.pagination .page-item.active .page-link {
  background: var(--secondary-color);
  color: #fff;
  border-color: var(--secondary-color);
}

/* Ensure pagination is always visible */
.table-responsive {
  margin-bottom: 0;
}

/* Add spacing between table and pagination */
.table-responsive + nav {
  margin-top: 1rem;
}

.hover-white:hover { color: #fff !important; }

/* Ensure alert dropdown items turn white on hover */
#alertDropdown .dropdown-item:hover {
  color: #fff !important;
}

/* Dashboard layout helpers */
.dashboard-card {
  min-height: 340px;
}

.dashboard-card .card-body {
  display: flex;
  flex-direction: column;
}

.dashboard-card canvas,
.dashboard-card .table-responsive {
  flex: 1 1 auto;
}

/* Billing list layout */
.bill-header {
  background: #fff;
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.bill-header__eyebrow {
  letter-spacing: 0.08em;
}

.bill-header__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 0.75rem;
  color: #5f6b7d;
}

.bill-header__meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(26, 35, 126, 0.08);
}

.bill-header__meta-item i {
  font-size: 1rem;
  color: var(--secondary-color);
}

.bill-header__actions {
  display: flex;
  justify-content: flex-start;
}

.bill-header__buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.bill-header__buttons .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(26, 35, 126, 0.15);
}

.bill-header__buttons .btn-outline-primary {
  box-shadow: 0 6px 20px rgba(26, 35, 126, 0.08);
}

.bill-toolbar {
  background: #fff;
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  display: grid;
  gap: 1rem;
}

.bill-toolbar__filter,
.bill-toolbar__search,
.bill-toolbar__per-page {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.bill-toolbar__per-page select {
  max-width: 100%;
}

.bill-summary {
  background: #fff;
  border-radius: 0.85rem;
  padding: 1rem 1.5rem;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.05);
}

@media (min-width: 576px) {
  .bill-header__buttons {
    flex-direction: row;
    justify-content: flex-end;
  }
}

@media (min-width: 768px) {
  .bill-toolbar {
    grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) minmax(0, 1fr);
    align-items: end;
  }

  .bill-toolbar__per-page {
    align-items: flex-end;
  }

  .bill-toolbar__per-page select {
    min-width: 140px;
  }
}

@media (min-width: 992px) {
  .bill-header {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
  }

  .bill-header__info {
    max-width: 60ch;
  }

  .bill-header__actions {
    justify-content: flex-end;
    align-items: center;
  }

  .bill-header__buttons {
    width: auto;
  }
}

/* Bill adjustments */
.bill-adjustments {
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: 0.75rem;
  background-color: var(--bs-body-bg, #fff);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.bill-adjustments__header .btn {
  align-self: flex-start;
}

.bill-adjustments__list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.bill-adjustment {
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: 0.65rem;
  background-color: var(--bs-tertiary-bg, #f8f9fa);
  padding: 1rem 1.25rem;
}

.bill-adjustment__content {
  display: grid;
  gap: 0.75rem;
}

.bill-adjustment__details {
  display: grid;
  gap: 0.5rem;
}

.bill-adjustment__field-label {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.15rem;
}

.bill-adjustment__field-value {
  font-weight: 600;
}

.bill-adjustment__actions {
  display: flex;
  justify-content: flex-start;
}

.bill-adjustments__empty {
  border: 1px dashed var(--bs-border-color, #dee2e6);
  border-radius: 0.65rem;
  padding: 1rem;
}

@media (min-width: 768px) {
  .bill-adjustment__content {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto;
    align-items: center;
  }

  .bill-adjustment__amount {
    text-align: right;
  }

  .bill-adjustment__actions {
    justify-content: flex-end;
  }

  .bill-adjustments__header {
    align-items: center;
  }

  .bill-adjustments__header .btn {
    align-self: initial;
  }
}
