/* ============================================================
   ISP ACS — Custom Styles
   Bootstrap 5 companion stylesheet
   ============================================================ */

/* --- CSS Variables ----------------------------------------- */
:root {
  --sidebar-width: 250px;
  --sidebar-bg: #0f1923;
  --sidebar-border: #1e2d3d;
  --sidebar-text: #8fa8c0;
  --sidebar-text-active: #ffffff;
  --sidebar-accent: #0d6efd;
  --sidebar-hover-bg: #1a2a3a;
  --topnav-height: 58px;
  --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --card-shadow-hover: 0 8px 28px rgba(0, 0, 0, 0.14);
  --body-bg: #f0f4f8;
  --stat-icon-size: 2.6rem;
  --transition-fast: 0.18s ease;
  --transition-med: 0.28s ease;
}

/* --- Global ------------------------------------------------- */
html, body {
  height: 100%;
}

body {
  background-color: var(--body-bg);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 0.9rem;
  color: #2c3e50;
  overflow-x: hidden;
}

/* --- Sidebar ----------------------------------------------- */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition-med), transform var(--transition-med);
}

#sidebar .sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--sidebar-border);
  text-decoration: none;
  min-height: var(--topnav-height);
}

#sidebar .sidebar-brand .brand-icon {
  font-size: 1.55rem;
  color: var(--sidebar-accent);
  flex-shrink: 0;
}

#sidebar .sidebar-brand .brand-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.02em;
  line-height: 1.2;
  white-space: nowrap;
}

#sidebar .sidebar-brand .brand-sub {
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--sidebar-text);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#sidebar .sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #4a6278;
  padding: 1.2rem 1.25rem 0.35rem;
}

#sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 1.25rem;
  color: var(--sidebar-text);
  border-radius: 0;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--transition-fast), color var(--transition-fast);
  border-left: 3px solid transparent;
  white-space: nowrap;
}

#sidebar .nav-link i {
  font-size: 1.05rem;
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
}

#sidebar .nav-link:hover {
  background: var(--sidebar-hover-bg);
  color: #c8d8e8;
  border-left-color: rgba(13, 110, 253, 0.4);
}

#sidebar .nav-link.active {
  background: rgba(13, 110, 253, 0.15);
  color: var(--sidebar-text-active);
  border-left-color: var(--sidebar-accent);
}

#sidebar .nav-link .nav-badge {
  margin-left: auto;
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
}

#sidebar .sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--sidebar-border);
  font-size: 0.75rem;
  color: #3d5366;
  text-align: center;
}

/* --- Main Layout ------------------------------------------- */
#main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-med);
}

/* --- Top Navbar -------------------------------------------- */
#topnav {
  height: var(--topnav-height);
  background: #ffffff;
  border-bottom: 1px solid #e2eaf2;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1030;
  gap: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

#topnav .topnav-org {
  font-size: 0.8rem;
  font-weight: 600;
  color: #4a6278;
  letter-spacing: 0.02em;
}

#topnav .topnav-sep {
  flex: 1;
}

#topnav .topnav-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: #2c3e50;
}

#topnav .topnav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0d6efd, #0a58ca);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* --- Page Content ------------------------------------------ */
.page-content {
  flex: 1;
  padding: 1.75rem 1.75rem 2.5rem;
}

.page-header {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #1a2b3c;
  margin: 0;
}

.page-subtitle {
  font-size: 0.8rem;
  color: #6c8294;
  margin: 0;
}

/* --- Stat Cards -------------------------------------------- */
.stat-card {
  background: #ffffff;
  border: 1px solid #e2eaf2;
  border-radius: 10px;
  padding: 1.35rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  box-shadow: var(--card-shadow);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
  text-decoration: none;
  color: inherit;
}

.stat-card:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-2px);
}

.stat-card .stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--stat-icon-size);
  flex-shrink: 0;
}

.stat-card .stat-icon i {
  font-size: 1.6rem;
}

.stat-card .stat-value {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1;
  color: #1a2b3c;
}

.stat-card .stat-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: #7a94a8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.2rem;
}

