/*
 * IMS Custom Layout Refinements
 * Targeted fixes for alignment, spacing, and consistency.
 * Loaded AFTER style.css — only overrides what needs correcting.
 */

/* ═══════════════════════════════════════════
   PAGE HEADER — icon + title vertical align
════════════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e9ecef;
}

.page-header .page-title {
  display: flex;
  align-items: center;
  margin-bottom: 0;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1;
}

.page-header .page-title .page-title-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  font-size: 1rem;
  flex-shrink: 0;
}

.page-header nav[aria-label="breadcrumb"] {
  margin-bottom: 0;
}

.page-header .breadcrumb {
  margin-bottom: 0;
  padding: 0;
  background: transparent;
  border: none;
  font-size: 0.82rem;
}

/* ═══════════════════════════════════════════
   FLASH ALERTS — icon baseline alignment
════════════════════════════════════════════ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.alert .btn-close {
  margin-left: auto;
  flex-shrink: 0;
  margin-top: 2px;
}

.alert ul {
  margin-bottom: 0;
  padding-left: 1rem;
  flex: 1;
}

/* ═══════════════════════════════════════════
   NAVBAR — brand wrapper & welcome text
════════════════════════════════════════════ */
.navbar .navbar-brand-wrapper {
  display: flex;
  align-items: center;
}

.navbar .welcome-text {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0;
  line-height: 1.3;
}

.navbar .welcome-sub-text {
  font-size: 0.78rem;
  color: #6c757d;
  margin-bottom: 0;
  font-weight: 400;
}

/* Hide Bootstrap's auto-generated caret where we supply our own icon */
.nav-link.no-caret::after {
  display: none !important;
}

/* ═══════════════════════════════════════════
   SIDEBAR — section category labels
════════════════════════════════════════════ */
.sidebar .nav .nav-category {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9fa4a9;
  padding: 0.85rem 1.25rem 0.35rem;
  pointer-events: none;
  line-height: 1;
}

/* Active nav item — left accent bar */
.sidebar .nav .nav-item.active > .nav-link {
  border-left: 3px solid #4B49AC;
  padding-left: calc(1rem - 3px);
}

.sidebar .nav .nav-item:not(.active) > .nav-link {
  border-left: 3px solid transparent;
  padding-left: calc(1rem - 3px);
}

/* ═══════════════════════════════════════════
   CARD HEADERS — consistent style
════════════════════════════════════════════ */
.card-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.25rem;
}

.card-header h5,
.card-header h4,
.card-header .card-title {
  margin-bottom: 0;
  line-height: 1.3;
}

/* Card header with action button on right */
.card-header.d-flex {
  justify-content: space-between;
}

/* ═══════════════════════════════════════════
   TABLES — header alignment & row density
════════════════════════════════════════════ */
.table thead th {
  vertical-align: middle;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #495057;
  border-bottom-width: 1px;
}

.table tbody td {
  vertical-align: middle;
}

/* Action button column — don't overflow */
.table .dropdown {
  white-space: nowrap;
}

/* Dropdown menus inside tables are repositioned to fixed by JS (see app.blade.php).
   This ensures they are never clipped by .table-responsive's overflow:auto. */
.table .dropdown-menu {
  /* Will be overridden to position:fixed by JS; fallback keeps it usable */
  will-change: transform;
}

