/* ALARM Admin Console - Professional Business Theme */

:root {
  --primary-color: #dc2626;
  --primary-dark: #b91c1c;
  --primary-light: #ef4444;
  --accent-color: #dc2626;
  --accent-light: #ef4444;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #dc2626;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --border-color: #e5e7eb;
  --bg-light: #f9fafb;
  --sidebar-width: 260px;
  --header-height: 70px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-light);
  color: var(--text-primary);
  line-height: 1.6;
}

/* ============================================
   SIDEBAR LAYOUT
   ============================================ */

.wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: #fff;
  color: var(--text-primary);
  z-index: 1000;
  overflow-y: auto;
  transition: transform 0.3s ease;
  border-right: 1px solid var(--border-color);
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 3px;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-brand-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.sidebar-logo {
  width: 64px;
  height: 64px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.brand-main {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--accent-color);
}

.brand-sub {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--text-primary);
}

/* SAFE / APP split styling */
.brand-part-safe {
  color: #000;
  font-weight: 900;
  letter-spacing: 2px;
}
.brand-part-app {
  color: var(--primary-color);
  font-weight: 900;
  margin-left: 6px;
}

.sidebar-nav {
  padding: 20px 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s ease;
  font-weight: 500;
}

.sidebar-link:hover {
  background-color: var(--bg-light);
  color: var(--primary-color);
}

.sidebar-link.active {
  background-color: rgba(220, 38, 38, 0.1);
  color: var(--accent-color);
  border-left: 4px solid var(--accent-color);
  font-weight: 600;
}

.sidebar-link i {
  font-size: 18px;
  width: 24px;
}

