:root {
  --primary: #3f3d99;
  --primary-color: #3f3d99;
  --primary-active: #5a58a7;
  --primary-hover: #35338a;
  --bg: #f6f8ff;
  --text: #1f2a44;
  --text-muted: #6c757d;
  --border: #a8b8d0;
  --border-light: #ced4da;
  --input-border: #a8b8d0;
  --rs-border: #a8b8d0;
  --rs-placeholder: #808080;
  --white: #ffffff;
  --pink-bg: #ffdfed;
  --pink-text: #e91e63;
  --datepicker-btn: #1976d2;
  --header-h: 64px;
  --nav-h: 46px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
  color: inherit;
}

button,
input,
select {
  font-family: inherit;
}

/* ==================== LOGIN ==================== */
.login-body {
  justify-content: center;
  align-items: center;
  background: var(--bg);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: var(--white);
  padding: 40px 30px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(63, 61, 153, 0.08);
  text-align: center;
}

.login-card h2 {
  color: #111827;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 30px;
  line-height: 1.4;
}

.login-btn {
  width: 100%;
  padding: 12px;
  margin-top: 10px;
}

.forgot-password {
  margin-top: 20px;
  font-size: 0.8rem;
}

.forgot-password a {
  color: var(--primary);
  font-weight: 500;
}

.forgot-password a:hover {
  text-decoration: underline;
}

/* ==================== TOP HEADER ==================== */
.top-header {
  background: var(--white);
  min-height: var(--header-h);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 20px;
  border-bottom: 1px solid #edf2f7;
}

.logo img {
  height: 48px;
  width: auto;
  display: block;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-info .bell {
  color: #6c757d;
  font-size: 1.15rem;
  cursor: pointer;
}

.user-info .greeting {
  font-weight: 600;
  color: #212529;
  font-size: 0.85rem;
}

.logout-btn {
  border: none;
  background: transparent;
  padding: 0;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #212529;
}

.logout-btn:hover {
  color: var(--primary);
}

/* ==================== NAVBAR (matches React portal navBar) ==================== */
.navbar {
  background: var(--primary);
  padding: 0 8px;
  display: flex;
  align-items: stretch;
  gap: 0;
  position: relative;
  z-index: 1000;
  min-height: var(--nav-h);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}

.nav-item {
  position: relative;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #fff;
  padding: 12px 14px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  user-select: none;
}

a.nav-link {
  color: #fff;
  text-decoration: none;
}

.nav-link i {
  font-size: 0.95rem;
  opacity: 0.95;
}

.nav-item:hover > .nav-link,
.nav-item.open > .nav-link {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-item.active > .nav-link {
  background: var(--primary-active);
  color: #fff;
  border-bottom: 3px solid #ffffff;
  font-weight: 600;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--primary);
  min-width: 260px;
  z-index: 9999;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  padding: 4px 0;
  margin: 0;
  list-style: none;
  /* Keep invisible but present so hover can bridge — avoids click miss */
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0);
}

/* Invisible hover bridge so menu doesn't close between trigger and items */
.dropdown-menu::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -12px;
  height: 12px;
}

