/* ===============================
   BASE
================================ */
html { font-size: 14px; height: 100%; }
@media (min-width: 768px){ html{ font-size:16px; } }

body{
  min-height: 100%;
  margin: 0;
  background: #f8fafc;
}

.btn:focus, .btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus{
  box-shadow: 0 0 0 0.1rem #fff, 0 0 0 0.25rem #258cfb;
}

/* Lock body scroll ONLY for authenticated layout (to avoid double scroll) */
body.app-auth { overflow: hidden; }

/* ===============================
   LAYOUT (FIX SCROLL + FOOTER)
================================ */
.app-shell{
  display: flex;
  height: 100vh;
}

/* Sidebar scrolls independently if long */
.sidebar{
  width: 285px;
  flex: 0 0 285px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  overflow: hidden; /* nav will scroll, not entire sidebar shell */
  background: linear-gradient(180deg, #0b1220 0%, #0d1b2a 40%, #0a1526 100%);
  color: #e9eefc;
  border-right: 1px solid rgba(255,255,255,.08);
}

/* Main column: header fixed, content scrolls */
.main{
  flex: 1;
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* scroll container (CRITICAL) */
.main-scroll{
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;

  display: flex;              /* ✅ NEW */
  flex-direction: column;     /* ✅ NEW */
}


/* content spacing */
.main-content{
  flex: 1 0 auto;             /* ✅ NEW */
  padding: 28px;
}


/* Footer sits AFTER content and will be at the bottom when page is short */
/* footer stays at bottom when content is short */
.app-footer{
  margin-top: auto;           /* ✅ NEW */
  border-top: 1px solid rgba(0,0,0,.08);
  background: #fff;
  padding: .75rem 1rem;
}

/* ===============================
   SIDEBAR UI
================================ */
.brand{
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-row{
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo{
  width: 46px; height: 46px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 10px 25px rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
}

.brand-title{ font-weight: 800; font-size: 1.05rem; line-height: 1.2; }
.brand-sub{ font-size: .78rem; opacity: .75; }

.sidebar-nav{
  padding: 10px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;               /* <-- nav area scroll */
  min-height: 0;
}

.nav-section-title{
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .6;
  padding: 8px 10px 6px;
}

.nav-item, .nav-sub{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  text-decoration: none;
  color: rgba(233,238,252,.9);
  transition: transform .12s ease, background .12s ease, box-shadow .12s ease;
  margin: 4px 4px;
}

.nav-item i, .nav-sub i{ font-size: 1.05rem; opacity: .9; }

.nav-item:hover, .nav-sub:hover{
  background: rgba(255,255,255,.07);
  transform: translateY(-1px);
}

.nav-item.active, .nav-sub.active{
  background: linear-gradient(90deg, rgba(77,163,255,.25), rgba(77,163,255,.06));
  box-shadow: 0 10px 22px rgba(0,0,0,.22);
  border: 1px solid rgba(77,163,255,.25);
}

/* Accordion in sidebar */
.sidebar-acc{ background: transparent; border: 0; }

.sidebar-acc-btn{
  background: rgba(255,255,255,.04);
  color: rgba(233,238,252,.92);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px !important;
  margin: 4px 4px;
  padding: 10px 12px;
  box-shadow: none;
}

.sidebar-acc-btn:focus{ box-shadow: none; }

.sidebar-acc .accordion-button::after{
  filter: invert(1);
  opacity: .8;
}

.sidebar-acc-body{ padding: 6px 0 10px; background: transparent; }

/* Sidebar footer */
.sidebar-footer{
  margin-top: auto;
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: grid;
  gap: 10px;
}

.user-pill{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
}

.user-dot{
  width: 10px; height: 10px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 6px rgba(34,197,94,.15);
}

.sidebar-logout{ border-radius: 14px; }

/* ===============================
   TOPBAR (GRAY THEME)
================================ */
.topbar{
  flex: 0 0 auto;
  z-index: 10;
}

.topbar-gray{
  height: 84px;
  background: linear-gradient(180deg, #4b5563 0%, #1f2937 100%);
  border-bottom: 1px solid rgba(15,23,42,.10);
  color: #f8fafc;
}

.topbar-gray .container-fluid{
  padding-left: 28px;
  padding-right: 28px;
}

.page-icon{
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(129, 131, 139, 0.05);
  border: 1px solid rgba(236, 241, 251, 0.1);
}

.page-icon i{ font-size: 1.35rem; color: #4f87ff; }

.page-title{
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.1;
  color: #f8fafc;
}

.page-subtitle{
  font-size: .85rem;
  color: rgba(247, 248, 252, 0.65);
}

/* User box */
.user-box{
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 14px 0 6px;
  border-radius: 999px;
  background: rgba(245, 246, 246, 0.04);
  border: 1px solid rgba(77, 122, 228, 0.1);
  color: #ffffff;
}

.user-box:hover{ background: rgba(255, 255, 255, 0.08); }

.user-avatar{
  width: 38px; height: 38px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #3b82f6, #22c55e);
}

.user-name{ font-weight: 700; font-size: .9rem; max-width: 200px; }
.user-role{ font-size: .72rem; color: rgba(248, 249, 252, 0.6); }

/* ===============================
   TABLE / CARD POLISH
================================ */
.page-card{
  border-radius: 16px;
  border: 1px solid rgba(15,23,42,.08);
  box-shadow: 0 10px 24px rgba(15,23,42,.08);
}

.table-modern thead th{
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(15,23,42,.65);
  background: #f8fafc;
  border-bottom: 1px solid rgba(15,23,42,.10);
  padding: 14px 12px;
}

.table-modern td{
  padding: 14px 12px;
  border-color: rgba(15,23,42,.08);
}

.table-modern tbody tr:hover{ background: #f1f5f9; }

/* status pill */
.status-pill{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 700;
  border: 1px solid rgba(15,23,42,.10);
}
.status-pill.active{
  background: #dcfce7;
  color: #166534;
  border-color: rgba(22,101,52,.18);
}

/* animated danger badge (optional) */
@keyframes pulse { 0%{transform:scale(1)} 50%{transform:scale(1.15)} 100%{transform:scale(1)} }
.badge.bg-danger { animation: pulse 1.5s infinite; }
 
/* ===============================
   MOBILE RESPONSIVE
================================ */

/* Default: desktop sidebar fixed */
.app-shell { display: flex; height: 100vh; }

/* Make tables scroll horizontally on small screens */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Offcanvas-like sidebar on small screens */
@media (max-width: 991.98px) {

  /* Hide desktop sidebar and use overlay sidebar */
  .sidebar {
    position: fixed;
    left: -295px;            /* hidden by default */
    top: 0;
    height: 100vh;
    width: 285px;
    z-index: 1045;
    transition: left .2s ease;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
  }

  /* When open */
  body.sidebar-open .sidebar {
    left: 0;
  }

  /* Dim background when sidebar is open */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1040;
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  /* Main takes full width */
  .main {
    width: 100%;
  }

  /* Reduce padding on small screens */
  .main-content {
    padding: 16px;
  }

  /* Topbar: less height and padding */
  .topbar-gray {
    height: auto;
    padding: 12px 0;
  }

  .topbar-gray .container-fluid {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Page icon + titles smaller */
  .page-icon { width: 42px; height: 42px; border-radius: 14px; }
  .page-icon i { font-size: 1.1rem; }
  .page-title { font-size: 1.05rem; }
  .page-subtitle { font-size: .8rem; }

  /* User box smaller (avoids overflow) */
  .user-box {
    height: 44px;
    padding: 0 10px 0 6px;
  }
  .user-name { max-width: 140px; }
}

/* Very small phones */
@media (max-width: 575.98px) {
  .page-subtitle { display: none; }   /* optional: cleaner */
  .user-name { max-width: 110px; }
}
.sidebar-acc-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#invoiceTable th, #invoiceTable td {
  padding-left: .5rem;
  padding-right: .5rem;
}