.sidebar-divider {
  padding: 8px 20px;
  margin-top: 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  font-weight: 600;
  opacity: 0.6;
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  z-index: 999;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  margin-right: 10px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-user-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-details {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.user-details {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.user-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.user-unit {
  color: var(--text-secondary);
  font-size: 12px;
}

.btn-user-menu {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-user-menu:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.btn-user-menu i {
  font-size: 22px;
}

/* ============================================
   PAGE CONTENT
   ============================================ */

.page-content {
  flex: 1;
  padding: 30px;
}

/* ============================================
   CARDS - PROFESSIONAL BUSINESS STYLE
   ============================================ */

.card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  overflow: hidden;
}

.card-header {
  background: #fff;
  color: var(--text-primary);
  border: none;
  border-bottom: 2px solid var(--border-color);
  padding: 18px 24px;
  font-weight: 700;
  font-size: 16px;
}

.card-body {
  padding: 24px;
}

/* Stats Cards */
.stat-card {
  border-left: 4px solid var(--primary-color);
  position: relative;
}

.stat-card.danger {
  border-left-color: var(--danger-color);
}

.stat-card.warning {
  border-left-color: var(--warning-color);
}

.stat-card.success {
  border-left-color: var(--success-color);
}

.stat-card .card-body {
  padding: 24px;
}

.stat-card h3 {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--primary-color);
}

.stat-card.danger h3 {
  color: var(--danger-color);
}

.stat-card.warning h3 {
  color: var(--warning-color);
}

.stat-card.success h3 {
  color: var(--success-color);
}

.stat-card p {
  color: var(--text-secondary);
  font-weight: 500;
  margin: 0;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
}

/* Stat Icon Backgrounds */
.stat-icon-bg {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.stat-icon-bg i {
  font-size: 32px;
}

.bg-danger-light {
  background-color: rgba(220, 38, 38, 0.1);
}

.bg-warning-light {
  background-color: rgba(245, 158, 11, 0.1);
}

.bg-primary-light {
  background-color: rgba(30, 58, 138, 0.1);
}

.bg-success-light {
  background-color: rgba(16, 185, 129, 0.1);
}

.stat-card:hover .stat-icon-bg {
  transform: scale(1.05);
}

/* ============================================
   BUTTONS - PROFESSIONAL STYLE
   ============================================ */

.btn {
  font-weight: 600;
  padding: 10px 24px;
  border-radius: 8px;
  transition: all 0.2s ease;
  border: none;
  font-size: 14px;
  letter-spacing: 0.3px;
}

.btn-primary {
  background: var(--primary-color);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(30, 58, 138, 0.3);
}

.btn-danger {
  background: var(--danger-color);
  color: #fff;
}

/* Member chips - checkbox styled as chips */
.member-chip {
  position: relative;
}
.member-chip .form-check-input {
  /* visually hide the checkbox but keep it accessible */
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  left: 0;
}
.member-chip .form-check-label {
  display: block; /* full width within the column so all chips match width */
  width: 100%;
  padding: 0.18rem 0.5rem; /* slightly thinner vertical padding */
  border-radius: 999px;
  background: #f3f4f6;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.12s ease-in-out;
  user-select: none;
  font-size: 0.82rem; /* slightly smaller text */
  line-height: 1; /* tighter vertical rhythm */
  min-height: 34px; /* consistent height across chips */
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.member-chip .form-check-label:hover {
  transform: translateY(-1px);
}
.member-chip .form-check-input:checked + .form-check-label {
  background: var(--primary-light); /* lighter red when selected */
  border-color: var(--primary-color);
  color: #fff;
  box-shadow: 0 4px 8px rgba(220, 38, 38, 0.1); /* subtle red shadow */
}
.member-chip .form-check-input:focus + .form-check-label {
  outline: 2px solid rgba(220, 38, 38, 0.12);
}

/* Compact layout when many users - make the checkbox area scrollable if needed */
.member-chip-wrap {
  max-height: 320px;
  overflow: auto;
  padding-right: 6px; /* account for scrollbar */
}

.btn-danger:hover {
  background: #b91c1c;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.btn-success {
  background: var(--success-color);
  color: #fff;
}

.btn-success:hover {
  background: #059669;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-outline-primary {
  border: 2px solid var(--primary-color);
  color: var(--primary-color);
  background: transparent;
}

.btn-outline-primary:hover {
  background: var(--primary-color);
  color: #fff;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 16px;
}

.btn-sm {
  padding: 6px 16px;
  font-size: 13px;
}

/* ============================================
   TABLES
   ============================================ */

.table {
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  font-size: 0.875rem;
}

.table thead th {
  background: var(--bg-light);
  border-bottom: 2px solid var(--primary-color);
  color: var(--text-primary);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.6875rem;
  letter-spacing: 0.5px;
  padding: 12px 14px;
}

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

.table-hover tbody tr {
  transition: background-color 0.2s ease;
}

.table-hover tbody tr:hover {
  background-color: rgba(30, 58, 138, 0.02);
}

/* ============================================
   BADGES
   ============================================ */

.badge {
  padding: 6px 12px;
  font-weight: 600;
  font-size: 11px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.badge-danger {
  background: var(--danger-color);
  color: #fff;
}

.badge-success {
  background: var(--success-color);
  color: #fff;
}

.badge-warning {
  background: var(--warning-color);
  color: #fff;
}

.badge-primary {
  background: var(--primary-color);
  color: #fff;
}

/* ============================================
   FORMS
   ============================================ */

.form-label {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  font-size: 14px;
}

.form-control,
.form-select {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  transition: all 0.2s ease;
  font-size: 14px;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(30, 58, 138, 0.1);
  outline: none;
}

/* ============================================
   ALERTS
   ============================================ */

.alert {
  border: none;
  border-left: 4px solid;
  border-radius: 8px;
  padding: 16px 20px;
  font-size: 14px;
}

.alert-danger {
  background-color: #fef2f2;
  border-left-color: var(--danger-color);
  color: #991b1b;
}

.alert-success {
  background-color: #f0fdf4;
  border-left-color: var(--success-color);
  color: #166534;
}

.alert-warning {
  background-color: #fffbeb;
  border-left-color: var(--warning-color);
  color: #92400e;
}

/* ============================================
   FOOTER
   ============================================ */

.main-footer {
  background: #fff;
  border-top: 1px solid var(--border-color);
  padding: 20px 30px;
  margin-top: auto;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
  font-size: 13px;
}

.footer-left strong {
  color: var(--primary-color);
  font-weight: 700;
}

.footer-right {
  display: flex;
  gap: 10px;
}

.footer-divider {
  color: var(--border-color);
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
}

.login-card {
  border: none;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-brand-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.login-logo {
  width: 100px;
  height: 100px;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.login-brand-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

.login-brand-text .brand-main {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--accent-color);
  margin: 0;
}

.login-brand-text .brand-sub {
  font-size: 52px;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--text-primary);
  margin: 0;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.active {
    transform: translateX(0);
  }

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

  .sidebar-toggle {
    display: block;
  }

  .user-details {
    display: none;
  }
}

@media (max-width: 768px) {
  .page-content {
    padding: 20px 15px;
  }

  .top-header {
    padding: 0 15px;
  }

  .footer-content {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.text-primary {
  color: var(--primary-color) !important;
}

.text-secondary {
  color: var(--text-secondary) !important;
}

.bg-primary {
  background-color: var(--primary-color) !important;
}

.border-primary {
  border-color: var(--primary-color) !important;
}

/* Page Headings */
.page-header {
  margin-bottom: 30px;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.page-header p {
  color: var(--text-secondary);
  margin: 0;
}

/* Loading States */
.spinner-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

/* Modals */
.modal-dialog {
  display: flex;
  align-items: center;
  min-height: calc(100% - 1rem);
}

.modal-dialog-centered {
  min-height: calc(100% - 3.5rem);
}

.modal-header {
  background: #fff;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
}

.modal-title {
  font-weight: 700;
}

.modal-content {
  border: none;
  border-radius: 12px;
  overflow: hidden;
}

/* Dropdown Menus */
.dropdown-menu {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  padding: 8px 0;
}

.dropdown-item {
  padding: 10px 20px;
  font-size: 14px;
  transition: all 0.2s ease;
}

.dropdown-item:hover {
  background-color: rgba(30, 58, 138, 0.05);
  color: var(--primary-color);
}

.dropdown-item i {
  margin-right: 10px;
  width: 18px;
}

.dropdown-header {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 13px;
  padding: 10px 20px 8px;
}

.dropdown-divider {
  margin: 8px 0;
}

/* TOTP Timer (rendered in header) */

/* Pagination */
.pagination {
  gap: 5px;
}

.page-link {
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 8px 14px;
  font-weight: 600;
}

.page-link:hover {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: #fff;
}

.page-item.active .page-link {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

/* Breadcrumbs */
.breadcrumb {
  background: none;
  padding: 0;
  margin-bottom: 20px;
}

.breadcrumb-item a {
  color: var(--text-secondary);
  text-decoration: none;
}

.breadcrumb-item a:hover {
  color: var(--primary-color);
}

.breadcrumb-item.active {
  color: var(--text-primary);
  font-weight: 600;
}

/* Status Indicators */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
}

.status-dot.success {
  background-color: var(--success-color);
}

.status-dot.danger {
  background-color: var(--danger-color);
}

.status-dot.warning {
  background-color: var(--warning-color);
}

/* Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

.login-card {
  max-width: 450px;
  width: 100%;
}

.login-logo {
  font-size: 4rem;
  color: var(--alarm-red);
}

/* Alarm Priority Colors */
.priority-high {
  color: var(--alarm-red);
  font-weight: 700;
}

.priority-medium {
  color: var(--alarm-orange);
  font-weight: 600;
}

.priority-low {
  color: #6c757d;
  font-weight: 500;
}

/* Status Badges */
.status-active {
  background-color: var(--alarm-green);
}

.status-pending {
  background-color: var(--alarm-orange);
}

.status-inactive {
  background-color: #6c757d;
}

/* Responsive */
@media (max-width: 768px) {
  .stat-card {
    margin-bottom: 1rem;
  }

  .table-responsive {
    font-size: 0.875rem;
  }
}

/* Material Symbols styling */
.material-symbols-outlined {
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  vertical-align: -0.125em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-inline {
  font-size: 1.05rem;
  vertical-align: -0.125em;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-in;
}

/* Compact dashboard stat cards */
.stat-card-compact .card-body {
  padding: 0.75rem 1rem;
}

.stat-card-compact .stat-label {
  font-size: 0.675rem;
  letter-spacing: 0.04em;
  color: #6b7280; /* muted text */
  text-transform: uppercase;
  margin-bottom: 0.125rem;
  display: block;
}

.stat-card-compact .stat-value {
  /* responsive number size */
  font-weight: 600;
  margin: 0;
  line-height: 1;
  font-size: clamp(1.25rem, 3.5vw, 1.75rem);
}

.stat-card-compact .stat-icon-bg {
  /* slightly larger icon background for better touch targets */
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 1.15rem;
}

/* Tighten the CTA button */
.stat-card-compact .card .btn {
  padding: 0.35rem 0.55rem;
  font-size: 0.85rem;
}

/* Smaller spacing for the whole block */
.stat-card-compact + .stat-card-compact {
  margin-top: 0.6rem;
}

/* On narrow screens hide supporting small text to save vertical space */
@media (max-width: 900px) {
  .stat-card-compact .stat-subtext,
  .stat-card-compact .stat-icon-label {
    display: none;
  }
  .stat-card-compact .stat-value {
    font-size: clamp(1.15rem, 4.5vw, 1.5rem);
  }
}

/* Optional: make badges / numbers wrap less often */
.stat-card-compact .stat-value,
.stat-card-compact .stat-label {
  white-space: nowrap;
}

/* Clickable card wrapper: make entire card act as a link */
.card-clickable {
  display: block;
  color: inherit;
  text-decoration: none;
}
.card-clickable .card {
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.card-clickable:hover .card {
  transform: translateY(-6px);
  box-shadow: 0 8px 20px rgba(18, 33, 68, 0.08);
}
.card-clickable:focus {
  outline: 2px solid rgba(220, 34, 34, 0.15);
  outline-offset: 2px;
}

/* TOTP UI removed */

/* Facilities Accordion Highlight */
.accordion-button:not(.collapsed) {
  background-color: #fee2e2 !important;
  color: #dc2626 !important;
}

.accordion-button:not(.collapsed)::after {
  filter: brightness(0) saturate(100%) invert(22%) sepia(93%) saturate(3034%) hue-rotate(348deg) brightness(89%) contrast(89%);
}

/* Instant Tooltip Display */
[title] {
  position: relative;
}

[title]:hover::after {
  content: attr(title);
  position: fixed;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  white-space: normal;
  max-width: 400px;
  z-index: 9999;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

/* Allow table overflow for tooltips */
.table-responsive {
  overflow: visible !important;
}

/* Dark text on yellow/warning backgrounds */
.bg-warning,
.badge.bg-warning,
.btn-warning,
.modal-header.bg-warning {
  color: #1f2937 !important;
}

.bg-warning i,
.badge.bg-warning i,
.btn-warning i,
.modal-header.bg-warning i {
  color: #1f2937 !important;
}

.btn-warning.text-white {
  color: #1f2937 !important;
}