.nav-item:hover > .dropdown-menu,
.nav-item.open > .dropdown-menu,
.nav-item:focus-within > .dropdown-menu {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.dropdown-item {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #e8e8ff !important;
  font-size: 0.84rem;
  text-decoration: none !important;
  cursor: pointer;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff !important;
}

.dropdown-item i {
  width: 16px;
  text-align: center;
  pointer-events: none;
}

/* ==================== LAYOUT ==================== */
.main-content {
  padding: 20px 24px 28px;
  flex: 1;
  width: 100%;
}

/* ==================== BUTTONS (Bootstrap btn-primary look) ==================== */
.btn-primary {
  background: var(--primary);
  color: var(--white);
  border: 1px solid var(--primary);
  padding: 7px 16px;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.5;
  height: 38px;
  white-space: nowrap;
  transition:
    background-color 0.15s ease-in-out,
    border-color 0.15s ease-in-out;
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

.btn-outline {
  border: 1px solid var(--primary);
  background: var(--white);
  color: var(--primary);
  padding: 7px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.875rem;
  height: 38px;
}

.btn-outline:hover {
  background: #f5f5ff;
}

.btn-search {
  min-width: 96px;
}

/* ==================== PINK STAT CARD ==================== */
.stat-box-pink {
  background: var(--pink-bg);
  border-radius: 8px;
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  min-height: 96px;
}

.stat-box-pink .title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.stat-box-pink .count {
  font-size: 2rem;
  font-weight: 700;
  color: var(--pink-text);
  line-height: 1.1;
}

.stat-box-pink i {
  font-size: 3.2rem;
  color: rgba(233, 30, 99, 0.22);
}

/* ==================== CONTENT CARD (Bootstrap Card) ==================== */
.content-card {
  width: 1300px !important;
  margin: 0 auto !important;
  background: var(--white);
  border-radius: 8px;
  border: 1px solid #e9ecef;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  padding: 20px 22px 24px;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid #eef0f4;
  background: transparent;
}

.card-header-flex {
  justify-content: space-between;
  align-items: center;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header h3,
.card-title-group h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
}

.icon-circle,
.card-icon {
  width: 34px;
  height: 34px;
  background: #edebfc;
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ==================== OUTLINED FLOATING LABEL FIELDS ==================== */
.field-outlined {
  position: relative;
  margin-top: 10px;
}

.field-outlined > label,
.input-group > label {
  position: absolute;
  top: -7px;
  left: 10px;
  background: var(--white);
  padding: 0 5px;
  font-size: 0.72rem;
  color: var(--primary);
  z-index: 3;
  line-height: 1;
  font-weight: 500;
  pointer-events: none;
}

.field-outlined > label .req,
.input-group > label .req,
.field-outlined > label span,
.filter-group label span {
  color: #dc3545;
}

.input-group {
  position: relative;
  margin-bottom: 0;
  text-align: left;
}

.input-wrapper {
  position: relative;
  border: 1px solid var(--rs-border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  min-height: 38px;
  background: var(--white);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.input-wrapper.focus-wrapper,
.input-wrapper:focus-within,
.input-group:focus-within .rs-control,
.input-group:focus-within .input-wrapper,
.field-outlined:focus-within .rs-control,
.field-outlined:focus-within .rdp-input,
.field-outlined:focus-within .input-wrapper {
  border-color: #80bdff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.15);
}

.input-wrapper i.icon-left {
  color: var(--primary);
  font-size: 0.9rem;
  margin-right: 8px;
}

.input-wrapper i.icon-right {
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  margin-left: 8px;
}

.input-wrapper input {
  width: 100%;
  border: none;
  outline: none;
  padding: 8px 0;
  font-size: 0.875rem;
  color: var(--text);
  background: transparent;
}

/* ==================== REACT-SELECT LOOKALIKE ==================== */
.rs-control {
  display: flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--rs-border);
  border-radius: 4px;
  background: var(--white);
  cursor: default;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.rs-control:hover {
  border-color: #b3b3b3;
}

.rs-value-container {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 2px 8px;
  min-width: 0;
  overflow: hidden;
}

.rs-placeholder {
  color: var(--rs-placeholder);
  font-size: 0.875rem;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rs-single-value {
  color: #333;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rs-indicators {
  display: flex;
  align-items: center;
  align-self: stretch;
  flex-shrink: 0;
}

.rs-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  padding: 0 6px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.rs-clear:hover {
  color: #666;
}

.rs-separator {
  align-self: stretch;
  width: 1px;
  background: #cccccc;
  margin: 8px 0;
}

.rs-dropdown {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  padding: 0 10px;
  font-size: 10px;
}

/* Native select fallback still styled like react-select */
.select-wrapper {
  position: relative;
}

.select-wrapper select,
.filter-select {
  width: 100%;
  min-height: 38px;
  padding: 6px 36px 6px 10px;
  border: 1px solid var(--rs-border);
  border-radius: 4px;
  font-size: 0.875rem;
  appearance: none;
  outline: none;
  color: #333;
  background: var(--white);
  cursor: pointer;
}

.select-wrapper::before {
  content: '';
  position: absolute;
  right: 32px;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 20px;
  background: #cccccc;
  pointer-events: none;
}

.select-wrapper::after {
  content: '\f107';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  position: absolute;
  right: 12px;
  top: 50%;
  color: #cccccc;
  font-size: 0.95rem;
  transform: translateY(-50%);
  pointer-events: none;
  border: none;
  width: auto;
  height: auto;
}

.select-wrapper select:invalid,
.filter-select:invalid {
  color: #808080;
}

.select-wrapper select option {
  color: #333333;
}

/* ==================== REACT-DATEPICKER LOOKALIKE ==================== */
.rdp-wrap {
  position: relative;
}

.rdp-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--rs-border);
  border-radius: 4px;
  padding: 6px 42px 6px 12px;
  font-size: 0.875rem;
  color: #333;
  background: var(--white);
  outline: none;
}

.rdp-input:hover {
  border-color: #b3b3b3;
}

.rdp-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #4a90d9;
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  box-shadow: none;
}

.rdp-btn:hover {
  background: #3b7fc4;
}

.rdp-btn i {
  display: none;
}

.rdp-btn::before {
  content: '\00d7';
  font-size: 16px;
  line-height: 1;
  margin-top: -1px;
}

/* ==================== FILTER GRIDS ==================== */
.filters-row,
.filters-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px 16px;
  margin-bottom: 8px;
  align-items: end;
}

.filters-grid-2 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px 16px;
  margin-top: 10px;
  margin-bottom: 18px;
  align-items: end;
}

.filter-group {
  min-width: 0;
}

.filter-actions {
  display: flex;
  align-items: flex-end;
  padding-bottom: 0;
}

.filter-panel {
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 16px 16px 14px;
  margin-bottom: 20px;
  background: var(--white);
}

.filter-panel .filters-grid,
.filter-panel .filter-grid {
  margin-bottom: 12px;
}

.filter-panel .btn-primary {
  margin-top: 4px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 12px;
  align-items: end;
}

/* Legacy filter label (used where not outlined) */
.filter-group > label {
  display: block;
  font-size: 0.72rem;
  color: var(--primary);
  margin-bottom: 4px;
  font-weight: 500;
}

.empty-state {
  background: #fafbfd;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 0.95rem;
  margin-top: 8px;
}

/* ==================== TABLE ==================== */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: 6px;
}

