/*
  Modern visual layer on top of the existing Bootstrap 4 / SB-Admin-2 theme
  (custom.css). Loaded AFTER custom.css so these rules override it purely
  visually — no HTML markup, class names, or JS behaviour are relied upon
  changing; every selector below targets classes the app already uses.
*/

:root {
  --app-radius-lg: 1rem;
  --app-radius: 0.85rem;
  --app-radius-sm: 0.55rem;
  --app-shadow-sm: 0 0.125rem 0.5rem rgba(33, 40, 50, 0.06);
  --app-shadow: 0 0.25rem 1rem rgba(33, 40, 50, 0.08);
  --app-shadow-hover: 0 0.75rem 1.75rem rgba(33, 40, 50, 0.14);
  --app-border: #e9ecf3;
  --app-bg: #f3f5fb;
  /* Sidebar gradient stays within the app's own steelblue brand color
     (bg-dark / --steelblue: #4682B4 in custom.css) — just adds depth,
     doesn't introduce a new hue. */
  --app-sidebar-from: #35647f;
  --app-sidebar-to: #4682b4;
  --app-font: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ---------------------------------------------------------------- */
/* Base / typography                                                */
/* ---------------------------------------------------------------- */

html, body {
  background-color: var(--app-bg);
  font-family: var(--app-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-family: var(--app-font);
  font-weight: 800;
  letter-spacing: -0.01em;
}

a {
  transition: color 0.15s ease;
}

/* ---------------------------------------------------------------- */
/* Layout wrapper                                                   */
/* ---------------------------------------------------------------- */

#content-wrapper {
  background-color: var(--app-bg);
}

#content {
  padding-bottom: 1rem;
}

.container-fluid {
  padding: 1.5rem 1.75rem;
}

/* ---------------------------------------------------------------- */
/* Sidebar                                                          */
/* ---------------------------------------------------------------- */

.sidebar,
.sidebar.navbar-default,
.sidebar.bg-dark {
  background: linear-gradient(180deg, var(--app-sidebar-from) 0%, var(--app-sidebar-to) 100%) !important;
  box-shadow: 0.15rem 0 1.5rem rgba(0, 0, 0, 0.18);
  border: none;
}

