/* === CSS Variables === */
:root {
  --primary-color: #667eea;
  --primary-color-dark: #5568d3;
  --secondary-color: #e5e7eb;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --danger-color-darker: #b91c1c;
  --warning-color: #f59e0b;
  --font-family: sans-serif;
  --font-family-old: Segoe UI, Noto Sans Hebrew, Tahoma, Geneva, Verdana, sans-serif;
  --font-family-mono: monospace;
  --link-color: #3844e6;
  --link-color-darker: #09139e;

  --link-color-gray: #6b7280;
  --link-color-gray-hover: #4b5563;

  --assigned-row-color: #ffd78f;
  --draft-row-color: #eceb98;
  --ready-row-color: #a1d9a3;

}

/* === Reset & Base Styles === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background: #f5f7fa;
}

/* === Utility Classes === */
.m1 {
  margin: 1px;
}

.mt5 {
  margin-top: 5px;
}

.mt10 {
  margin-top: 10px;
}

.mt20 {
  margin-top: 20px;
}

.mb10 {
  margin-bottom: 10px;
}

.mb20 {
  margin-bottom: 20px;
}

.mh2 {
  margin-left: 2px;
  margin-right: 2px;
}

.mh5 {
  margin-left: 5px;
  margin-right: 5px;
}

.relative {
  position: relative;
}

.sticky {
  position: sticky;
  top: 10px;
}

.flex {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.nowrap {
  white-space: nowrap;
}

.translation {
  font-size: 80%;
  opacity: 0.5;
  background: #f0f0f0;
  padding: 10px;
}

.tcenter {
  text-align: center;
}

.mini {
  font-size: 80%;
}

.right {
  float: right;
}

.graylink {
  color: #6b7280;
  cursor: pointer;
  text-decoration: none;
}

.pointer {
  cursor: pointer;
}

/* === Typography & Links === */
h1 i,
h2 i,
h3 i,
h4 i,
button i {
  margin: 0 5px;
}

h2 {
  color: #1f2937;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--secondary-color);
}

.input-autolink {
  color: var(--primary-color);
}

.input-autolink:hover {
  color: var(--primary-color-dark);
}


.graylink:hover {
  color: #4b5563;
  text-decoration: none;
}

.back-link {
  color: var(--primary-color);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 20px;
  font-size: 14px;
}

.back-link:hover {
  text-decoration: underline;
}

/* === Header === */
.header {
  background: linear-gradient(135deg, #282d41 0%, #1f1926 100%);
  color: white;
  padding: 20px 0 20px 0px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  height: 90px;
}

.header h1 {
  font-size: 24px;
  margin: 0 40px;
}

.header h1 a {
  color: white;
  text-decoration: none;
}

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

.user-info {
  font-size: 14px;
}

.navbar li {
  display: inline;
  list-style: none;
}

.navbar a {
  color: white;
  text-decoration: none;
  margin-right: 20px;
  font-size: 14px;
}

#results-rows {
  color: #666;
  font-size: 12px;
}

/* === Layout === */
.container {
  max-width: 1600px;
  margin: 30px auto;
  padding: 0 40px;
}

.grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.grid.col-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

/* === Cards === */
.card {
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  padding: 25px;
}

.card h3 {
  color: #1f2937;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--secondary-color);
}

.form-card {
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  padding: 30px;
}

.form-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--secondary-color);
  margin-bottom: 10px;
}

.form-card-header h2 {
  margin: 0;
  border-bottom: none;
}

.stat-card {
  background: white;
  border-radius: 10px;
  padding: 25px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  text-align: center;
}

.stat-card .icon {
  font-size: 36px;
  margin-bottom: 15px;
}

.stat-card .icon.blue {
  color: var(--primary-color);
}

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

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

.stat-card .value {
  font-size: 32px;
  font-weight: bold;
  color: #1f2937;
  margin-bottom: 5px;
}

.stat-card .label {
  color: #6b7280;
  font-size: 14px;
}