.total-records {
  text-align: right;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.84rem;
  color: var(--text);
  vertical-align: middle;
}

.data-table thead tr:first-child th {
  font-weight: 700;
  color: var(--primary);
  background: #f3f5fc;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.data-table .filter-row th {
  padding: 8px 10px;
  background: var(--white);
  border-bottom: 1px solid var(--border-light);
}

.data-table .filter-row input,
.data-table .filter-row select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.8rem;
  color: #495057;
  font-weight: 400;
  height: 32px;
  background: #fff;
  outline: none;
}

.data-table .filter-row input:focus,
.data-table .filter-row select:focus {
  border-color: #80bdff;
  box-shadow: 0 0 0 0.15rem rgba(0, 123, 255, 0.15);
}

.data-table tbody tr:nth-child(even) {
  background: #fafbfd;
}

.data-table tbody tr:hover {
  background: #f5f7fe;
}

.action-btn {
  border: 1px solid;
  background: var(--white);
  width: 30px;
  height: 30px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  font-size: 0.8rem;
}

.action-btn.edit {
  color: #198754;
  border-color: #198754;
}

.action-btn.edit:hover {
  background: #e8f5ee;
}

.action-btn.delete {
  color: #dc3545;
  border-color: #dc3545;
}

.action-btn.delete:hover {
  background: #fdecee;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}

.page-size .rs-control {
  min-width: 70px;
  min-height: 32px;
}

.page-size select {
  padding: 4px 28px 4px 10px;
  border: 1px solid var(--rs-border);
  border-radius: 4px;
  appearance: none;
  font-size: 0.85rem;
  color: #333;
  background: #fff
    url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23999' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 8px center/10px 10px;
  height: 32px;
}

.page-numbers .page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
}

/* ==================== TOGGLE (Bootstrap form-switch) ==================== */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #ced4da;
  transition: 0.2s;
  border-radius: 20px;
}

.slider:before {
  position: absolute;
  content: '';
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  transition: 0.2s;
  border-radius: 50%;
}

input:checked + .slider {
  background: #0d6efd;
}

input:checked + .slider:before {
  transform: translateX(16px);
}

/* ==================== CREATE FORM HELPERS ==================== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px 16px;
  margin-top: 12px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 28px;
}

.file-upload-wrapper {
  display: flex;
  align-items: center;
  border: 1px solid var(--rs-border);
  border-radius: 4px;
  overflow: hidden;
  min-height: 38px;
  background: #fff;
}

.file-upload-wrapper input[type='file'] {
  display: none;
}

.file-upload-btn {
  background: #f8f9fa;
  border-right: 1px solid var(--rs-border);
  padding: 0 12px;
  height: 38px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 0.85rem;
  color: #495057;
}

.file-upload-text {
  padding-left: 12px;
  font-size: 0.85rem;
  color: #94a3b8;
}

/* ==================== FOOTER ==================== */
footer {
  background: var(--primary);
  color: var(--white);
  text-align: center;
  padding: 14px;
  font-size: 0.8rem;
  margin-top: auto;
}

.back-to-top {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #2196f3;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(33, 150, 243, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  z-index: 1000;
}

.back-to-top:hover {
  background: #1976d2;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1100px) {
  .filters-row,
  .filters-grid,
  .filters-grid-2,
  .filter-grid,
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .navbar {
    overflow-x: auto;
  }
}

@media (max-width: 640px) {
  .filters-row,
  .filters-grid,
  .filters-grid-2,
  .filter-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .main-content {
    padding: 14px;
  }

  .user-info .greeting {
    display: none;
  }

  .card-header-flex {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

/* ==================== TOAST ==================== */
.toast-popup {
  visibility: hidden;
  min-width: 250px;
  background-color: #f44336;
  color: #fff;
  text-align: center;
  border-radius: 4px;
  padding: 16px;
  position: fixed;
  z-index: 9999;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  font-size: 14px;
  box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
  opacity: 0;
  transition: opacity 0.3s, bottom 0.3s, visibility 0.3s;
}

.toast-popup.show {
  visibility: visible;
  opacity: 1;
  bottom: 50px;
}
