@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Manrope:wght@500;600;700;800&display=swap');

/* Konekt Theme Tokens & CSS Variables */
:root {
  --theme-primary: #FF9800;
  --theme-primary-rgb: 255, 152, 0;
  --theme-primary-hover: #FFB74D;
  --theme-on-primary: #1E1E2D;

  --theme-secondary: #1E1E2D;
  --theme-secondary-rgb: 30, 30, 45;
  --theme-secondary-hover: #2B2B40;
  --theme-on-secondary: #FFFFFF;

  --konekt-orange: var(--theme-primary);
  --konekt-orange-hover: var(--theme-primary-hover);
  --brand-primary: var(--theme-primary);
  --brand-secondary: var(--theme-secondary);

  --konekt-black: #000000;
  --konekt-white: #FFFFFF;
  --konekt-gray-light: #F4F6F9;
  --konekt-gray-card: #FFFFFF;
  --konekt-gray-dark: var(--theme-secondary);
  --konekt-gray-dark-card: #151521;
  --konekt-text-main-light: #181C32;
  --konekt-text-muted-light: #5E6278;
  --konekt-border-light: #E4E6EF;

  --konekt-text-main-dark: #FFFFFF;
  --konekt-text-muted-dark: #92929F;
  --konekt-border-dark: #2B2B40;

  --konekt-success: #50CD89;
  --konekt-warning: #FFC700;
  --konekt-error: #F1416C;
  --konekt-info: #009EF7;

  --sidebar-width: 260px;
  --topbar-height: 70px;

  /* Active theme dynamic mappings */
  --bg-app: var(--konekt-gray-light);
  --bg-card: var(--konekt-gray-card);
  --bg-sidebar: #FFFFFF;
  --bg-topbar: #FFFFFF;
  --text-main: var(--konekt-text-main-light);
  --text-muted: var(--konekt-text-muted-light);
  --border-color: var(--konekt-border-light);
  --table-hover-bg: rgba(0, 0, 0, 0.02);

  /* Bootstrap primary mappings */
  --bs-primary: var(--theme-primary);
  --bs-primary-rgb: var(--theme-primary-rgb);
  --bs-primary-bg-subtle: rgba(var(--theme-primary-rgb), 0.15);
  --bs-primary-border-subtle: rgba(var(--theme-primary-rgb), 0.25);
  --bs-primary-text-emphasis: var(--theme-primary);
  --bs-link-color: var(--theme-primary);
  --bs-link-hover-color: var(--theme-primary-hover);
}

/* Dark Mode Theme Overrides */
[data-bs-theme="dark"], body.dark-version {
  --bg-app: var(--theme-secondary, var(--konekt-gray-dark));
  --bg-card: var(--konekt-gray-dark-card);
  --bg-sidebar: var(--theme-secondary, #1E1E2D);
  --bg-topbar: var(--theme-secondary, #1E1E2D);
  --text-main: var(--konekt-text-main-dark);
  --text-muted: var(--konekt-text-muted-dark);
  --border-color: var(--konekt-border-dark);
  --table-hover-bg: rgba(255, 255, 255, 0.03);
}

/* General Layout & Fonts */
* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, h5, h6, .navbar-brand, .btn, .nav-link, .card-title, .modal-title {
  font-family: 'Manrope', sans-serif !important;
  font-weight: 700;
}

/* Navigation Layout */
#app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-left: 8px solid var(--konekt-orange);
  border-right: none;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1040;
  transition: transform 0.3s ease, width 0.3s ease;
}

.sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  border-bottom: none;
}

.sidebar-menu {
  padding: 1rem 0;
  overflow-y: auto;
  flex: 1;
}

.menu-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.75rem 1.5rem 0.35rem 1.5rem;
}

.nav-item {
  list-style: none;
}

.nav-link-custom {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.925rem;
  font-weight: 600;
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
}

.nav-link-custom i {
  font-size: 1.15rem;
  width: 1.75rem;
  margin-right: 0.5rem;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.nav-link-custom:hover {
  color: var(--konekt-orange);
  background-color: rgba(255, 152, 0, 0.05);
}

.nav-link-custom:hover i {
  color: var(--konekt-orange);
}

.nav-link-custom.active {
  color: var(--konekt-orange);
  background-color: rgba(255, 152, 0, 0.1);
  border-left-color: var(--konekt-orange);
}

.nav-link-custom.active i {
  color: var(--konekt-orange);
}

.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left 0.3s ease;
}