.chart-card {
  background: white;
  border-radius: 10px;
  padding: 25px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.chart-card h3 {
  color: #1f2937;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--secondary-color);
}

.chart-card.full {
  grid-column: 1 / -1;
}

.image-card {
  position: relative;
  border: 1px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.image-card .image-thumb {
  cursor: move;
  width: 100%;
  padding-top: 75%;
  position: relative;
  background: #f8fafc;
}

.image-card .image-thumb img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-card .image-actions {
  display: flex;
  justify-content: flex-end;
  padding: 6px;
  gap: 5px;
  background: rgba(255, 255, 255, 0.9);
}

/* === Forms === */
.new-event-form {
  max-width: 800px;
  margin: 0 auto;
}

.event-details-bottom {
  font-size: 70%;
  color: #808080;
  display: flex;
  justify-content: space-between;
  margin: 30px 0 -25px 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.form-group {
  margin-bottom: 15px;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.language-tab {padding: 8px 12px; background: none; border: none; cursor: pointer; border-bottom: 2px solid transparent;}
.language-tab.active {border-bottom: 2px solid #007bff;}

label,
.label {
  display: block;
  margin-bottom: 5px;
  color: #374151;
  font-weight: 500;
  font-size: 14px;
}

label .required,
.label .required {
  color: var(--danger-color);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.3s;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

.helper-text {
  font-size: 12px;
  color: #6b7280;
  margin-top: 5px;
  float: right;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-group input[type="checkbox"] {
  width: auto;
}

.search-box {
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 5px;
  width: 300px;
  font-size: 14px;
}

/* Event Notes */

.event-note-input {
  display: flex;
  gap: 10px;
}

.event-note-input textarea {
  min-height: 3em;
  width: calc(100% - 100px);
  font-size: 12px;
}

.event-note-item .note-header {
  display: flex;
  gap: 10px;
}

.event-note-item .note-author {
  font-weight: bold;
}

.event-note-item .note-date {
  font-size: 10px;
  opacity: 0.8;
}

.event-note-item .note-delete {
  cursor: pointer;
  display: none;
}

.event-note-item:hover .note-delete {
  display: inline-block;
}

.event-note-item .note-content {
  margin-bottom: 10px;
}


/* === File Upload === */
.upload-container {
  max-width: 800px;
  margin: 0 auto;
}

.dropzone {
  border: 2px dashed #ccc;
  border-radius: 4px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background-color: #f9f9f9;
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: #4CAF50;
  background-color: #f0f8f0;
}

.dropicon {
  font-size: 28px;
  color: #666;
  margin-bottom: 5px;
}

.upload-hint {
  font-size: 12px;
  color: #999;
  margin-top: 5px;
}

.image-preview-container,
.existing-images {
  display: grid;
  gap: 15px;
}

.image-preview-container {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.existing-images {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  margin-bottom: 10px;
}

.empty-gallery {
  padding: 15px;
  border: 1px dashed #d1d5db;
  border-radius: 6px;
  color: #6b7280;
}

.preview-item {
  position: relative;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
}

.preview-item img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}

.preview-item .remove-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(255, 0, 0, 0.8);
  color: white;
  border: none;
  border-radius: 50%;
  width: 25px;
  height: 25px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

.preview-item .file-name {
  padding: 5px;
  font-size: 11px;
  text-align: center;
  background: #f5f5f5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-progress {
  margin-top: 20px;
}

.progress-bar {
  width: 100%;
  height: 25px;
  background-color: #f0f0f0;
  border-radius: 12px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: #4CAF50;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  text-align: center;
  margin-top: 8px;
  font-size: 14px;
  color: #666;
}

.upload-results {
  padding: 10px;
  border-radius: 4px;
}

.result-item {
  padding: 8px;
  margin-bottom: 5px;
  border-radius: 3px;
}

.result-success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.result-error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* === Image Galleries === */
#image-preview {
  text-align: center;
  height: 100vw;
  z-index: 10;
}

#image-preview .modal-content {
  padding: 20px;
  margin: 10px auto;
  height: calc(100vh - 20px);
}

#image-preview-src {
  max-height: 100%;
  max-width: 100%;
  height: 100%;
}

.manage-edit-box {
  max-height: 100vh;
}

.settler-profile-div {
  flex-basis: 0;
  flex: 1 1 0px;
}

.settler-profile-div .base {
  margin-bottom: 20px;
}

.square-image-container {
  width: 70px;
  height: 70px;
  padding: 0 !important;
  position: relative;
  overflow: hidden;
  transition: 0.2s ease;
}

.square-image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 5px;
  cursor: pointer;
}

.square-image-container:hover {
  transform: scale(1.05);
}

/* Loading spinner for encrypted settler images */
.square-image-container img[data-encrypted-item]:not(.encrypted-ready) {
  opacity: 0.3;
  filter: grayscale(1);
}
.square-image-container img[data-encrypted-item]:not(.encrypted-ready) + .enc-loading-spinner,
.square-image-container:has(img[data-encrypted-item]:not(.encrypted-ready))::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #0ea5e9;
  border-radius: 50%;
  animation: enc-spin 0.7s linear infinite;
  pointer-events: none;
}
.square-image-container:has(img.encrypted-ready)::after {
  display: none;
}
@keyframes enc-spin {
  to { transform: rotate(360deg); }
}

.settler-pictures {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  padding: 10px;
  direction: ltr;
  background: #222;
}

.settler-pictures img {
  flex: 0 1 150px;
  max-width: 100%;
  height: auto;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.settler-picture:hover {
  transform: scale(1.05);
}

.splide.main {
  width: 100%;
}

.splide__slide {
  opacity: 0.6;
}

.splide__slide.is-active {
  opacity: 1;
}


.main .splide__slide {
  border-radius: 6px;
  text-align: center;
  background: #151515;
  position: relative;
}

/* Loading spinner for encrypted images in splide carousel */
.splide__slide:has(img[data-encrypted-item]:not(.encrypted-ready))::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: #0ea5e9;
  border-radius: 50%;
  animation: enc-spin 0.7s linear infinite;
  pointer-events: none;
  z-index: 1;
}
.splide__slide:has(img.encrypted-ready)::after {
  display: none;
}

.splide__slide img[data-encrypted-item]:not(.encrypted-ready) {
  opacity: 0.15;
}

.main .splide__slide img {
  width: auto;
  max-height: 50vh;
  height: 100%;
}

.thumbnail .splide__slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.settler-details a {
  color: var(--link-color);
}

.settler-details a:hover {
  color: var(--link-color-darker)
}

.settler-details .presentation-page-link {
  margin-top: 20px;
}

.leaflet-control-layers-toggle {
  transform: scale(0.95);
  width: 30px !important;
  height: 30px !important;
}

/* === Buttons === */
.btn {
  padding: 12px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  display: inline-block;
  transition: all 0.3s;
  white-space: nowrap;
}

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

.btn-xs {
  padding: 4px 8px;
  font-size: 11px;
}

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

.btn-white:hover {
  background: #f3f4f6;
}

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

.btn-primary.active,
.btn-primary:hover {
  background: var(--primary-color-dark);
}

.btn-danger.active,
.btn-danger:hover {
  background: var(--danger-color-darker);
}

.btn-secondary {
  background: var(--secondary-color);
  color: #374151;
}

.btn-secondary:hover {
  background: #d1d5db;
}

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

.btn-success:hover {
  background: #059669;
}

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

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

.btn-group {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--secondary-color);
}

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

.badge-info {
  background: #dbeafe;
  color: #1e40af;
  border: 2px solid #beceff;
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-admin {
  background: #dbeafe;
  color: #1e40af;
}


.associated-settlers {
  margin: 10px 0;
}

.badge-settler {
  background: #e9dad2;
  margin: 1px;
  border: 2px solid #c29999;
}

.badge-settler i {
  visibility: hidden;
  color: #666;
}

.badge-settler:hover i {
  visibility: visible;
}

.badge-settler img {
  transition: 0.2s;
  margin: 0 3px;
}

.badge-settler img:hover {
  height: 150px !important;
}


.place-tag,
.type-tag {
  white-space: nowrap;
  display: inline-block;
}

/* === Alerts === */
.alert {
  padding: 15px;
  border-radius: 5px;
  margin-bottom: 20px;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  border-left: 4px solid var(--success-color);
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border-left: 4px solid var(--danger-color);
}

.alert-warning {
  background: #fef3c7;
  color: #92400e;
  border-left: 4px solid #d97706;
}

/* Event-form header link that jumps to the files gallery below */
.event-files-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  color: #3730a3;
  font-size: 13px;
  text-decoration: none;
  margin-inline-end: 8px;
}
.event-files-link:hover { background: #e0e7ff; }
.event-files-link .event-files-count {
  background: #3730a3;
  color: white;
  border-radius: 999px;
  padding: 1px 8px;
  font-weight: 600;
  font-size: 11px;
}

/* === Files gallery (settler / event attached files) === */
.files-gallery { margin: 10px 0; }
.files-gallery-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 8px;
}
.files-gallery-count { font-weight: 500; }
.files-gallery-mode-toggle { display: inline-flex; gap: 2px; }
.files-gallery-mode-toggle .fg-mode {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 4px 8px;
  cursor: pointer;
  color: #6b7280;
  border-radius: 4px;
}
.files-gallery-mode-toggle .fg-mode[aria-pressed="true"] {
  background: #2a9d8f;
  color: white;
  border-color: #2a9d8f;
}
.files-gallery-empty {
  padding: 14px;
  text-align: center;
  color: #9ca3af;
  background: #f9fafb;
  border-radius: 4px;
}

/* Grid mode */
.files-gallery-body--grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}
.files-gallery-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 110px;
  padding: 6px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
}
.files-gallery-tile:hover { background: #f3f4f6; border-color: #d1d5db; }
.files-gallery-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}
.files-gallery-tile-icon { font-size: 28px; color: #6b7280; }
.files-gallery-tile-name {
  font-size: 11px;
  color: #6b7280;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

/* List (dir-style) mode */
.files-gallery-body--list { display: flex; flex-direction: column; }
.files-gallery-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: white;
  border: none;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  text-align: start;
  font-size: 14px;
  color: #1f2937;
}
.files-gallery-row:hover { background: #f9fafb; }
.files-gallery-row-icon { color: #6b7280; }
.files-gallery-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-gallery-row-size { color: #9ca3af; font-size: 12px; }

/* Lightbox */
.files-gallery-lightbox {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 10000;
  align-items: center;
  justify-content: center;
}
.files-gallery-lightbox.open { display: flex; }
.files-gallery-lightbox .fg-lb-content {
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.files-gallery-lightbox .fg-lb-image {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
}
.files-gallery-lightbox .fg-lb-icon { font-size: 64px; color: #e5e7eb; }
.files-gallery-lightbox .fg-lb-caption {
  position: absolute;
  bottom: 16px;
  color: white;
  font-size: 13px;
  opacity: 0.9;
}
.files-gallery-lightbox .fg-lb-close,
.files-gallery-lightbox .fg-lb-prev,
.files-gallery-lightbox .fg-lb-next {
  position: absolute;
  background: none;
  border: none;
  color: white;
  font-size: 36px;
  cursor: pointer;
  padding: 8px 16px;
  opacity: 0.7;
}
.files-gallery-lightbox .fg-lb-close:hover,
.files-gallery-lightbox .fg-lb-prev:hover,
.files-gallery-lightbox .fg-lb-next:hover { opacity: 1; }
.files-gallery-lightbox .fg-lb-close { top: 10px; right: 16px; font-size: 28px; }
.files-gallery-lightbox .fg-lb-prev  { left: 16px; top: 50%; transform: translateY(-50%); }
.files-gallery-lightbox .fg-lb-next  { right: 16px; top: 50%; transform: translateY(-50%); }

.error {
  background: #fee;
  color: #c33;
  padding: 10px;
  border-radius: 5px;
  margin-bottom: 20px;
  font-size: 14px;
}

/* === Tooltips === */
.tooltip {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.tooltip>div {
  visibility: hidden;
  width: 350px;
  background-color: #555;
  color: #fff;
  border-radius: 6px;
  padding: 10px;
  position: absolute;
  z-index: 2;
  top: 125%;
  left: 50%;
  margin-left: -165px;
  opacity: 0;
  transition: opacity 0.4s;
  text-align: start;
}

.tooltip>div::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: transparent transparent #555 transparent;
}

.tooltip:hover>div {
  visibility: visible;
  opacity: 1;
}


/* === Full description === */

.full-description .tooltip.d {
  cursor: initial;
  width: 500px;
}

.full-description .tooltip.d>i {
  display: none;
}

.full-description .tooltip.d>div {
  all: unset;
  display: inline-block;
}

.full-description .tooltip.d>div::after {
  all: unset;
}

/* === Modals === */
.modal {
  display: none;
  position: fixed;
  z-index: 3;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
  background-color: #fefefe;
  margin: 100px auto;
  padding: 20px;
  width: 80%;
  box-shadow: 0 0px 2px #fff;
  border-radius: 10px;
}

.modal-close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
}

.modal-close:hover,
.modal-close:focus {
  color: black;
  text-decoration: none;
  cursor: pointer;
}

/* === Tables === */

#dashboard-events-table {
  max-height: 80vh;
  min-height: 400px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

#eventsTableBody {
  width: 100%;
  position: relative;
  /* Fixed layout: column widths come from <colgroup>, not from row content,
     so columns don't shift when Clusterize swaps rows or queries change. */
  table-layout: fixed;
}

#eventsTableBody thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

/* Pinned column widths (paired with the <colgroup> in generate_events_table_header()).
   Title gets the remaining space; everything else has an explicit width. */
#eventsTableBody .col-expand    { width: 36px; }
#eventsTableBody .col-serial    { width: 90px; }
#eventsTableBody .col-date      { width: 100px; }
#eventsTableBody .col-title     { width: auto; }
#eventsTableBody .col-place     { width: 140px; }
#eventsTableBody .col-type      { width: auto; }
#eventsTableBody .col-settlers  { width: 70px; }
#eventsTableBody .col-details   { width: 60px; }
#eventsTableBody .col-source    { width: 110px; }
#eventsTableBody .col-documents { width: 60px; }
#eventsTableBody .col-videos    { width: 60px; }
#eventsTableBody .col-files     { width: 60px; }
#eventsTableBody .col-actions   { width: 80px; }

/* Prevent long text in any cell from overflowing into the next column.
   Title and place wrap to multiple lines; the rest stay on one line with ellipsis. */
#eventsTableBody tbody td {
  overflow: hidden;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.table-container {
  background: white;
  border-radius: 0px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  overflow: visible;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: #f9fafb;
}



#eventsTableHeader th.sort-asc::after {
  content: " ▲";
  font-size: 0.7em;
  color: #333;
}

#eventsTableHeader th.sort-desc::after {
  content: " ▼";
  font-size: 0.7em;
  color: #333;
}

th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: #374151;
  border-bottom: 2px solid var(--secondary-color);
  font-size: 13px;
}

table[data-sortable] th {
  white-space: nowrap;
}

table[data-sortable] th::after {
  float: none !important;
}

td {
  padding: 2px;
  border-bottom: 1px solid #f3f4f6;
  color: #6b7280;
  font-size: 12px;
}

tr:hover {
  background: #f9fafb;
}

[dir=rtl] th,
[dir=rtl] td {
  text-align: right;
}

table[data-sortable] th,
table[data-sortable] td {
  text-align: initial !important;
}

/* === Tabs & Navigation === */
.tab-nav,
.nav-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--secondary-color);
}

