/**
 * Secure Registration Portal — Enterprise Theme
 * Primary: #0d4f8b
 */

:root {
  --primary: #0d4f8b;
  --primary-dark: #0a3d6b;
  --primary-light: #1a6bb5;
  --primary-rgb: 13, 79, 139;
  --accent: #0e7c7b;
  --success: #198754;
  --warning: #c9a00b;
  --danger: #c0392b;
  --info: #0dcaf0;
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --navbar-height: 60px;
  --bg-body: #f0f4f8;
  --bg-card: #ffffff;
  --bg-sidebar: #0a2f52;
  --bg-sidebar-hover: rgba(255, 255, 255, 0.08);
  --bg-sidebar-active: rgba(255, 255, 255, 0.14);
  --text-main: #1a2332;
  --text-muted: #6c7a89;
  --text-sidebar: #c8d6e5;
  --text-sidebar-active: #ffffff;
  --border-color: #dce3eb;
  --shadow-sm: 0 1px 3px rgba(10, 47, 82, 0.06);
  --shadow-md: 0 4px 14px rgba(10, 47, 82, 0.08);
  --radius: 8px;
  --font-sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg-body: #0f1720;
  --bg-card: #1a2430;
  --bg-sidebar: #0a1622;
  --bg-sidebar-hover: rgba(255, 255, 255, 0.06);
  --bg-sidebar-active: rgba(26, 107, 181, 0.35);
  --text-main: #e8eef4;
  --text-muted: #94a3b8;
  --text-sidebar: #a8b8c8;
  --border-color: #2a3a4a;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --primary: #3a8fd4;
  --primary-dark: #2a7fc4;
  --primary-light: #5aa5e0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-body);
  color: var(--text-main);
  margin: 0;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-dark);
}

/* ---------- App Shell ---------- */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--bg-sidebar) 0%, #071e36 100%);
  color: var(--text-sidebar);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  height: var(--navbar-height);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.sidebar-brand img {
  height: 36px;
  width: auto;
}

.sidebar-brand .brand-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.sidebar-brand .brand-sub {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-sidebar);
  opacity: 0.8;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
}

.sidebar-nav .nav-section {
  padding: 0.5rem 1.25rem 0.25rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(200, 214, 229, 0.5);
  font-weight: 600;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.25rem;
  color: var(--text-sidebar);
  font-size: 0.9rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.sidebar-nav .nav-link i {
  width: 1.25rem;
  text-align: center;
  font-size: 0.95rem;
  opacity: 0.85;
}

.sidebar-nav .nav-link:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}

.sidebar-nav .nav-link.active {
  background: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
  border-left-color: var(--primary-light);
}

.sidebar-nav .nav-link .submenu-arrow {
  margin-left: auto;
  font-size: 0.7rem;
  transition: transform var(--transition);
}

.sidebar-nav .nav-link[aria-expanded="true"] .submenu-arrow {
  transform: rotate(90deg);
}

.sidebar-nav .submenu {
  list-style: none;
  padding: 0;
  margin: 0;
  background: rgba(0, 0, 0, 0.15);
}

.sidebar-nav .submenu .nav-link {
  padding-left: 3rem;
  font-size: 0.85rem;
  font-weight: 400;
}

.sidebar-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.sidebar-footer .nav-link {
  color: #f5a9a9;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

/* ---------- Top Navbar ---------- */
.top-navbar {
  height: var(--navbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: var(--shadow-sm);
}

.top-navbar .btn-icon {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  position: relative;
  transition: background var(--transition), color var(--transition);
}

.top-navbar .btn-icon:hover {
  background: var(--bg-body);
  color: var(--primary);
}

.top-navbar .notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

.user-dropdown .dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.25rem 0.5rem;
}

.user-dropdown .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

/* ---------- Page Content ---------- */
.page-content {
  padding: 1.5rem;
  flex: 1;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 0.35rem;
}

.breadcrumb {
  background: transparent;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
}

.breadcrumb-item + .breadcrumb-item::before {
  color: var(--text-muted);
}

.breadcrumb-item a {
  color: var(--text-muted);
}

.breadcrumb-item.active {
  color: var(--primary);
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--text-main);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.25rem;
  font-weight: 600;
}

.card-body {
  padding: 1.25rem;
}

.stat-card {
  border: none;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-md);
  transition: transform var(--transition), box-shadow var(--transition);
  height: 100%;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(10, 47, 82, 0.12);
}