.topbar {
  height: var(--topbar-height);
  background-color: var(--bg-topbar);
  border-bottom: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.content-body {
  padding: 1.75rem;
  flex: 1;
}

/* Card Styling */
.card-konekt {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  margin-bottom: 1.5rem;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.card-konekt .card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-konekt .card-body {
  padding: 1.5rem;
}

/* Metric Cards */
.metric-card {
  display: flex;
  align-items: center;
  padding: 1.25rem 1.5rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

.metric-icon {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-right: 1.25rem;
  flex-shrink: 0;
}

.metric-icon.orange {
  background-color: rgba(255, 152, 0, 0.15);
  color: var(--konekt-orange);
}

.metric-icon.green {
  background-color: rgba(80, 205, 137, 0.15);
  color: var(--konekt-success);
}

.metric-icon.blue {
  background-color: rgba(0, 158, 247, 0.15);
  color: var(--konekt-info);
}

.metric-icon.purple {
  background-color: rgba(114, 57, 234, 0.15);
  color: #7239EA;
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 0.15rem;
  font-family: 'Manrope', sans-serif;
}

.metric-label {
  font-size: 0.825rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Primary Button KONEKT Style */
.btn-konekt-primary {
  background-color: var(--theme-primary, var(--konekt-orange)) !important;
  color: var(--theme-on-primary, #000000) !important;
  font-weight: 600;
  border: none !important;
  border-radius: 8px;
  padding: 0.6rem 1.25rem;
  transition: all 0.2s ease;
}

.btn-konekt-primary:hover, .btn-konekt-primary:focus {
  background-color: var(--theme-primary-hover, var(--konekt-orange-hover)) !important;
  color: var(--theme-on-primary, #000000) !important;
  box-shadow: 0 4px 12px rgba(var(--theme-primary-rgb, 255, 152, 0), 0.3);
}

.btn-konekt-outline {
  border: 1.5px solid var(--theme-primary, var(--konekt-orange)) !important;
  color: var(--theme-primary, var(--konekt-orange)) !important;
  background: transparent !important;
  font-weight: 600;
  border-radius: 8px;
  padding: 0.6rem 1.25rem;
  transition: all 0.2s ease;
}

.btn-konekt-outline:hover {
  background-color: var(--theme-primary, var(--konekt-orange)) !important;
  color: var(--theme-on-primary, #000000) !important;
}

/* Bootstrap Primary Helpers with Custom ISP Theme Variables */
.text-primary {
  color: var(--theme-primary) !important;
}
.bg-primary {
  background-color: var(--theme-primary) !important;
  color: var(--theme-on-primary, #FFFFFF) !important;
}
.bg-primary-subtle {
  background-color: rgba(var(--theme-primary-rgb, 255, 152, 0), 0.15) !important;
  color: var(--theme-primary) !important;
}
.border-primary {
  border-color: var(--theme-primary) !important;
}

.btn-secondary-custom {
  background-color: var(--border-color);
  color: var(--text-main);
  border: none;
  font-weight: 600;
  border-radius: 8px;
  padding: 0.6rem 1.25rem;
}

/* Data Tables */
.table-custom {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 0;
  color: var(--text-main);
}

.table-custom th {
  background-color: var(--bg-app);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.775rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  border-top: 1px solid var(--border-color);
}

.table-custom th:first-child {
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}

.table-custom th:last-child {
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}

.table-custom td {
  padding: 1rem 1.25rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
}

.table-custom tbody tr:hover {
  background-color: var(--table-hover-bg);
}

/* Status Badges */
.badge-status {
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.badge-status.active, .badge-status.completed, .badge-status.success {
  background-color: rgba(80, 205, 137, 0.15);
  color: var(--konekt-success);
}

.badge-status.pending, .badge-status.warning {
  background-color: rgba(255, 199, 0, 0.15);
  color: #B58100;
}

.badge-status.inactive, .badge-status.disabled, .badge-status.failed, .badge-status.error {
  background-color: rgba(241, 65, 108, 0.15);
  color: var(--konekt-error);
}

.badge-status.info {
  background-color: rgba(0, 158, 247, 0.15);
  color: var(--konekt-info);
}

.badge-root {
  background-color: rgba(255, 152, 0, 0.2);
  color: #D67D00;
  border: 1px solid rgba(255, 152, 0, 0.4);
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 700;
}

/* Quota Indicator Bar */
.quota-box {
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.progress-konekt {
  height: 8px;
  border-radius: 4px;
  background-color: var(--border-color);
  overflow: hidden;
}

.progress-bar-konekt {
  height: 100%;
  background-color: var(--konekt-orange);
  transition: width 0.3s ease;
}

.progress-bar-konekt.full {
  background-color: var(--konekt-error);
}

/* Form Controls */
.form-label-custom {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.form-control-custom, .form-select-custom {
  width: 100%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control-custom:focus, .form-select-custom:focus {
  outline: none;
  border-color: var(--konekt-orange);
  box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.2);
}

/* Modals */
.modal-content-konekt {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-main);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.modal-header-konekt {
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
}

.modal-footer-konekt {
  border-top: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
}

/* Key display area */
.key-box {
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  font-family: monospace;
  font-size: 0.825rem;
  word-break: break-all;
  user-select: all;
  color: var(--text-main);
}

/* Mobile responsive hamburger menu */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .table-responsive-card {
    display: block;
    width: 100%;
    overflow-x: auto;
  }
}