.nav-tabs {
  padding-bottom: 10px;
  margin-bottom: 30px;
}

.tab-btn,
.nav-tab {
  padding: 10px 20px;
  background: white;
  border: 1px solid var(--secondary-color);
  border-radius: 5px 5px 0 0;
  cursor: pointer;
  text-decoration: none;
  color: #6b7280;
  transition: all 0.3s;
  font-size: 14px;
}

.tab-btn:hover,
.nav-tab:hover {
  background: #f9fafb;
}

.tab-btn.active,
.nav-tab.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.stats-events-btns {
  position: absolute;
  right: 40px;
  margin-top: -10px;
}

[dir=rtl] .stats-events-btns {
  right: auto;
  left: 40px;
}


.language-selector-btns {
  height: 90%;
}

.language-selector-btns button {
  background: #cac57d;
  color: #000;
  display: block;
  width: 70px;
  height: 30px;
  border: 1px solid #000;
  cursor: pointer;
}

.language-selector-btns button.he,
.language-selector-btns button.ar {
  font-size: 14pt;
}

.language-selector-btns button:hover {
  background: #4c491c;
  color: #fff;
}

.language-selector-btns button.active {
  background: #4c491c;
  color: #fff;
}

/* === Lists & Filters === */
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.list-header h3 {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
  flex: 0 0 auto;
}

