/*
 *= require lexxy
 */

/*
 * Securitas Monitoring Application Styles
 */

/* CSS Variables - Official Securitas Brand Colors */
:root {
  /* SEC Navy Blue - Primary brand color */
  --primary-color: #031F30;
  --primary-light: #0a3a5c;
  --primary-dark: #010d15;

  /* SEC Red - Accent/Secondary brand color */
  --sec-red: #FC273F;
  --sec-red-hover: #e01f35;

  --text-primary: #212121;
  --text-secondary: #5c6970;
  --background: #f5f7f8;
  --surface: #ffffff;
  --border-color: #dde3e6;
  --success-color: #28a745;
  --warning-color: #ffc107;
  --danger-color: #FC273F;
  --info-color: #17a2b8;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--background);
  margin: 0;
  padding: 0;
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

.hidden {
  display: none;
}

/* Navbar */
.navbar {
  background-color: var(--primary-color);
  color: white;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  border-bottom: 3px solid var(--sec-red);
}

.navbar-brand {
  font-size: 18px;
  font-weight: 600;
}

.navbar-logo {
  color: white;
  text-decoration: none;
}

.navbar-menu {
  display: flex;
  align-items: center;
  gap: 4px;
}

.navbar-item {
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.navbar-item:hover {
  background-color: rgba(255,255,255,0.1);
  color: white;
}

.navbar-item.active {
  background-color: var(--sec-red);
  color: white;
}

.navbar-dropdown {
  position: relative;
}

.dropdown-trigger {
  cursor: pointer;
}

.dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: white;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 160px;
  z-index: 1000;
}

.navbar-dropdown:hover .dropdown-content {
  display: block;
}

.dropdown-item {
  display: block;
  padding: 10px 16px;
  color: var(--text-primary);
  text-decoration: none;
}

.dropdown-item:hover {
  background-color: var(--background);
}

.navbar-end {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar-user {
  color: rgba(255,255,255,0.9);
}

/* Footer */
.footer {
  background-color: var(--primary-dark);
  color: rgba(255,255,255,0.8);
  padding: 16px 20px;
  margin-top: auto;
}

.footer-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-link {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
}

.footer-link:hover {
  color: white;
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 24px;
  margin-bottom: 20px;
}

.card-narrow {
  max-width: 500px;
  margin: 40px auto;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-primary {
  background-color: var(--sec-red);
  color: white;
}

.btn-primary:hover {
  background-color: var(--sec-red-hover);
}

.btn-secondary {
  background-color: #e0e0e0;
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: #bdbdbd;
}

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

.btn-danger:hover {
  background-color: #d32f2f;
}

.btn-link {
  background: none;
  color: rgba(255,255,255,0.9);
  padding: 8px 12px;
}

.btn-link:hover {
  color: white;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

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

.btn-outline-primary:hover {
  background-color: var(--sec-red);
  color: white;
}

.btn-group {
  display: flex;
  gap: 4px;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 4px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--sec-red);
  box-shadow: 0 0 0 2px rgba(252, 39, 63, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-check-input {
  width: 16px;
  height: 16px;
}

.form-actions {
  margin-top: 24px;
  display: flex;
  gap: 12px;
}

.form-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.table th {
  background-color: var(--background);
  font-weight: 600;
  color: var(--text-secondary);
}

.table-hover tbody tr:hover {
  background-color: rgba(3, 31, 48, 0.04);
  cursor: pointer;
}

.table tr.selected {
  background-color: rgba(252, 39, 63, 0.08) !important;
}

.table tr.inactive {
  opacity: 0.6;
}

.table-sm th,
.table-sm td {
  padding: 8px 12px;
}

/* Flash Messages */
.flash {
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: slideIn 0.3s ease;
}

.flash-notice {
  background-color: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
}

.flash-alert {
  background-color: #ffebee;
  color: #c62828;
  border: 1px solid #ef9a9a;
}

.flash-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  opacity: 0.6;
}

.flash-close:hover {
  opacity: 1;
}

.flash.fade-out {
  animation: fadeOut 0.3s ease forwards;
}

@keyframes slideIn {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 16px;
}

.alert-danger {
  background-color: #ffebee;
  color: #c62828;
  border: 1px solid #ef9a9a;
}

.alert-warning {
  background-color: #fff3e0;
  color: #e65100;
  border: 1px solid #ffcc80;
}

.alert-success {
  background-color: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
}

.alert ul {
  margin: 0;
  padding-left: 20px;
}

/* Authentication */
.auth-container {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  padding: 32px;
  width: 100%;
  max-width: 400px;
}

.auth-title {
  margin: 0 0 24px;
  text-align: center;
  color: var(--primary-color);
}

.auth-links {
  margin-top: 16px;
  text-align: center;
}

.auth-links a {
  color: var(--sec-red);
}

.auth-links a:hover {
  color: var(--sec-red-hover);
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-header h1 {
  margin: 0;
  color: var(--primary-color);
}

.page-actions {
  display: flex;
  gap: 8px;
}

/* Search Bar */
.search-bar {
  margin-bottom: 20px;
}

.search-form {
  display: flex;
  gap: 8px;
  max-width: 500px;
}

.search-form .form-control {
  flex: 1;
}

/* Content Container */
.content-container {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 24px;
}

/* Sites Layout */
.sites-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.sites-list {
  max-height: 45vh;
  overflow-y: auto;
}

.site-details2 {
  position: sticky;
  top: 20px;
}
.site-details {
  max-height: 45vh;
  overflow-y: auto;
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 16px;
}

.tab {
  padding: 12px 20px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.tab:hover {
  color: var(--sec-red);
}

.tab.active {
  color: var(--sec-red);
  border-bottom-color: var(--sec-red);
}

.tab-content {
  padding: 16px 0;
}

/* Info Grid */
.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.info-item label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.info-item span {
  font-weight: 500;
}

/* Panels */
.panel-card {
  background: var(--background);
  border-radius: 4px;
  padding: 16px;
  margin-bottom: 12px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

/* Alarms Layout */
.alarms-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.alarms-list {
  max-height: 600px;
  overflow-y: auto;
}

.alarm-details {
  position: sticky;
  top: 20px;
}

/* Filter Bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.filter-bar label {
  font-weight: 500;
  color: var(--text-secondary);
}

/* Home */
.home-container {
  padding: 20px 0;
}

.welcome-card {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 32px;
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
}

.welcome-card h1 {
  color: var(--primary-color);
  margin-bottom: 8px;
}

.welcome-card h1 span {
  color: var(--sec-red);
}

.quick-links {
  margin-top: 32px;
}

.quick-links h2 {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.link-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background: var(--background);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.2s;
}

.link-card:hover {
  background: rgba(252, 39, 63, 0.08);
  transform: translateY(-2px);
}

.link-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.link-title {
  font-weight: 500;
}

/* Feedback & Information Cards */
.feedback-card,
.information-card {
  background: var(--background);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.feedback-header,
.information-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.feedback-header h3,
.information-header h3 {
  margin: 0;
  font-size: 16px;
}

.feedback-meta,
.information-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.feedback-body,
.information-body {
  color: var(--text-primary);
}

.information-acknowledgment {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  font-size: 13px;
  color: var(--text-secondary);
}

.information-card.acknowledged {
  border-left: 3px solid var(--sec-red);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 12px;
}

.badge-success {
  background-color: #e8f5e9;
  color: #2e7d32;
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

/* Text utilities */
.text-muted {
  color: var(--text-secondary);
}

/* Home Grid Layout */
.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

/* Map Card */
.map-card {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 24px;
}

.map-card h2 {
  margin: 0 0 16px;
  font-size: 16px;
  color: var(--text-secondary);
}

#sites-map {
  height: 400px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.map-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-secondary);
  margin: 0;
}

/* Leaflet Map Marker Clusters - Securitas Branding */
.marker-cluster {
  background: var(--primary-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  border: 3px solid var(--sec-red);
}

.marker-cluster-inner {
  color: white;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
}

.marker-cluster-small {
  background: var(--primary-color);
}

.marker-cluster-medium {
  background: var(--primary-light);
}

.marker-cluster-large {
  background: var(--sec-red);
  border-color: var(--primary-color);
}

/* Map Popup Styles */
.map-popup h4 {
  margin: 0 0 10px;
  color: var(--primary-color);
  font-size: 15px;
  border-bottom: 2px solid var(--sec-red);
  padding-bottom: 6px;
}

.popup-sites {
  max-height: 150px;
  overflow-y: auto;
}

.popup-site {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}

.popup-site:last-child {
  border-bottom: none;
}

.popup-site strong {
  color: var(--sec-red);
}

.popup-site small {
  color: var(--text-secondary);
}

/* Individual site marker popup */
.popup-site-name {
  font-weight: 500;
  margin-bottom: 4px;
}

.popup-site-address {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Individual site marker */
.site-marker {
  background: transparent;
}

.site-marker-inner {
  width: 24px;
  height: 24px;
  background: var(--sec-red);
  border: 3px solid var(--primary-color);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.site-marker-inner::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--primary-color);
}

/* Override MarkerCluster default styles */
.leaflet-cluster-anim .leaflet-marker-icon,
.leaflet-cluster-anim .leaflet-marker-shadow {
  transition: transform 0.3s ease-out, opacity 0.3s ease-in;
}

/* Leaflet Popup Override */
.leaflet-popup-content-wrapper {
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.leaflet-popup-content {
  margin: 12px 14px;
}

.dropdown-item.active {
  font-weight: 600;
  color: var(--sec-red);
}

/* Lexxy rich text editor */
lexxy-editor {
  display: block;
  width: 100%;
  min-height: 160px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  background-color: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  transition: border-color 0.2s;
}

lexxy-editor:focus-within {
  border-color: var(--sec-red);
  box-shadow: 0 0 0 2px rgba(252, 39, 63, 0.15);
  outline: none;
}

lexxy-editor .lexxy-content {
  min-height: 140px;
  outline: none;
}

lexxy-editor[data-placeholder]::before {
  color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 992px) {
  .home-grid {
    grid-template-columns: 1fr;
  }

  #sites-map {
    height: 350px;
  }
}

@media (max-width: 768px) {
  .sites-layout,
  .alarms-layout {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .link-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .navbar-user-info {
    display: flex;
    flex-direction: column;
    margin-right: 1rem;
  }

  .navbar-user {
    font-weight: 600;
  }

  .navbar-last-login {
    font-size: 0.75rem;
    color: #777;
  }

  .navbar-menu {
    display: none;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  #sites-map {
    height: 300px;
  }
}