/* ═══════════════════════════════════════════
   FILTER BARS — compact, aligned
════════════════════════════════════════════ */
.card .card-body.py-2 .row.g-2 > [class*="col-"] {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

/* ═══════════════════════════════════════════
   FORM GROUPS — consistent label + input
════════════════════════════════════════════ */
.form-label {
  margin-bottom: 0.3rem;
  font-size: 0.875rem;
}

.form-control,
.form-select {
  font-size: 0.9rem;
}

.form-group .text-muted,
.form-group small {
  font-size: 0.78rem;
  display: block;
  margin-top: 0.2rem;
}

/* ═══════════════════════════════════════════
   KPI / STAT CARDS — consistent body padding
════════════════════════════════════════════ */
.card-tale .card-body,
.card-dark-blue .card-body,
.card-light-blue .card-body,
.card .card-body {
  padding: 1.25rem;
}

/* Summary / stat cards — small left-border variant */
.card.border-start {
  border-radius: 6px;
}

.card.border-start .card-body {
  padding: 0.75rem 1.25rem;
}

/* ═══════════════════════════════════════════
   PAGINATION — align with table
════════════════════════════════════════════ */
.pagination {
  margin-bottom: 0;
  justify-content: flex-end;
}

.mt-3 > .pagination {
  margin-top: 0.5rem;
}

/* ═══════════════════════════════════════════
   BADGES — consistent vertical alignment
════════════════════════════════════════════ */
.badge {
  vertical-align: middle;
}

/* ═══════════════════════════════════════════
   FOOTER — subtle top border, balanced padding
════════════════════════════════════════════ */
.footer {
  border-top: 1px solid #e9ecef;
  padding: 0.85rem 1.5rem;
  font-size: 0.82rem;
}

/* ═══════════════════════════════════════════
   INPUT GROUPS — date pickers alignment
════════════════════════════════════════════ */
.input-group .form-control {
  border-right: 0;
}

.input-group .input-group-text {
  background: #f8f9fa;
  border-left: 0;
  color: #6c757d;
}

/* ═══════════════════════════════════════════
   DROPDOWN MENUS — action dropdowns
════════════════════════════════════════════ */
.dropdown-menu .dropdown-item {
  display: flex;
  align-items: center;
  font-size: 0.875rem;
  padding: 0.45rem 1rem;
}

.dropdown-menu .dropdown-item i {
  flex-shrink: 0;
  width: 18px;
}

/* ═══════════════════════════════════════════
   CONTENT WRAPPER — consistent top padding
════════════════════════════════════════════ */
.content-wrapper {
  padding-top: 1.5rem;
}

/* ═══════════════════════════════════════════
   RESPONSIVE — small screens
════════════════════════════════════════════ */
@media (max-width: 767px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-header nav[aria-label="breadcrumb"] {
    width: 100%;
  }

  .table thead th {
    font-size: 0.75rem;
  }
}

/* ═══════════════════════════════════════════
   MOBILE RESPONSIVE — sidebar & layout
   StarAdmin2 uses .sidebar-offcanvas + .active
   for the mobile left-drawer pattern
════════════════════════════════════════════ */

/* --- Breakpoint: ≤ 991px (tablet + phone) --- */
@media (max-width: 991px) {

  /* Sidebar slides in from the LEFT as an overlay */
  .sidebar-offcanvas {
    position: fixed !important;
    top: 0;
    left: -260px;
    height: 100vh;
    width: 260px;
    z-index: 1050;
    overflow-y: auto;
    transition: left 0.28s ease;
    box-shadow: none;
  }

  .sidebar-offcanvas.active {
    left: 0;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.18);
  }

  /* Dark overlay behind open sidebar */
  body.sidebar-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1040;
  }

  /* Main panel takes full width */
  .main-panel {
    width: 100% !important;
    margin-left: 0 !important;
    min-height: 100vh;
  }

  /* Page body wrapper: no left offset */
  .page-body-wrapper {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Navbar: full width, stacks brand + menu */
  .navbar.default-layout {
    flex-wrap: nowrap;
  }

  .navbar .navbar-brand-wrapper {
    width: auto;
    min-width: 0;
    flex-shrink: 0;
  }

  .navbar .navbar-menu-wrapper {
    flex: 1;
    min-width: 0;
  }

  /* Hide desktop minimize toggler on mobile — handled via d-none d-lg-block in HTML */

  /* Mobile hamburger: theme gives navbar-toggler-right 15px left padding for right-side use.
     We're placing it on the LEFT inside navbar-brand-wrapper so reset that. */
  .navbar .navbar-brand-wrapper .navbar-toggler-right {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Content wrapper: reduce horizontal padding */
  .content-wrapper {
    padding: 1rem 0.75rem !important;
  }

  /* Page header: stack title + breadcrumb */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  /* Tables: allow horizontal scroll */
  .table-responsive {
    -webkit-overflow-scrolling: touch;
  }

  /* Filter bar: stack inputs vertically */
  .card .card-body.py-2 .row.g-2 > [class*="col-"] {
    width: 100% !important;
    flex: none;
  }

  /* KPI cards: 2 per row on tablet */
  .row > [class*="col-md-3"],
  .row > [class*="col-sm-6"] {
    flex: 0 0 50%;
    max-width: 50%;
  }

  /* Dashboard chart col: full width */
  .col-lg-8,
  .col-lg-4 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Dropdown menus: prevent overflow on small screens */
  .dropdown-menu-right,
  .dropdown-menu-end {
    right: 0 !important;
    left: auto !important;
  }
}

/* --- Breakpoint: ≤ 575px (phone only) --- */
@media (max-width: 575px) {

  /* KPI cards: 1 per row on small phones */
  .row > [class*="col-md-3"],
  .row > [class*="col-sm-6"] {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Navbar brand text: slightly smaller */
  .navbar .navbar-brand-wrapper a span {
    font-size: 1rem !important;
  }

  /* Tighten content padding on phone */
  .content-wrapper {
    padding: 0.75rem 0.5rem !important;
  }

  /* Card body: tighter padding */
  .card .card-body {
    padding: 1rem !important;
  }

  /* Card header: tighter padding */
  .card-header {
    padding: 0.65rem 1rem !important;
  }

  /* Page header title: smaller */
  .page-header .page-title {
    font-size: 1.05rem;
  }

  /* Welcome text: hide date line */
  .welcome-sub-text {
    display: none !important;
  }

  /* Table action buttons: reduce padding */
  .table .btn-sm,
  .table .btn-xs {
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
  }

  /* Footer: stack vertically */
  .footer .d-flex {
    flex-direction: column;
    gap: 0.25rem;
    text-align: center;
  }
}

/* ═══════════════════════════════════════════
   AUTH PAGES — login / register mobile
════════════════════════════════════════════ */
.auth .auth-form-light {
  border-radius: 8px;
}

@media (max-width: 575px) {
  .auth .auth-form-light {
    padding: 1.5rem 1.25rem !important;
    border-radius: 6px;
  }

  .auth .brand-logo .mdi {
    font-size: 2.5rem !important;
  }

  .auth .form-control-lg {
    font-size: 0.95rem;
    padding: 0.55rem 0.85rem;
  }

  .auth h4 {
    font-size: 1.2rem;
  }

  .auth .btn-lg {
    font-size: 0.95rem;
    padding: 0.6rem 1rem;
  }
}

/* ═══════════════════════════════════════════
   BTN-XS COMPAT (Bootstrap 3 class shim)
   Used in categories, units inline tables
════════════════════════════════════════════ */
.btn-xs {
  padding: 0.2rem 0.45rem;
  font-size: 0.78rem;
  line-height: 1.4;
  border-radius: 4px;
}

.btn-xs i.mdi {
  font-size: 0.9rem;
  vertical-align: middle;
}

/* ═══════════════════════════════════════════
   USER DROPDOWN — navbar avatar + menu
════════════════════════════════════════════ */

/* Small avatar in the navbar trigger */
.user-nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #4B49AC;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Dropdown panel */
.user-dropdown-menu {
  min-width: 240px;
  padding: 0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0,0,0,0.10);
}

/* Header section */
.user-dropdown-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  background: #f8f9ff;
}

/* Large avatar in the header */
.user-dropdown-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #4B49AC;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-dropdown-info {
  overflow: hidden;
}

.user-dropdown-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #1a1a2e;
}

.user-dropdown-email {
  font-size: 0.78rem;
  color: #6c757d;
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-dropdown-role {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.3px;
  background-color: transparent;
}

/* Menu items */
.user-dropdown-menu .dropdown-item {
  font-size: 0.875rem;
  color: #3d3d3d;
  padding-left: 1.1rem;
  padding-right: 1.1rem;
  transition: background 0.15s ease;
}

.user-dropdown-menu .dropdown-item:hover {
  background: #f0f1ff;
}

.user-dropdown-menu .dropdown-item i.mdi {
  width: 20px;
  text-align: center;
}