.filter-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  justify-content: flex-end;
}

.filter-input-group {
  display: flex;
  align-items: center;
  gap: 0px;
  width: 300px;
}

@media screen and (max-width: 600px) {
  .filter-input-group {
    width: 100%;
  }
}

.filter-input-group .btn {
  border-radius: 0 5px 5px 0;
}

.filter-input-group input {
  border-radius: 5px 0 0 5px;
}

[dir="rtl"] .filter-input-group input {
  border-radius: 0 5px 5px 0;
}

[dir="rtl"] .filter-input-group .btn {
  border-radius: 5px 0 0 5px;
}

.filter-input-wrapper {
  position: relative;
  flex: 1 1 240px;
}

.filter-input {
  height: 36px;
  padding: 0 38px 0 12px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 13px;
  min-width: 220px;
  width: 100%;
}

.filter-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.filter-submit {
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
}

.filter-reset {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  color: #9ca3af;
  text-decoration: none;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.filter-reset:hover {
  color: var(--danger-color);
}

.filter-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 15px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #eef2ff;
  color: #4338ca;
  border-radius: 999px;
  font-size: 12px;
}

.filter-chip strong {
  font-weight: 600;
}

/* === Content Header === */
.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.content-header h2 {
  color: #1f2937;
}

/* === Stats & Charts Grid === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

#map-tab-canvas {
  height: 800px;
  border-radius: 5px;
}

/* Filter card */
.chart-card {
  margin-top: 20px;
}

/* Filters grid */
.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 15px;
}

/* Filter field */
.filter-field label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
}