.stat-card .card-body {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-card .stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
  margin: 0;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
  font-weight: 500;
}

.stat-card.stat-primary .stat-icon { background: rgba(var(--primary-rgb), 0.12); color: var(--primary); }
.stat-card.stat-warning .stat-icon { background: rgba(201, 160, 11, 0.15); color: #b8860b; }
.stat-card.stat-success .stat-icon { background: rgba(25, 135, 84, 0.12); color: var(--success); }
.stat-card.stat-danger .stat-icon { background: rgba(192, 57, 43, 0.12); color: var(--danger); }
.stat-card.stat-info .stat-icon { background: rgba(13, 202, 240, 0.15); color: #0aa2c0; }
.stat-card.stat-secondary .stat-icon { background: rgba(108, 117, 125, 0.12); color: #6c757d; }
.stat-card.stat-teal .stat-icon { background: rgba(14, 124, 123, 0.12); color: var(--accent); }

/* ---------- Forms ---------- */
.form-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.form-control,
.form-select {
  border-color: var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  border-radius: 6px;
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(var(--primary-rgb), 0.2);
  background: var(--bg-card);
  color: var(--text-main);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background: #121a24;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
}

/* ---------- Tables ---------- */
.table {
  color: var(--text-main);
  --bs-table-bg: transparent;
  --bs-table-striped-bg: rgba(var(--primary-rgb), 0.03);
  --bs-table-hover-bg: rgba(var(--primary-rgb), 0.06);
}

.table thead th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom-width: 1px;
  white-space: nowrap;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-main);
  padding: 0.35rem 0.6rem;
}

.btn-action {
  cursor: pointer;
}

/* ---------- Auth / Access Layouts ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(135deg, rgba(10, 47, 82, 0.92) 0%, rgba(13, 79, 139, 0.85) 50%, rgba(14, 124, 123, 0.75) 100%),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.auth-card .auth-header {
  background: linear-gradient(135deg, #0a2f52, #0d4f8b);
  color: #fff;
  padding: 1.75rem 1.5rem;
  text-align: center;
}

.auth-card .auth-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0.5rem 0 0.25rem;
}

.auth-card .auth-header p {
  margin: 0;
  opacity: 0.85;
  font-size: 0.85rem;
}

.auth-card .auth-body {
  padding: 1.75rem 1.5rem;
}

.auth-card .auth-footer {
  padding: 0 1.5rem 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: #6c7a89;
}

.access-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-body);
}

.access-header {
  background: linear-gradient(90deg, #0a2f52, #0d4f8b);
  color: #fff;
  padding: 1.25rem 1.5rem;
  text-align: center;
}

.access-header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
}

.access-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.access-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  padding: 2rem;
}

.otp-inputs {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.otp-inputs input {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-main);
}

.otp-inputs input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.2);
}

/* ---------- Error pages ---------- */
.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  background: var(--bg-body);
}

.error-page .error-code {
  font-size: 6rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  opacity: 0.9;
}

/* ---------- Misc ---------- */
.filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.nav-tabs .nav-link {
  color: var(--text-muted);
  font-weight: 600;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
}

.nav-tabs .nav-link.active {
  color: var(--primary);
  background: transparent;
  border-bottom-color: var(--primary);
}

.chart-container {
  position: relative;
  height: 280px;
}

.access-url-box {
  background: rgba(var(--primary-rgb), 0.06);
  border: 1px dashed var(--primary);
  border-radius: var(--radius);
  padding: 1rem;
  word-break: break-all;
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1035;
}

.sidebar-backdrop.show {
  display: block;
}

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }
}

/* Select2 dark compat */
[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection {
  background-color: #121a24;
  border-color: var(--border-color);
  color: var(--text-main);
}

[data-theme="dark"] .select2-dropdown {
  background-color: #1a2430;
  border-color: var(--border-color);
  color: var(--text-main);
}

[data-theme="dark"] .table {
  --bs-table-color: var(--text-main);
  --bs-table-border-color: var(--border-color);
}

[data-theme="dark"] .dropdown-menu {
  background: var(--bg-card);
  border-color: var(--border-color);
}

[data-theme="dark"] .dropdown-item {
  color: var(--text-main);
}

[data-theme="dark"] .dropdown-item:hover {
  background: var(--bg-body);
}

[data-theme="dark"] .modal-content {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-color);
}

[data-theme="dark"] .list-group-item {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-color);
}