.sidebar .sidebar-brand {
  height: auto;
  min-height: 4.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.9rem 1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

/* Fixed-height logo box: keeps the 500x263 source image sharp and
   proportional (object-fit: contain) instead of stretching to whatever
   width custom.css's breakpoints happen to set.
   sono1.png already has its own solid white background baked into the
   pixels (it's not a transparent cutout), so we round the image itself
   instead of layering a second CSS background behind it — a separate
   box would show as a mismatched/greyish white next to the image's
   own pure white. */
.sidebar .sidebar-brand img {
  width: auto !important;
  height: 42px !important;
  max-width: 140px;
  object-fit: contain;
}

@media (max-width: 576px) {
  .sidebar .sidebar-brand img {
    height: 36px !important;
    max-width: 110px;
  }
}

.sidebar-divider {
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
  margin: 0.35rem 1rem !important;
}

.sidebar .nav-item {
  margin: 0.05rem 0;
}

.sidebar .nav-item .nav-link {
  border-radius: var(--app-radius-sm);
  margin: 0.15rem 0.7rem;
  padding: 0.65rem 0.9rem;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 600;
  font-size: 0.85rem;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.sidebar .nav-item .nav-link i {
  color: rgba(255, 255, 255, 0.55);
  transition: color 0.15s ease;
  width: 1.4rem;
}

/* Below 500px custom.css switches the sidebar into a narrow icon "rail"
   (.nav-link gets a fixed width: 6.5rem, icon+label stacked and
   text-align:center). The horizontal margin above is sized for the
   wide (>=500px) sidebar's pill-shaped links — added on top of that
   fixed 6.5rem width it overflows the rail and pushes the icon off
   centre. Drop the horizontal margin and centre the icon explicitly
   here instead. */
@media (max-width: 499.98px) {
  .sidebar .nav-item .nav-link {
    width: 100%;
    margin: 0.15rem 0;
    padding: 0.6rem 0.25rem;
    text-align: center;
  }

  .sidebar .nav-item .nav-link i {
    display: block;
    width: auto;
    margin: 0 auto 0.2rem;
  }
}

.sidebar .nav-item .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #fff;
  transform: translateX(2px);
}

.sidebar .nav-item .nav-link:hover i {
  color: #fff;
}

.sidebar .nav-item .nav-link.active,
.sidebar .nav-item.active .nav-link {
  background-color: rgba(255, 255, 255, 0.16);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.sidebar .nav-item .nav-link.active i,
.sidebar .nav-item.active .nav-link i {
  color: #fff;
}

.sidebar .sidebar-heading {
  color: rgba(255, 255, 255, 0.35);
  font-weight: 700;
  letter-spacing: 0.08em;
}

/* Sidebar submenu flyout (narrow/mobile rail mode: custom.css pops the
   .collapse submenu out as position:absolute, to the right of the icon
   rail). Two things were hiding it on mobile:
   1. z-index:1 (custom.css) put it BELOW .topbar.sticky-top, which is
      z-index:1020 — the submenu rendered underneath the topbar.
   2. admin/a_sidebar.php's <ul id="accordionSidebar"> has an inline
      overflow-x:hidden (for its own long menu list), which clips the
      submenu since it intentionally extends past the rail's edge. */
.sidebar .nav-item .collapse,
.sidebar .nav-item .collapsing {
  z-index: 1050;
}

@media (max-width: 499.98px) {
  /* :not(.toggled) matters: when the user hides the sidebar via the
     toggle button, custom.css sets .sidebar.toggled { width:0 !important;
     overflow:hidden; } to actually hide its contents (including the
     logo). Without this exclusion, overflow:visible !important above
     would beat that non-important overflow:hidden regardless of
     .toggled's higher specificity, leaving the logo/nav items visibly
     floating outside the collapsed 0-width box. */
  .sidebar:not(.toggled) {
    overflow: visible !important;
    max-height: none !important;
  }
}

/* ---------------------------------------------------------------- */
/* Topbar                                                           */
/* ---------------------------------------------------------------- */

.topbar {
  background-color: rgba(255, 255, 255, 0.85) !important;
  backdrop-filter: saturate(180%) blur(8px);
  box-shadow: 0 0.2rem 1rem rgba(33, 40, 50, 0.07) !important;
  border-bottom: 1px solid var(--app-border);
}

.topbar .navbar-search h3 {
  font-size: 1.05rem;
  font-weight: 800;
  color: #5a5c69;
  margin: 0;
  letter-spacing: -0.01em;
}

.topbar #sidebarToggleTop {
  border-radius: 50%;
  background-color: #f3f5fb;
  width: 2.2rem;
  height: 2.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.topbar .nav-item .nav-link {
  border-radius: 50%;
  width: 2.4rem;
  height: 2.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: #f3f5fb;
  color: #4e73df;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.topbar .nav-item .nav-link:hover {
  background-color: #e9edfb;
  box-shadow: 0 0.25rem 0.6rem rgba(78, 115, 223, 0.2);
}

/* ---------------------------------------------------------------- */
/* Cards                                                             */
/* ---------------------------------------------------------------- */

.card {
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: var(--app-shadow-hover);
}

/* Consistent Bootstrap "p-2" padding on every card body, regardless of
   what each view's markup happens to set. */
.card-body {
  padding: 0.5rem;
}

.card-header {
  border-radius: var(--app-radius) var(--app-radius) 0 0 !important;
  background-color: #fff;
  border-bottom: 1px solid var(--app-border);
  font-weight: 700;
}

/* Stat / KPI cards (border-left-* pattern used across dashboards) */
.card.border-left-primary,
.card.border-left-success,
.card.border-left-info,
.card.border-left-warning,
.card.border-left-danger,
.card.border-left-secondary {
  border-left: none !important;
  position: relative;
  overflow: hidden;
}

.card.border-left-primary::before,
.card.border-left-success::before,
.card.border-left-info::before,
.card.border-left-warning::before,
.card.border-left-danger::before,
.card.border-left-secondary::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.card.border-left-primary::before { background: var(--primary, #4e73df); }
.card.border-left-success::before { background: var(--success, #18a34e); }
.card.border-left-info::before { background: var(--info, #36b9cc); }
.card.border-left-warning::before { background: var(--warning, #f6c23e); }
.card.border-left-danger::before { background: var(--danger, #e74a3b); }
.card.border-left-secondary::before { background: var(--secondary, #858796); }

.card .fa-2x.text-gray-300 {
  background-color: #f3f5fb;
  color: #4e73df !important;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem !important;
}

.card.border-left-success .fa-2x.text-gray-300 { color: #18a34e !important; }
.card.border-left-info .fa-2x.text-gray-300 { color: #36b9cc !important; }
.card.border-left-warning .fa-2x.text-gray-300 { color: #f6c23e !important; }
.card.border-left-danger .fa-2x.text-gray-300 { color: #e74a3b !important; }

/* ---------------------------------------------------------------- */
/* Buttons                                                           */
/* ---------------------------------------------------------------- */

.btn {
  border-radius: var(--app-radius-sm);
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary { box-shadow: 0 0.25rem 0.75rem rgba(78, 115, 223, 0.25); }
.btn-success { box-shadow: 0 0.25rem 0.75rem rgba(24, 163, 78, 0.22); }
.btn-danger  { box-shadow: 0 0.25rem 0.75rem rgba(231, 74, 59, 0.22); }
.btn-warning { box-shadow: 0 0.25rem 0.75rem rgba(246, 194, 62, 0.25); }
.btn-secondary { box-shadow: 0 0.15rem 0.5rem rgba(133, 135, 150, 0.18); }

.btn-sm {
  border-radius: var(--app-radius-sm);
}

/* ---------------------------------------------------------------- */
/* Forms                                                             */
/* ---------------------------------------------------------------- */

.form-control,
.custom-select,
.custom-file-label {
  border-radius: var(--app-radius-sm);
  border: 1px solid var(--app-border);
}

.form-control:focus,
.custom-select:focus {
  box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.15);
  border-color: var(--primary, #4e73df);
}

/* ---------------------------------------------------------------- */
/* Tables                                                            */
/* ---------------------------------------------------------------- */

/* Rounding/shadow lives on the scroll wrapper only — never on the
   <table> itself. Overflow:hidden on .table broke horizontal scrolling
   for wide tables (content got clipped instead of scrolling). */
.table-responsive {
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-sm);
}

.table thead th {
  background-color: #f8f9fc;
  border-bottom: 2px solid var(--app-border);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  color: #5a5c69;
}

.table-bordered td,
.table-bordered th {
  border-color: var(--app-border);
}

.table-hover tbody tr:hover {
  background-color: #f4f7ff;
}

.table-striped tbody tr:nth-of-type(odd) {
  background-color: #fafbff;
}

/* jQuery DataTables (Kasbonadmin, pemberangkatan, etc.) always wraps its
   table in .dataTables_wrapper regardless of what the view's own markup
   does — scrolling that wrapper is the DataTables-safe way to make wide
   DataTables tables responsive without breaking its column width math. */
.dataTables_wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------------------------------------------------------------- */
/* Alerts                                                            */
/* ---------------------------------------------------------------- */

.alert {
  border: none;
  border-left: 4px solid transparent;
  border-radius: var(--app-radius-sm);
  box-shadow: var(--app-shadow-sm);
  font-weight: 600;
}

.alert-primary { border-left-color: #4e73df; }
.alert-success { border-left-color: #18a34e; }
.alert-danger  { border-left-color: #e74a3b; }
.alert-warning { border-left-color: #f6c23e; }
.alert-info    { border-left-color: #36b9cc; }
.alert-secondary { border-left-color: #858796; }

/* ---------------------------------------------------------------- */
/* Breadcrumbs & pills                                              */
/* ---------------------------------------------------------------- */

.breadcrumb {
  background-color: #fff;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-sm);
  box-shadow: var(--app-shadow-sm);
  padding: 0.6rem 1rem;
}

.breadcrumb-item.active {
  color: #4e73df;
  font-weight: 700;
}

.nav-pills .nav-link {
  border-radius: var(--app-radius-sm);
  font-weight: 700;
  color: #5a5c69;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-pills .nav-link.active {
  background: linear-gradient(90deg, #4e73df, #6f86e6);
  box-shadow: 0 0.35rem 0.9rem rgba(78, 115, 223, 0.28);
}

/* ---------------------------------------------------------------- */
/* Dropdowns & modals                                                */
/* ---------------------------------------------------------------- */

.dropdown-menu {
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-sm);
  box-shadow: var(--app-shadow-hover);
}

.dropdown-item {
  border-radius: var(--app-radius-sm);
  margin: 0.1rem 0.3rem;
  width: calc(100% - 0.6rem);
}

.dropdown-item:hover,
.dropdown-item:focus {
  background-color: #f3f5fb;
}

.modal-content {
  border-radius: var(--app-radius-lg);
  border: none;
  box-shadow: var(--app-shadow-hover);
}

.modal-header {
  border-bottom: 1px solid var(--app-border);
}

.modal-footer {
  border-top: 1px solid var(--app-border);
}

/* ---------------------------------------------------------------- */
/* Badges                                                            */
/* ---------------------------------------------------------------- */

.badge {
  border-radius: 0.4rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ---------------------------------------------------------------- */
/* Scrollbar (webkit)                                                */
/* ---------------------------------------------------------------- */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: #c7cedd;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a9b3c9;
}

/* ---------------------------------------------------------------- */
/* Login / reset password card                                      */
/* ---------------------------------------------------------------- */

.login-card,
.card-login {
  border-radius: var(--app-radius-lg);
  box-shadow: var(--app-shadow-hover);
  border: none;
}

.login-card .form-control,
.card-login .form-control {
  background-color: #f8f9fc;
}

/* ---------------------------------------------------------------- */
/* Footer                                                            */
/* ---------------------------------------------------------------- */

footer.sticky-footer {
  background-color: transparent !important;
  border-top: 1px solid var(--app-border);
}

footer.sticky-footer .copyright {
  color: #9aa1b5;
  font-size: 0.8rem;
}

/* ---------------------------------------------------------------- */
/* Responsive images (baseline)                                     */
/* ---------------------------------------------------------------- */

img {
  max-width: 100%;
  height: auto;
}

/* ---------------------------------------------------------------- */
/* Mobile & tablet optimisation                                     */
/* ---------------------------------------------------------------- */

/* custom.css hard-codes .navbar-search to 25rem (400px), which forces
   the topbar to overflow on phones since it never shrinks. Let it
   flex instead, and keep the title from wrapping/overflowing. */
.topbar .navbar-search {
  width: auto;
  max-width: 100%;
  flex: 1 1 auto;
  min-width: 0;
}

.topbar .navbar-search h3 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tablets (<=991.98px) */
@media (max-width: 991.98px) {
  .container-fluid {
    padding: 1.15rem 1.1rem;
  }

  .topbar .navbar-search h3 {
    font-size: 0.95rem;
  }
}

/* Phones (<=767.98px) */
@media (max-width: 767.98px) {
  .container-fluid {
    padding: 0.9rem 0.85rem;
  }

  h1, .h1 { font-size: 1.5rem; }
  h2, .h2 { font-size: 1.3rem; }
  h3, .h3 { font-size: 1.1rem; }

  .topbar .navbar-search h3 {
    font-size: 0.85rem;
  }

  .table thead th,
  .table td,
  .table th {
    font-size: 0.78rem;
    padding: 0.5rem 0.55rem;
  }

  /* Safety net: several views put "table-responsive"/"table-responsive-sm"
     directly on the <table> instead of a wrapper <div> (where those
     classes actually work), and a few plain (non-DataTables) tables have
     no wrapper at all. Making every .table scroll horizontally on its
     own here means they no longer overflow past the card regardless of
     the markup mistake — wrapped tables just get a harmless nested
     scroll container. */
  .table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* DataTables tables must keep display:table so its column width math
     stays correct — .dataTables_wrapper (added above) handles the
     scrolling for those instead. */
  .dataTables_wrapper .table {
    display: table;
    overflow: visible;
  }

  .btn {
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
  }

  /* Stat cards (col-lg-4 col-md-6 col-sm-8) have no column size below
     576px, so Bootstrap leaves them at content width instead of
     stacking full-width like the rest of the grid. */
  .col-sm-8 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }

  /* Touch-friendlier topbar icon buttons */
  .topbar .nav-item .nav-link {
    width: 2.5rem;
    height: 2.5rem;
  }
}

/* Small phones (<=575.98px) */
@media (max-width: 575.98px) {
  .container-fluid {
    padding: 0.75rem 0.65rem;
  }

  .sidebar .nav-item .nav-link {
    margin: 0.1rem 0.35rem;
    padding: 0.55rem 0.5rem;
  }
}

/* Phones in landscape. The width-based breakpoints above key off width
   (<=767.98px), but a rotated phone is often WIDER than that (e.g. an
   iPhone landscape is ~812-926px) while its height stays short
   (~375-430px) — so none of the phone compaction above applied, yet
   vertical space is just as tight. This targets that short-height case
   directly, regardless of width, using height rather than a device list. */
@media (orientation: landscape) and (max-height: 500px) {
  .container-fluid {
    padding: 0.6rem 1rem;
  }

  .topbar {
    height: auto;
    min-height: 2.75rem;
  }

  .topbar .nav-item .nav-link,
  .topbar #sidebarToggleTop {
    height: 2.25rem;
    width: 2.25rem;
  }

  .topbar .navbar-search h3 {
    font-size: 0.85rem;
  }

  .sidebar {
    min-height: 100vh;
    height: 100vh;
    overflow-y: auto;
  }

  .sidebar .sidebar-brand {
    min-height: 2.75rem;
    padding: 0.5rem 1rem;
  }

  .sidebar .sidebar-brand img {
    height: 30px !important;
  }

  .sidebar .nav-item .nav-link {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }

  .card-body {
    padding: 0.5rem;
  }

  h1, .h1 { font-size: 1.3rem; }
  h2, .h2 { font-size: 1.15rem; }

  /* Short viewport: let modals scroll internally instead of getting
     cut off top/bottom. */
  .modal-dialog {
    max-height: 92vh;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
  }

  .modal-body {
    max-height: 65vh;
    overflow-y: auto;
  }

  .table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .dataTables_wrapper .table {
    display: table;
    overflow: visible;
  }
}