/* Inputs and selects */
.filter-control {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

/* Actions row */
.filters-actions {
  display: flex;
  gap: 10px;
}

/* Buttons */
.filters-actions .btn {
  padding: 10px 20px;
}

/* Loading indicator */
.filter-loading {
  display: none;
  align-items: center;
  margin-left: 10px;
}

.filter-loading span {
  margin-left: 8px;
}

/* === Login === */
.login-container {
  background: white;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  margin: 50px auto;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #9ca3af;
}

.empty-state>i {
  font-size: 48px;
  margin-bottom: 20px;
}

/* === Actions === */
.actions {
  display: flex;
  gap: 8px;
  justify-content: end;
}

.btn-events-number {
  width: 5em;
}

/* === Third-party Plugin Overrides === */

/* Select2 */

.select2-container--default .select2-selection--multiple {
  border: 1px solid #d1d5db;
  border-radius: 5px;
  min-height: 40px;
  padding: 4px;
}

.select2-container--default.select2-container--focus .select2-selection--multiple {
  border-color: var(--primary-color);
}

.select2-selection__choice {
  font-size: 14px;
}

.select2-selection__choice .select_2-option .img {
  height: 15px;
  margin: 0 3px -2px 3px;
  transition: 0.2s;
}

.select2-selection__choice .select_2-option .img:hover {
  height: 100px;
}

.select2-results .select_2-option img {
  width: 30px;
  transition: 0.2s;
  margin: 0 3px;
}

.select2-results .base {
  float: inline-end;
  white-space: nowrap;
  margin: 0 40px 0 0;
}

.select2-results .select_2-option img:hover {
  width: 150px;
}

/* TinyMCE */
.tox .tox-tbtn {
  min-height: 24px;
  height: 24px;
  padding: 0 6px;
}

.tox .tox-toolbar,
.tox .tox-toolbar__primary {
  min-height: 28px;
}

/* Import */

.subtitle {
  color: #666;
  margin-bottom: 30px;
  font-size: 14px;
}


.upload-section {
  border: 2px dashed #ddd;
  border-radius: 10px;
  padding: 40px;
  text-align: center;
  margin-bottom: 30px;
  background: #fafafa;
}

.upload-section:hover {
  border-color: var(--primary-color);
  background: #f5f5ff;
}

input[type="file"] {
  display: none;
}

.file-label {
  display: inline-block;
  padding: 12px 30px;
  background: var(--primary-color);
  color: white;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.3s;
}

.file-label:hover {
  background: var(--primary-color-dark)
}

.column-info {
  margin-bottom: 30px;
}

.column-info h3 {
  color: #333;
  margin-bottom: 15px;
}

.data-preview {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 5px;
}

.instructions {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 5px;
  margin-bottom: 30px;
}

.instructions h3 {
  color: #333;
  margin-bottom: 10px;
}

.instructions ul {
  margin-left: 20px;
  color: #666;
}

.instructions li {
  margin-bottom: 5px;
}

.file-name {
  margin-top: 10px;
  color: #666;
  font-size: 14px;
}

.results-section {
  margin-top: 30px;
}

.results-section h2 {
  color: #333;
  margin-bottom: 20px;
  font-size: 24px;
}

.to-check-table {
  margin-bottom: 30px;
}

.unknown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.unknown-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 15px;
  font-size: 14px;
  background: #f9f9f9;
  position: relative;
}

.card-select-checkbox {
  position: absolute;
  top: 20px;
  right: 20px;
}

.unknown-settler-checkbox {
  cursor: pointer;
}

.unknown-card:has(.unknown-settler-checkbox:checked) {
  border: 2px solid var(--primary-color);
  background: rgb(228, 237, 255);
}

.unknown-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 5px;
  margin-bottom: 10px;
}

.unknown-no-image {
  width: 100%;
  height: 200px;
  background: #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  margin-bottom: 10px;
  flex-direction: column;
}

.unknown-no-image i {
  font-size: 48px;
  display: block;
  color: #9ca3af;

}

.unknown-no-image div {
  margin-top: 20px;
  color: #9ca3af;
}

.unknown-card .settler-id {
  font-weight: bold;
  color: var(--primary-color);
  margin-bottom: 5px;
}

.unknown-card .base {
  color: #666;
  margin-bottom: 5px;
}

.unknown-card .presentation {
  color: #888;
  font-size: 12px;
  font-style: italic;
}

/* RESOLVER */
.ambiguous-resolver-block {
  border: 1px solid #333;
  margin: 5px 0;
  max-height: 800px;
  transition: 0.3s ease-out;
}

.ambiguous-event {
  background: #ddd;
  border-bottom: 1px solid #ddd;
  padding: 5px;
  font-weight: bold;
  font-size: 90%;
}

.ambiguous-choices {
  background: #f0f0f0;
  padding: 5px;
}

.ambiguous-choices-table .selected {
  background: #dbe1ff;
}

input[type=radio] {
  cursor: pointer;
}