.stat-card.primary .stat-icon { background: rgba(13, 110, 253, 0.1); color: #0d6efd; }
.stat-card.success .stat-icon { background: rgba(25, 135, 84, 0.1); color: #198754; }
.stat-card.warning .stat-icon { background: rgba(255, 193, 7, 0.12); color: #e6a800; }
.stat-card.info .stat-icon { background: rgba(13, 202, 240, 0.1); color: #0dcaf0; }
.stat-card.danger .stat-icon { background: rgba(220, 53, 69, 0.1); color: #dc3545; }

/* --- Content Cards ----------------------------------------- */
.content-card {
  background: #ffffff;
  border: 1px solid #e2eaf2;
  border-radius: 10px;
  box-shadow: var(--card-shadow);
}

.content-card .card-header {
  background: transparent;
  border-bottom: 1px solid #e8f0f7;
  padding: 1rem 1.35rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: #1a2b3c;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.content-card .card-body {
  padding: 1.25rem 1.35rem;
}

/* --- Tables ------------------------------------------------ */
.acs-table {
  width: 100%;
  font-size: 0.855rem;
}

.acs-table thead th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #7a94a8;
  background: #f7fafd;
  border-bottom: 2px solid #e2eaf2;
  padding: 0.7rem 0.85rem;
  white-space: nowrap;
}

.acs-table tbody tr {
  border-bottom: 1px solid #f0f5fb;
  transition: background var(--transition-fast);
}

.acs-table tbody tr:hover {
  background: #f7faff;
}

.acs-table tbody td {
  padding: 0.65rem 0.85rem;
  vertical-align: middle;
  color: #2c3e50;
}

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

/* --- Status Badges ----------------------------------------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.status-badge.online {
  background: rgba(25, 135, 84, 0.12);
  color: #146c43;
}

.status-badge.online::before { background: #198754; }

.status-badge.offline {
  background: rgba(108, 117, 125, 0.12);
  color: #5a6a74;
}

.status-badge.offline::before { background: #adb5bd; }

.status-badge.error {
  background: rgba(220, 53, 69, 0.12);
  color: #b02a37;
}

.status-badge.error::before { background: #dc3545; }

.status-badge.registered {
  background: rgba(13, 110, 253, 0.1);
  color: #0a58ca;
}

.status-badge.registered::before { background: #0d6efd; }

/* --- Feature Locked Overlay -------------------------------- */
.feature-locked-wrapper {
  position: relative;
}

.feature-locked {
  position: absolute;
  inset: 0;
  background: rgba(15, 25, 35, 0.72);
  backdrop-filter: blur(3px);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  gap: 0.6rem;
}

.feature-locked .lock-icon {
  font-size: 2.5rem;
  color: #f8c841;
  opacity: 0.9;
}

.feature-locked .lock-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
  text-align: center;
  max-width: 280px;
}

.feature-locked .lock-sub {
  font-size: 0.78rem;
  color: #a8c0d4;
}

/* --- Login Page -------------------------------------------- */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f1923 0%, #0d2136 40%, #0a3254 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #ffffff;
  border-radius: 14px;
  padding: 2.5rem 2.25rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}

.login-brand-icon {
  width: 68px;
  height: 68px;
  border-radius: 16px;
  background: linear-gradient(135deg, #0d6efd, #0a3fa3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: white;
  margin: 0 auto 1.25rem;
  box-shadow: 0 8px 20px rgba(13, 110, 253, 0.35);
}

.login-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #0f1923;
  text-align: center;
  margin-bottom: 0.2rem;
}

.login-tagline {
  font-size: 0.78rem;
  color: #7a94a8;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1.75rem;
}

/* --- Progress Bars (usage) --------------------------------- */
.usage-row {
  margin-bottom: 0.85rem;
}

.usage-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 0.3rem;
  color: #4a6278;
}

.usage-label .usage-pct {
  font-weight: 600;
  color: #1a2b3c;
}

/* --- Tabs -------------------------------------------------- */
.acs-tabs .nav-link {
  color: #6c8294;
  font-size: 0.855rem;
  font-weight: 500;
  padding: 0.6rem 1rem;
  border-bottom: 2px solid transparent;
  border-top: none;
  border-left: none;
  border-right: none;
  border-radius: 0;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.acs-tabs .nav-link:hover {
  color: #1a2b3c;
  border-bottom-color: #c8d8e8;
}

.acs-tabs .nav-link.active {
  color: #0d6efd;
  border-bottom-color: #0d6efd;
  background: transparent;
  font-weight: 600;
}

/* --- Flash Messages ---------------------------------------- */
.flash-container {
  position: fixed;
  top: calc(var(--topnav-height) + 0.75rem);
  right: 1.25rem;
  z-index: 1080;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flash-container .alert {
  font-size: 0.855rem;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* --- Misc -------------------------------------------------- */
.text-muted-sm {
  font-size: 0.78rem;
  color: #8fa8c0;
}

.mono {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.82rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #8fa8c0;
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.9rem;
  margin: 0;
}

/* Permission checkbox groups */
.perm-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #4a6278;
  margin-bottom: 0.4rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid #e2eaf2;
}

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

/* License feature matrix */
.feature-check { color: #198754; font-size: 1rem; }
.feature-cross { color: #adb5bd; font-size: 1rem; }

/* --- Responsive -------------------------------------------- */
@media (max-width: 991.98px) {
  #sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
  }

  #sidebar.sidebar-open {
    transform: translateX(0);
  }

  #main-content {
    margin-left: 0;
  }

  .flash-container {
    width: calc(100vw - 2rem);
    right: 1rem;
  }
}

@media (max-width: 575.98px) {
  .page-content {
    padding: 1.25rem 1rem 2rem;
  }

  .stat-card {
    padding: 1rem;
  }
}

/* Sidebar overlay (mobile) */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1035;
}

@media (max-width: 991.98px) {
  #sidebar-overlay.active {
    display: block;
  }
}

/* Scrollbar styling */
#sidebar::-webkit-scrollbar {
  width: 4px;
}

#sidebar::-webkit-scrollbar-track {
  background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
  background: #1e2d3d;
  border-radius: 4px;
}
