/* Global theme (extracted from reports.php look & feel)
   Applies background, sidebar, header, and 85% content panels.
*/

:root {
  /* Reports page uses a 180px sidebar; keep header/content aligned to that */
  --sidebar-width: 210px;
  --sidebar-left-gap: 12px;
  --content-left-gap: 0px;

  --sidebar-btn-bg: #2c3e50;
  --sidebar-btn-hover: #34495e;
  --active-green: #2ecc71;
  --alert-red: #e74c3c;

  --panel-bg: rgba(255, 255, 255, 0.85);
  --panel-bg-soft: rgba(248, 249, 250, 0.85);
  --header-bg: rgba(44, 62, 80, 0.85);
}

body {
  /* Anchor image to top-left so cropping hides right/bottom on small screens */
  background: url('../images/back.jpg') no-repeat left top fixed;
  background-size: cover;
}

html {
  overflow-y: scroll;
  overflow-x: hidden;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width) !important;
  background: none !important;
  box-shadow: none !important;

  position: fixed;
  left: 0;
  top: 0;

  padding-top: 72px;
  margin-top: 112px;
  margin-left: var(--sidebar-left-gap);

  display: flex;
  flex-direction: column;
  gap: 14px;

  /* Auto-fit to screen: keep the sidebar within the viewport and scroll internally */
  justify-content: flex-start;

  top: 96px !important;
  bottom: 18px !important;
  height: auto !important;

  padding-top: 0 !important;
  margin-top: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
}

.menu-item {
  padding: 8px 18px;
  border-radius: 12px;

  background: var(--sidebar-btn-bg);
  color: #bdc3c7;
  text-decoration: none;

  display: flex;
  align-items: center;
  gap: 15px;

  border-left: 4px solid transparent;
  border: 1px solid var(--active-green);

  transition: all 0.3s;
}

.menu-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--alert-red);
  margin-left: auto;
}

/* Force consistent sidebar button size across pages.
   Some pages still ship inline `.menu-item` styles with larger padding/line-height.
*/
.sidebar .menu-item {
  padding: 8px 18px !important;
  font-size: 15px !important;
  line-height: 1.2 !important;
  min-height: 38px;
  max-width: 180px;
  width: 180px;

  display: flex !important;
  align-items: center !important;
  gap: 15px !important;
  white-space: nowrap;
}

.menu-item:hover {
  background: var(--sidebar-btn-hover);
  color: #fff;
  border-left-color: #3498db;
  padding-left: 30px;
}

.sidebar .menu-item:hover {
  padding-left: 30px !important;
}

.menu-item.active {
  background: var(--sidebar-btn-hover);
  color: #fff;
  border-left-color: var(--active-green);
  box-shadow: 0 0 16px 4px #2ecc71ee !important;
}

/* Some pages use per-page inline CSS that sets box-shadow to none.
   Force the active glow in the sidebar context.
*/
.sidebar .menu-item.active {
  box-shadow: 0 0 16px 4px #2ecc71ee !important;
}

.sidebar .menu-item.active:hover {
  box-shadow: 0 0 18px 5px #2ecc71ee !important;
}

/* Header */
.header {
  background: var(--header-bg) !important;
  border: 1px solid var(--active-green);
  border-radius: 18px;

  color: #fff !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  gap: 14px;

  min-height: 48px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.10);

  position: relative !important;
  top: 0;
  z-index: 1000;

  padding: 8px 24px;

  /* Align with content */
  margin: 36px 0 18px 0 !important;
  margin-left: calc(var(--sidebar-width) + var(--sidebar-left-gap) + var(--content-left-gap)) !important;
  width: calc(100% - (var(--sidebar-width) + var(--sidebar-left-gap) + var(--content-left-gap)) - 24px) !important;
}

/* Header title */
.header h1,
.header h2 {
  margin: 0 !important;
  font-size: 22px;
  font-weight: 600;
  color: #fff !important;
}

/* Header right-side actions (many pages use either .header-actions or a plain div) */
.header .header-actions,
.header > div {
  display: flex !important;
  align-items: center !important;
  gap: 15px;
  font-size: 14px;
  font-weight: 500;
  color: #fff !important;
}

.header .header-actions span,
.header > div span {
  color: #fff !important;
}

.header .header-actions strong,
.header > div strong {
  font-weight: 700;
}

/* Header links should look like Reports page header buttons */
.header a {
  color: #fff !important;
  text-decoration: none !important;
  padding: 8px 15px !important;
  border-radius: 4px !important;
  transition: background 0.3s;
  font-size: 14px !important;
  border: none !important;
  background: transparent !important;
  display: inline-block;
}

.header a:hover {
  background: rgba(255, 255, 255, 0.10) !important;
}

@media (max-width: 768px) {
  .header {
    margin: 12px 12px 12px 12px !important;
    margin-left: 12px !important;
    width: calc(100% - 24px) !important;
  }
  .sidebar {
    display: none !important;
  }
  .content {
    margin-left: 0 !important;
  }
}

/* Content alignment */
.content {
  margin-left: calc(var(--sidebar-width) + var(--sidebar-left-gap) + var(--content-left-gap)) !important;
  background: none !important;
}

/* Safety: never let wide content break layout; allow horizontal scroll where needed */
.table-container {
  max-width: 100% !important;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

pre,
code {
  max-width: 100%;
  overflow-x: auto;
}

/* 85% opacity panels (background only; text stays crisp) */
.stat-card,
.report-card,
.table-container,
.summary-section,
.search-filter-bar {
  background-color: var(--panel-bg) !important;
}

.summary-item {
  background-color: var(--panel-bg-soft) !important;
}

/* Keep these generic helpers scoped to main content */
.content .form-container,
.content .container,
.content .card {
  background-color: var(--panel-bg) !important;
}

/* Extra responsive helpers (many pages have wide tables / fixed-width cards) */
img, svg, video, canvas {
  max-width: 100%;
  height: auto;
}

@media (max-width: 768px) {
  .header {
    flex-wrap: wrap !important;
  }

  .header .header-actions,
  .header > div {
    flex-wrap: wrap !important;
  }

  form, .form, .form-row, .row, .filters, .toolbar, .actions {
    flex-wrap: wrap;
  }

  input[type="text"], input[type="number"], input[type="email"], input[type="password"],
  input[type="date"], input[type="time"], select, textarea {
    max-width: 100% !important;
    box-sizing: border-box;
  }

  .content {
    padding: 0 12px 18px 12px !important;
  }

  .content .form-container,
  .content .container,
  .content .card {
    max-width: 100% !important;
  }

  .table-container {
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  input,
  select,
  textarea {
    max-width: 100% !important;
  }
}

@media (max-width: 480px) {
  /* Login page has a fixed width in inline CSS; keep it within the viewport */
  .login-box.card {
    width: 92vw !important;
    padding: 22px !important;
  }
}