@media screen and (max-width: 600px) {
  .header h1 {
    margin: 0 10px;
  }

  .container {
    margin: 10px auto;
    padding: 0 8px;
  }

  .content-header {
    display: block;
  }

  .charts-grid {
    display: block;
  }

  #dashboard-events-table {
    overflow-x: initial;
  }

  /* Nascondi header */
  .events-table thead {
    display: none;
  }

  /* Ogni riga diventa un riquadro */
  .events-table tbody tr {
    display: block;
    margin: 0 12px 16px;
    padding: 12px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.04);
    box-sizing: border-box;
  }

  /* Ogni cella diventa un blocco */
  .events-table tbody tr td {
    display: block;
    width: 100%;
    padding: 6px 0;
    border: none;
    box-sizing: border-box;
    word-break: break-word;
  }

  /* Miglior leggibilità per contenuti lunghi */
  .events-table tbody tr td:nth-child(4),
  /* titolo */
  .events-table tbody tr td:nth-child(6) {
    /* types */
    padding-top: 10px;
    padding-bottom: 10px;
  }

  /* Celle di icone: allineate a destra */
  .events-table tbody tr td:nth-child(7),
  .events-table tbody tr td:nth-child(10),
  .events-table tbody tr td:nth-child(11),
  .events-table tbody tr td:nth-child(12),
  .events-table tbody tr td:nth-child(13) {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
  }

  /* Rendi le icone tappabili */
  .events-table tbody tr td:nth-child(13) button,
  .events-table tbody tr td:nth-child(13) a {
    min-height: 36px;
    min-width: 36px;
    padding: 6px 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
  }

  /* Evita overflow di immagini */
  .events-table tbody tr td img {
    max-width: 100%;
    height: auto;
    display: inline-block;
  }

}


/* === Expandable Rows === */
.expand-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: #666;
  padding: 4px 8px;
  transition: transform 0.2s, color 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

[dir=rtl] .expand-btn {
  transform: rotate(180deg);
}

.expand-btn:hover {
  color: #000000;
}

.expand-btn.expanded {
  transform: rotate(90deg);
  color: #000000;
}

.detail-row {
  border-bottom: 1px solid #e9ecef;
  background-color: #f8f9fa;
  height: auto;
  overflow: hidden;
  transition: 0.2s;
}

.detail-row td {
  padding: 0;
}

.detail-row.collapsed {
  visibility: collapse;
  line-height: 0 !important;
  height: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

.detail-row.collapsed * {
  display: none;
}

.expanded-row {
  padding: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  box-sizing: border-box;
}

.detail-section {
  margin-bottom: 15px;
}

.detail-label {
  font-weight: 600;
  color: #555;
  margin-bottom: 5px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-content {
  color: #333;
  line-height: 1.6;
  padding: 10px;
  background: white;
  border-radius: 4px;
  border-left: 3px solid #4CAF50;
}

.expanded-row .details-column {
  padding: 0 15px;
  flex: 1 1 0;
  min-width: 0;
  box-sizing: border-box;
}

.expanded-row .details {
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  padding: 15px;
}

.expanded-row .no-details {
  text-align: center;
  font-size: 14pt;
  color: #999;
  padding: 15px;
}

.expanded-row .checks {
  flex: 1 1 0;
  min-width: 0;
  box-sizing: border-box;
}

@media screen and (max-width: 800px) {

  .expanded-row .details,
  .expanded-row .checks {
    display: block;
    width: 100%;
    margin: 0;
  }
}

/* === User assignment === */
/* User Selection Section */
.main-row.expanded {
  background: #dce6fa;
}

.main-row.assigned-row {
  background: var(--assigned-row-color);
}

.main-row.draft-row {
  background: var(--draft-row-color);
}

.main-row.ready-row {
  background: var(--ready-row-color);
}

.user-selection {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 400px;
}

.user-selection label {
  font-weight: 600;
  color: #2c3e50;
  min-width: 120px;
}

.userselect2-container {
  flex: 1;
  max-width: 400px;
}

.select2-results__option {
  font-size: 12px;
}

/* User Badges */
.users-assigned {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 15px;
}

.users-assigned h4 {
  width: 100%;
  color: #2c3e50;
  margin-bottom: 5px;
  font-size: 14px;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 1px 6px;
  background: white;
  border: 2px solid #ddd;
  border-radius: 10px;
  font-size: 14px;
  transition: all 0.3s;
}

.user-badge.checked {
  border-color: #27ae60;
  background: #e8f8f0;
}

.user-badge-name {
  font-weight: 500;
  font-size: 9pt;
}

.user-badge-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  margin: 0;
}

.user-badge-remove {
  color: #666;
  background: transparent;
  border: none;
  border-radius: 50%;
  width: 10px;
  height: 20px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: background 0.3s;
  padding: 0;
}

.user-badge-remove:hover {
  color: #000;
}

.no-users {
  color: #95a5a6;
  font-style: italic;
  font-size: 14px;
}

/* Loading State */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Status badge */
.status-badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.status-active {
  background: #d4edda;
  color: #155724;
}

.status-pending {
  background: #fff3cd;
  color: #856404;
}

/* === File Management System === */

/* Tab Interface */
.file-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--secondary-color);
  margin-bottom: 5px;
}

.file-tab {
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #6b7280;
  transition: all 0.3s;
}

.file-tab:hover {
  color: var(--primary-color);
  background: #f9fafb;
}

.file-tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  background: #f9fafb;
}

.file-tab-content {
  display: none;
}

.file-tab-content.active {
  display: block;
}

/* File Upload Dropzone */
.file-dropzone {
  border: 2px dashed #d1d5db;
  border-radius: 8px;
  padding: 10px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #f9fafb;
  margin-bottom: 20px;
}

.file-dropzone:hover {
  border-color: var(--primary-color);
  background: #f0f4ff;
}

.file-dropzone.drag-over {
  border-color: var(--success-color);
  background: #f0fdf4;
  border-style: solid;
}

.file-dropzone > i {
  font-size: 48px;
  color: #9ca3af;
  margin-bottom: 10px;
  display: block;
  position: absolute;
}

.file-dropzone.drag-over i {
  color: var(--success-color);
}

.file-dropzone p {
  margin: 5px 0;
  color: #6b7280;
}

.file-dropzone .upload-hint {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 10px;
}

