/* Custom styles shared across the app (Bootstrap 5) */
:root {
  --brand-primary: #0d6efd; /* Bootstrap primary */
  --topbar-bg: #0b2239; /* dark blue tone */
  --sidebar-bg: #0f2a46;
  --sidebar-hover: #14375d;
  --sidebar-active: #1d4ed8; /* blue */
}

/* ========== Auth pages ========== */
body.bg-light {
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

.app-logo {
  width: 72px;
  height: 72px;
  color: #6c757d;
}

.auth-card {
  width: 100%;
  max-width: 480px;
  border-radius: .75rem;
}

.auth-title {
  font-weight: 600;
  color: #212529;
}

.form-text-help {
  font-size: .875rem;
}

.btn-primary {
  box-shadow: 0 2px 6px rgba(13, 110, 253, 0.3);
}

.footer-links a {
  text-decoration: none;
}

.input-error {
  color: #dc3545;
  font-size: .875rem;
}

/* ========== App shell (authenticated) ========== */
.app-shell { background-color: #f5f7fb; }

.app-topbar { 
  background-color: var(--topbar-bg); 
  position: sticky;
  top: 0;
  z-index: 1040;
  padding: 0.5rem 0;
}

.app-topbar .container-fluid {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.app-topbar .navbar-brand {
  color: white !important;
  font-size: 1.25rem;
  margin: 0;
  padding: 0;
}

.app-topbar .nav-link {
  color: white !important;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  transition: background-color 0.2s ease;
}

.app-topbar .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-toggle-btn {
  position: absolute;
  top: 8px;
  left: 220px; /* computed again by JS for accuracy */
  transition: left 0.3s ease-in-out;
  z-index: 1050;
  color: white !important;
  border: none;
  background: none;
  padding: 0.5rem;
}

.sidebar-toggle-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 0.375rem;
}

.app-body { min-height: calc(100vh - 56px); }

/* Sidebar */
.app-sidebar {
  width: 300px;
  background-color: var(--sidebar-bg);
  color: #e2e8f0;
  position: fixed;
  top: 56px;
  left: 0;
  height: calc(100vh - 56px);
  z-index: 1030;
  transition: transform .3s ease-in-out;
  overflow-y: auto;
  box-shadow: 2px 0 4px rgba(0,0,0,0.1);
}

.app-sidebar-inner {
  padding: 1rem 0;
  height: 100%;
}

.app-sidebar .nav-link {
  color: #cbd5e1;
  padding: .75rem 1.5rem;
  border-left: 3px solid transparent;
  display: flex;
  align-items: center;
  border-radius: 0;
  margin: 0 0.5rem;
  border-radius: 0.375rem;
  transition: all 0.2s ease;
  white-space: nowrap;
  min-height: 44px;
  text-decoration: none;
}

.app-sidebar .nav-link .bi { 
  font-size: 1.1rem; 
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.app-sidebar .nav-link span {
  margin-left: 0.75rem;
  font-weight: 500;
  flex-grow: 1;
}

.app-sidebar .nav-link:hover { 
  background-color: var(--sidebar-hover); 
  color: #fff; 
  transform: translateX(2px);
}

.app-sidebar .nav-link.active {
  background-color: rgba(29,78,216,.15);
  color: #fff;
  border-left-color: var(--sidebar-active);
  font-weight: 600;
}

.app-sidebar .nav-link.disabled { opacity: .6; cursor: not-allowed; }

/* Dropdown toggle styling */
.app-sidebar .nav-link.dropdown-toggle {
  cursor: pointer;
}

.app-sidebar .nav-link.dropdown-toggle::after {
  display: none; /* Hide default Bootstrap caret */
}

.app-sidebar .nav-link.dropdown-toggle .bi-chevron-down {
  font-size: 0.75rem;
  transition: transform 0.2s ease;
  margin-left: auto;
}

.app-sidebar .nav-link.dropdown-toggle[aria-expanded="true"] .bi-chevron-down {
  transform: rotate(180deg);
}

/* Sub-menu items styling */
.app-sidebar .nav-link-sub {
  padding-left: 3.5rem;
  font-size: 0.9rem;
  min-height: 40px;
}

.app-sidebar .nav-link-sub:hover {
  background-color: var(--sidebar-hover);
  color: #fff;
}

.app-sidebar .nav-link-sub.active {
  background-color: rgba(29,78,216,.2);
  color: #fff;
  border-left-color: var(--sidebar-active);
}
.app-sidebar .text-secondary { 
  color: #9fb2c8 !important; 
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  margin: 1rem 0 0.5rem 0;
  padding: 0 1.5rem;
}

/* Sidebar toggle states */
.app-sidebar.collapsed {
  width: 60px;
}

.app-sidebar.collapsed .nav-link span {
  display: none;
}

.app-sidebar.collapsed .text-secondary {
  display: none;
}

.app-sidebar.collapsed .nav-link {
  padding: .75rem 1rem;
  justify-content: center;
}

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

.app-sidebar.collapsed .nav-link.dropdown-toggle .bi-chevron-down {
  display: none;
}

/* Hide collapse menus when sidebar is collapsed (but not if they have .show class) */
.app-sidebar.collapsed .collapse:not(.show) {
  display: none !important;
}

/* Ensure collapse menus show when they have the .show class, even when sidebar is collapsed */
.app-sidebar .collapse.show {
  display: block !important;
}

/* Hide hover dropdown by default */
.hover-dropdown {
  display: none !important;
}

/* Collapsed sidebar hover dropdown */
.app-sidebar.collapsed .nav-item {
  position: relative;
}

.app-sidebar.collapsed .nav-item:hover .hover-dropdown,
.app-sidebar.collapsed .hover-dropdown:hover {
  display: block !important;
  position: fixed;
  left: 60px;
  background-color: var(--sidebar-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  min-width: 200px;
  padding: 0.5rem 0;
  z-index: 1060;
}

/* Add a transparent bridge to prevent dropdown from disappearing */
.app-sidebar.collapsed .nav-item::after {
  content: '';
  position: fixed;
  left: 60px;
  width: 200px;
  height: 100%;
  top: 0;
  pointer-events: none;
  z-index: 1059;
}

.app-sidebar.collapsed .nav-item:hover::after {
  pointer-events: auto;
}

.app-sidebar.collapsed .hover-dropdown .nav-link {
  padding: 0.75rem 1.5rem;
  justify-content: flex-start;
  margin: 0;
}

.app-sidebar.collapsed .hover-dropdown .nav-link span {
  display: inline-block;
  margin-left: 0.75rem;
}

.app-sidebar.collapsed .hover-dropdown .nav-link .bi {
  margin-right: 0;
}

/* Ensure normal sidebar doesn't show hover dropdowns */
.app-sidebar:not(.collapsed) .hover-dropdown {
  display: none !important;
}

.app-content {
  margin-left: 300px;
  transition: all .3s ease-in-out;
  padding: 1.5rem;
  width: calc(100vw - 300px);
  min-height: calc(100vh - 56px);
  box-sizing: border-box;
}

.app-content.sidebar-collapsed {
  margin-left: 60px;
  width: calc(100vw - 60px);
}

/* Breadcrumb Styling */
.breadcrumb {
  background: transparent;
  padding: 0;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.breadcrumb-item {
  color: #6c757d;
}

.breadcrumb-item a {
  color: #0d6efd;
  text-decoration: none;
  transition: color 0.15s ease-in-out;
}

.breadcrumb-item a:hover {
  color: #0a58ca;
  text-decoration: underline;
}

.breadcrumb-item.active {
  color: #495057;
  font-weight: 500;
}

.breadcrumb-item + .breadcrumb-item::before {
  content: "›";
  color: #6c757d;
  font-weight: bold;
  margin: 0 0.5rem;
}

/* Global Time Picker Styling */
.time-picker {
  cursor: pointer;
  position: relative;
}

/* Make sure the entire input area triggers the time picker */
.time-picker::-webkit-calendar-picker-indicator {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  height: auto;
  color: transparent;
  background: transparent;
  cursor: pointer;
}

/* For Firefox */
.time-picker {
  -moz-appearance: textfield;
}

.time-picker::-moz-calendar-picker-indicator {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  height: auto;
  background: transparent;
  cursor: pointer;
}

/* Style the input group with clock icon */
.input-group .input-group-text {
  background-color: #f8f9fa;
  border-color: #ced4da;
  color: #6c757d;
}

.input-group .form-control:focus + .input-group-text {
  border-color: #86b7fe;
  background-color: #f8f9fa;
}

/* Make the clock icon clickable too */
.input-group-text {
  cursor: pointer;
}

/* Global Date Picker Styling */
.date-picker {
  cursor: pointer;
  position: relative;
}

/* Make sure the entire input area triggers the date picker */
.date-picker::-webkit-calendar-picker-indicator {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  height: auto;
  color: transparent;
  background: transparent;
  cursor: pointer;
}

/* For Firefox */
.date-picker {
  -moz-appearance: textfield;
}

.date-picker::-moz-calendar-picker-indicator {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  height: auto;
  background: transparent;
  cursor: pointer;
}

/* ========== Permissions Table ========== */
.permissions-table {
  border: 1px solid #e9ecef;
  border-radius: 0.375rem;
  overflow: hidden;
  background: white;
}

.permissions-table .table {
  margin-bottom: 0;
  border-collapse: separate;
  border-spacing: 0;
}

.permissions-table .table thead th {
  background-color: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  font-weight: 600;
  color: #495057;
  padding: 0.75rem;
  text-align: center;
  vertical-align: middle;
  font-size: 0.875rem;
}

.permissions-table .table thead th:first-child {
  text-align: left;
}

.permissions-table .table tbody td {
  padding: 0.75rem;
  vertical-align: middle;
  border-bottom: 1px solid #f1f3f4;
  background-color: white;
}

.permissions-table .table tbody td:first-child {
  font-weight: 500;
  color: #212529;
  background-color: #fafbfc;
}

.permissions-table .table tbody tr:last-child td {
  border-bottom: none;
}

.permissions-table .form-check-input {
  margin: 0;
  width: 1em;
  height: 1em;
  border: 2px solid #000;
}

.permissions-table .form-check-input:checked {
  background-color: #0d6efd;
  border-color: #000;
}

.permissions-table .form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
  border-color: #000;
}

/* Mobile: slide-in */
@media (max-width: 991.98px) {
  .app-sidebar { 
    transform: translateX(-100%); 
  }
  .app-sidebar.open { 
    transform: translateX(0); 
  }
  .app-content { 
    margin-left: 0 !important; 
    width: 100vw !important;
    padding: 1rem;
  }
  .sidebar-toggle-btn { left: 12px !important; }
}

/* Content */
.page-title { font-weight: 600; }

/* Cards */
.stat-card .stat-icon {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: .5rem;
}
.stat-card .stat-label { font-size: .875rem; color: #6c757d; }
.stat-card .stat-value { font-size: 1.25rem; font-weight: 600; }

.fc .fc-button {text-transform: capitalize;}

#entries-table thead th {
    white-space: nowrap;
    padding-right: 28px; /* room for sorting caret */
    vertical-align: middle;
}

/* Constrain header text and allow ellipsis if it's long */
#entries-table thead th .dt-head-content {
    display: inline-block;
    max-width: calc(100% - 28px);
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    white-space: nowrap;
}

/* Ensure the DataTables generated sort icon remains to the right */
.dataTables_wrapper .dataTables_scrollHeadInner table th {
    position: relative;
}