.folder-upload-btn {
  margin-top: 8px;
  padding: 6px 14px;
  background: #374151;
  color: #e5e7eb;
  border: 1px solid #4b5563;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}

.folder-upload-btn:hover {
  background: #4b5563;
}

.folder-upload-btn i {
  font-size: 13px;
  color: #e5e7eb;
  margin-inline-end: 4px;
}

/* File List */
.file-list {
  margin-top: 20px;
}

.file-list-empty {
  padding: 20px;
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
  border: 1px dashed #e5e7eb;
  border-radius: 6px;
  background: #f9fafb;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  margin-bottom: 10px;
  background: white;
  transition: all 0.2s;
}

.file-item:hover {
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.file-item-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-item-icon {
  font-size: 24px;
  color: var(--danger-color);
}

.file-item-details {
  flex: 1;
}

.file-item-name {
  font-weight: 500;
  color: #1f2937;
  margin-bottom: 3px;
  word-break: break-word;
}

.file-item-date,
.file-item-size {
  font-size: 12px;
  color: #6b7280;
}

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

.file-item-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.file-item-btn.view {
  background: var(--primary-color);
  color: white;
}

.file-item-btn.view:hover {
  background: var(--primary-color-dark);
}

.file-item-btn.download {
  background: var(--primary-color);
  color: white;
}

.file-item-btn.download:hover {
  background: var(--primary-color-dark);
}

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

.file-item-btn.delete:hover {
  background: var(--danger-color-darker);
}

/* External Link Input */
.external-link-container {
  display: flex;
  gap: 10px;
  align-items: center;
}

.external-link-container input {
  flex: 1;
}

.external-link-icon {
  color: var(--primary-color);
  font-size: 20px;
  cursor: pointer;
  transition: color 0.2s;
}

.external-link-icon:hover {
  color: var(--primary-color-dark);
}

/* File Viewer Modal */
#file-viewer-modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
}

#file-viewer-modal .modal-content {
  margin: 10px auto;
  height: calc(100vh - 40px);
}

.file-viewer-content {
  position: relative;
  width: 100%;
  height: 90%;
  max-width: 1200px;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.file-viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: #1f2937;
  color: white;
}

.file-viewer-title {
  font-size: 16px;
  font-weight: 500;
  margin: 0;
}

.file-viewer-iframe {
  width: 100%;
  height: 100%;
  border: none;
  min-height: 600px;
}

.encrypted-files-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.encrypted-files-header {
  align-items: end;
}

.encrypted-files-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.encrypted-files-filters input,
.encrypted-files-filters select {
  min-width: 180px;
}

.encrypted-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.encrypted-items-empty {
  min-height: 180px;
  background: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #6b7280;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.encrypted-item-card {
  background: white;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.18);
  display: flex;
  flex-direction: column;
}

.encrypted-item-preview {
  position: relative;
  min-height: 180px;
  background: linear-gradient(135deg, #111827, #334155);
  overflow: hidden;
}

.encrypted-item-preview-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  filter: blur(14px) grayscale(0.5) brightness(0.72);
  transform: scale(1.05);
  transition: filter 0.7s ease, transform 0.7s ease, opacity 0.5s ease;
  opacity: 0;
}

.encrypted-item-preview.decrypted .encrypted-item-preview-img,
.encrypted-item-preview-img.thumb-ready {
  opacity: 1;
  filter: blur(0px) grayscale(0);
  transform: scale(1);
}

.encrypted-item-preview {
  cursor: pointer;
}

.encrypted-item-preview-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 24px;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.encrypted-item-preview.decrypted .encrypted-item-preview-overlay {
  opacity: 0;
}

.encrypted-item-meta {
  padding: 14px 16px 8px;
}

.encrypted-item-meta h3 {
  font-size: 15px;
  line-height: 1.4;
  margin-bottom: 8px;
  color: #111827;
}

.encrypted-item-meta p {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 4px;
}

.encrypted-item-actions {
  display: flex;
  gap: 10px;
  padding: 0 16px 12px;
  justify-content: flex-end;
}

.encrypted-viewer {
  width: 100%;
  height: 100%;
  min-height: 640px;
  background: #0f172a;
  color: white;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.encrypted-viewer-spinner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
  color: #e2e8f0;
  font-size: 15px;
}

.encrypted-viewer-image {
  background: #020617;
}

.encrypted-viewer-thumb,
.encrypted-viewer-full {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.encrypted-viewer-thumb {
  filter: blur(16px) saturate(0.75);
  transform: scale(1.03);
}

.encrypted-viewer-full {
  opacity: 0;
  transition: opacity 0.6s ease;
}

.encrypted-viewer.decrypted .encrypted-viewer-full {
  opacity: 1;
}

.encrypted-viewer-document,
.encrypted-viewer-video {
  padding: 12px;
  align-items: stretch;
}

.encrypted-video-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 8px;
  margin-bottom: 10px;
}

.encrypted-video-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.encrypted-video-jump label {
  color: #cbd5e1;
  font-size: 12px;
}

.encrypted-video-jump-input {
  width: 70px;
  padding: 4px 8px;
  font-size: 13px;
  border-radius: 4px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #f9fafb;
}

.encrypted-video-player-wrap {
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}

.encrypted-video-prefetch-bar {
  position: relative;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  overflow: hidden;
}

.encrypted-video-prefetch-buffered {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  background: rgba(148, 163, 184, 0.45);
  pointer-events: none;
  transition: width 0.2s ease;
}

.encrypted-video-prefetch-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  background: #38bdf8;
  pointer-events: none;
  transition: width 0.1s linear;
}

.encrypted-video-prefetch-hover {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 2px;
  background: #f9fafb;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  transform: translateX(-1px);
}

.encrypted-video-player {
  display: block;
  width: 100%;
  max-height: 70vh;
  background: #000;
}

/* ─── pdf.js viewer ──────────────────────────────── */
.pdfjs-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.pdfjs-toolbar .btn-sm {
  padding: 4px 10px;
  font-size: 13px;
  min-width: auto;
}

.pdfjs-page-info {
  font-size: 13px;
  color: #cbd5e1;
  white-space: nowrap;
}

.pdfjs-zoom-level {
  font-size: 13px;
  color: #94a3b8;
  min-width: 42px;
  text-align: center;
}

.pdfjs-canvas-container {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  background: #1e293b;
  border-radius: 8px;
  padding: 12px;
}

.pdfjs-canvas-container canvas {
  max-width: 100%;
  height: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* ─── Text file viewer ───────────────────────────── */
.encrypted-viewer-text-content {
  flex: 1;
  overflow: auto;
  margin: 0;
  padding: 16px 20px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  tab-size: 4;
}

.encrypted-viewer-generic {
  background: linear-gradient(135deg, #111827, #1e293b);
}

.encrypted-viewer-generic-card {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 16px;
  padding: 28px;
  text-align: center;
  min-width: 320px;
}

.encrypted-viewer-generic-card i {
  font-size: 46px;
  margin-bottom: 16px;
}

.encrypted-video-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 12px;
}

.encrypted-video-player-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
}

.encrypted-video-player {
  width: 100%;
  max-height: calc(100vh - 170px);
  background: #000;
}

.encrypted-file-item {
  border-left: 4px solid #0ea5e9;
}

/* Encrypted file link icons in event table */
.encrypted-file-link,
.encrypted-dir-link {
  cursor: pointer;
  position: relative;
}

.badge-count {
  font-size: 10px;
  font-weight: 600;
  background: #0ea5e9;
  color: white;
  border-radius: 8px;
  padding: 1px 5px;
  vertical-align: super;
}

/* Directory grid inside the file viewer modal */
.modal-directory-grid {
  padding: 16px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}

/* ─── Gallery viewer (prev/next + thumbnail strip) ─── */

.gallery-main {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, opacity 0.2s;
  opacity: 0.7;
}
.gallery-nav:hover {
  background: rgba(0, 0, 0, 0.8);
  opacity: 1;
}
.gallery-nav:disabled {
  opacity: 0.2;
  cursor: default;
}
.gallery-nav-prev { left: 12px; }
.gallery-nav-next { right: 12px; }

.gallery-thumb-strip {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  background: #0f172a;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.gallery-thumb {
  width: 56px;
  height: 56px;
  min-width: 56px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, transform 0.2s;
}
.gallery-thumb:hover {
  border-color: rgba(255,255,255,0.4);
  transform: scale(1.05);
}
.gallery-thumb.active {
  border-color: #0ea5e9;
  transform: scale(1.1);
}

.gallery-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-thumb-icon {
  font-size: 20px;
  color: #94a3b8;
}

/* Upload Progress */
.upload-progress {
  margin-top: 15px;
  padding: 15px;
  background: #f9fafb;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

.upload-progress-bar {
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.upload-progress-fill {
  height: 100%;
  background: var(--success-color);
  transition: width 0.3s ease;
}

.upload-progress-text {
  font-size: 13px;
  color: #6b7280;
  text-align: center;
}


/* Polygon / Marker Toggle Switch */
.switch-checkbox {
  display: none;
}

.switch-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  width: 65px;
  height: 30px;
  background: #fff;
  border-radius: 50px;
  position: relative;
  transition: background 0.3s;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
  border: 1px solid #ccc;
  padding: 0 5px;
}

.switch-label .fa-map-marker-alt {
  color: #ccc;
  font-size: 18px;
  z-index: 1;
  transition: color 0.3s;
}

.switch-label .fa-draw-polygon {
  color: #ccc;
  font-size: 18px;
  z-index: 1;
  transition: color 0.3s;
}

.switch-checkbox:not(:checked)+.switch-label .fa-map-marker-alt {
  color: #337ab7;
}

.switch-checkbox:checked+.switch-label .fa-draw-polygon {
  color: #d9534f;
}

.switch-button {
  content: '';
  position: absolute;
  top: 2px;
  left: 0px;
  width: 30px;
  height: 25px;
  border-radius: 50% 0 0 50%;
  transition: 0.3s;
  background: transparent;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  z-index: 2;
}

.switch-checkbox:checked+.switch-label .switch-button {
  left: calc(100% - 0px);
  border-radius: 0 50% 50% 0;
  transform: translateX(-100%);
}
/* Custom Map Controls */
.custom-map-control {
    background: white;
    padding: 5px;
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    cursor: pointer;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    font-size: 14px;
    color: #333;
    transition: background-color 0.2s, color 0.2s;
}

.custom-map-control:hover {
    background-color: #f4f4f4;
}

.custom-map-control.active {
    background-color: #3388ff;
    color: white;
}

/* === Pagination === */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin: 16px 0 8px;
    justify-content: center;
}
.pagination .pagination-summary {
    margin-right: auto;
    font-size: 0.9em;
    color: #666;
}
.pagination .page-link {
    display: inline-block;
    min-width: 32px;
    padding: 6px 10px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #333;
    text-decoration: none;
    background: #fff;
}
.pagination .page-link:hover:not(.disabled):not(.active) {
    background: #f5f5f5;
}
.pagination .page-link.active {
    background: var(--primary-color, #3388ff);
    color: #fff;
    border-color: var(--primary-color, #3388ff);
}
.pagination .page-link.disabled {
    color: #bbb;
    background: #fafafa;
    pointer-events: none;
}
.pagination .page-ellipsis {
    padding: 6px 4px;
    color: #999;
}
