/* ==========================================================
   WhoTaggedIt — Review Console Stylesheet (Refined Edition)
   ========================================================== */

body {
  background-color: #111;
  color: #eee;
  font-family: system-ui, sans-serif;
  margin: 0;
}

/* ==========================================================
   HEADER
   ========================================================== */

header {
  padding: 1rem;
  text-align: center;
  background-color: #222;
  border-bottom: 1px solid #333;
}
header h1 {
  margin: 0;
  font-size: 1.4rem;
}

.filters,
.search-box {
  margin-top: 0.5rem;
}

.filters a {
  display: inline-block;
  margin: 0.2rem;
  padding: 0.5rem 1rem;
  border: 1px solid #444;
  border-radius: 4px;
  text-decoration: none;
  color: #eee;
  background-color: #1b1b1b;
}
.filters a.active {
  background-color: #444;
  font-weight: bold;
}

/* ==========================================================
   Compact Header: logo + title on one line
   ========================================================== */

.header-row {
  display: flex;
  justify-content: center;   /* center horizontally */
  align-items: center;       /* align vertically */
  gap: 1rem;
  margin-bottom: 0.8rem;     /* space above filters */
}

.header-logo {
  height: 80px;
  width: auto;
}

.header-title {
  font-size: 2.4rem;
  font-weight: 700;
  margin: 0;
  color: #fff;
}

/* ==========================================================
   Compact Inline Search Bar (Refined)
   ========================================================== */

.search-row {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  width: auto;
  margin: 0 auto;
}

/* FIX: We use ".search-row .search-input" here to create a 
   specific selector (0-2-0) that overrides the generic input rule below.
*/
.search-row .search-input {
  width: 400px;             /* Target width */
  max-width: 100%;          /* Prevent overflow on small screens */
  padding: 0.45rem 0.6rem;
  border-radius: 4px;
  border: 1px solid #444;
  background: #222;
  color: #eee;
  display: inline-block;
  margin: 0;
  white-space: nowrap;
  box-sizing: border-box;   /* Crucial for correct sizing */
}

.search-btn,
.adv-search-btn {
  white-space: nowrap;
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
  border: 1px solid #555;
  border-radius: 4px;
  background: #333;
  color: #eee;
  cursor: pointer;
  text-decoration: none;
}

.search-btn:hover,
.adv-search-btn:hover {
  background: #444;
}

.search-box {
  margin-bottom: 1rem;
}

/* ==========================================================
   SUMMARY BLOCK
   ========================================================== */

.summary {
  text-align: center;
  margin: 1rem 0;
  font-size: 0.95rem;
  color: #aaa;
  background: #1b1b1b;
  border: 1px solid #333;
  padding: 0.6rem;
  border-radius: 6px;
}

/* ==========================================================
   MAIN LAYOUT
   ========================================================== */

main {
  max-width: 1400px;
  margin: 1rem auto;
  padding: 1rem;
}
main,
main * {
  text-align: left !important;
}

/* ==========================================================
   RECORD BLOCKS
   ========================================================== */

.record {
  display: flex;
  flex-direction: row;
  background: #1a1a1a;
  margin-bottom: 1.5rem;
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid #333;
}

.left {
  flex: 0 0 40%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.left img {
  max-width: 100%;
  max-height: 400px;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.3s ease;
}
.left img:hover {
  transform: scale(1.03);
}

.right {
  flex: 1;
  padding-left: 1.2rem;
}

.filename {
  font-weight: bold;
  color: #66ccff;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.meta {
  font-size: 0.9rem;
  margin-bottom: 1rem;
  color: #ccc;
  background: #151515;
  padding: 0.6rem;
  border-radius: 6px;
  border: 1px solid #282828;
}

/* ==========================================================
   FORM ELEMENTS
   ========================================================== */

textarea,
select,
input[type="text"] {
  background: #222;
  color: #eee;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  width: 95%;
  box-sizing: border-box; /* FIX: Prevents width + padding from exceeding container */
}

textarea {
  min-height: 4.5em;
  resize: vertical;
}

.caption-status {
  display: inline-block;
  margin-left: 0.4rem;
  color: #7fd47f;
  visibility: hidden;
}

button {
  background: #333;
  color: #eee;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 0.4rem 0.8rem;
  margin-top: 0.3rem;
  cursor: pointer;
}
button:hover {
  background: #444;
}

.status {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}
.status span.ok {
  color: #7fd47f;
}
.status span.bad {
  color: #f76c6c;
}
.status span.warn {
  color: #e6b800;
}

/* ==========================================================
   PAGINATION
   ========================================================== */

.pagination {
  text-align: center;
  margin-top: 2rem;
}
.pagination a {
  display: inline-block;
  margin: 0 0.4rem;
  padding: 0.5rem 1rem;
  color: #eee;
  background: #222;
  border-radius: 4px;
  border: 1px solid #444;
  text-decoration: none;
}
.pagination a:hover {
  background: #333;
}

/* ==========================================================
   LIGHTBOX
   ========================================================== */

#lightbox {
  display: none;
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.95);
  align-items: center;
  justify-content: center;
}

#lightbox img {
  max-width: 95%;
  max-height: 95%;
}

/* ==========================================================
   COMPACT LIMIT SELECTOR
   ========================================================== */

.limit-selector select {
  width: auto;
  min-width: 4em;
  display: inline-block;
  padding: 0.25rem 0.5rem;
}
.limit-selector {
  display: inline-block;
  margin-left: 1em;
}

/* ==========================================================
   STATS PAGE CHART LAYOUT
   ========================================================== */

.charts-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 1rem;
  width: 100%;
}

.chart-box {
  flex: 0 0 45%;
  min-width: 360px;
  max-width: 600px;
  background: #1b1b1b;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.5rem;
  box-sizing: border-box;
}

.chart-box-full {
  width: 100%;
  background: #1b1b1b;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.5rem;
  margin-top: 1rem;
  box-sizing: border-box;
}

/* ==========================================================
   BULK TOOLBAR
   ========================================================== */

.bulk-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.8rem;
  background: #222;
  border: 2px solid #555;
  border-radius: 6px;
  padding: 0.6rem;
  margin-bottom: 0.8rem;
}

.bulk-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.bulk-controls label {
  font-size: 0.9rem;
  color: #ccc;
}

.bulk-controls select {
  width: auto;
  min-width: 65px;
  padding: 0.25rem 0.4rem;
}

#bulk_apply_btn {
  background: #333;
  color: #eee;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 0.3rem 0.8rem;
  margin-left: 0.6rem;
  cursor: pointer;
  transition: background 0.2s ease;
}
#bulk_apply_btn:hover {
  background: #3a3a3a;
}

#bulk_status_icon {
  margin-left: 0.4rem;
  color: #7fd47f;
  visibility: hidden;
}

#bulk_map_btn {
  background: #333;
  border: 1px solid #555;
  color: #eee;
  border-radius: 4px;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
}
#bulk_map_btn:hover {
  background: #444;
}

/* ==========================================================
   MAP PAGE
   ========================================================== */

#map {
  height: 100vh;
  width: 100vw;
  background: #000;
}

#map-controls {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 9999;
  background: rgba(20,20,20,0.82);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 10px;
}

#map-controls button {
  background: #333;
  color: #eee;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 6px 12px;
  margin: 6px 0;
  width: 140px;
  cursor: pointer;
}
#map-controls button:hover {
  background: #444;
}

.leaflet-popup-content-wrapper {
  background: #1b1b1b;
  color: #eee;
  border-radius: 8px;
  border: 1px solid #333;
  box-shadow: 0 0 10px rgba(0,0,0,0.6);
}

.leaflet-popup-content {
  max-height: 450px;
  overflow-y: auto;
  padding-right: 4px;
  font-size: 0.9rem;
  scrollbar-width: thin;
}

.popup-container {
  min-width: 280px;
}
.popup-container h3 {
  margin: 0 0 8px 0;
  color: #ffb347;
}
.popup-meta {
  line-height: 1.4;
  margin-bottom: 8px;
}
.popup-image-block {
  margin-bottom: 6px;
}
.popup-image-block img {
  max-width: 100%;
  border-radius: 4px;
  border: 1px solid #333;
  margin: 6px 0;
}
.popup-fields {
  font-size: 0.85rem;
  line-height: 1.45;
}
.leaflet-popup-content hr {
  border: 0;
  border-top: 1px solid #444;
  margin: 10px 0;
}
.leaflet-popup-content a {
  color: #66ccff;
  text-decoration: none;
}
.leaflet-popup-content a:hover {
  text-decoration: underline;
}

/* ==========================================================
   PDF GENERATION OVERLAY
   ========================================================== */

#pdf_loading_overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.78);
  z-index: 9999;
  backdrop-filter: blur(3px);
}

.pdf_loading_box {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #fff;
  font-size: 20px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 6px solid #444;
  border-top: 6px solid #fff;
  border-radius: 50%;
  margin: 0 auto 15px auto;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading_text {
  margin-top: 10px;
  font-size: 18px;
  letter-spacing: 0.5px;
}

/* ==========================================================
   LOGOUT / BANNER
   ========================================================== */

.logout-container {
  position: absolute;
  top: 20px;
  right: 20px;
}

.logout-btn {
  background: #aa3333;
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: bold;
  border: 1px solid #771f1f;
}
.logout-btn:hover {
  background: #cc4444;
}

.readonly-banner {
  background: #663;
  border: 1px solid #aa8;
  color: #ffebc2;
  padding: 0.8rem 1rem;
  margin: 1.2rem auto;
  text-align: center;
  font-size: 1.05rem;
  border-radius: 6px;
  max-width: 900px;
  box-shadow: 0 0 8px rgba(0,0,0,0.35);
}

/* ==========================================================
   DATE FILTER BAR
   ========================================================== */

.date-filter-bar {
  margin-top: 0.8rem;
  padding: 0.5rem;
  background-color: #1b1b1b;
  border: 1px solid #333;
  display: inline-block;
  border-radius: 6px;
}

.date-filter-bar form {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}

.date-filter-bar span {
  font-size: 0.9rem;
  color: #ccc;
  font-weight: bold;
}

input[type="datetime-local"] {
  background: #222;
  color: #eee;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  font-family: inherit;
  color-scheme: dark;
}

input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

.filter-btn {
  background: #006699;
  border: 1px solid #005580;
  color: white;
  margin: 0;
}
.filter-btn:hover {
  background: #0077b3;
}

.clear-date-btn {
  color: #ff6666;
  text-decoration: none;
  font-size: 0.9rem;
  border: 1px solid #662222;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  background: #331111;
}
.clear-date-btn:hover {
  background: #551111;
}

/* ==========================================================
   PAGINATION BREADCRUMBS & SCROLL TOP
   ========================================================== */

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 5px;
  margin-top: 2rem;
  margin-bottom: 3rem;
  padding-top: 1rem;
  border-top: 1px solid #222;
}

.page-link {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  background: #1b1b1b;
  color: #aaa;
  border: 1px solid #333;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.page-link:hover {
  background: #333;
  color: #fff;
  border-color: #555;
}

.page-link.active {
  background: #006699;
  color: #fff;
  border-color: #005580;
  font-weight: bold;
  pointer-events: none;
}

.page-ellipsis {
  color: #666;
  padding: 0 5px;
}

.scroll-top-btn {
  margin-left: 20px;
  padding: 0.5rem 1.2rem;
  background: #333;
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  border: 1px solid #555;
  font-weight: bold;
}
.scroll-top-btn:hover {
  background: #444;
}

/* ==========================================================
   MOBILE / PORTABLE DEVICE RESPONSIVENESS
   Triggers on screens narrower than 900px
   ========================================================== */

@media (max-width: 900px) {

  /* --- 1. Header & Logout Fixes --- */
  
  .logout-container {
    position: static;
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 1rem;
    order: -1; 
  }
  
  .header-row {
    flex-direction: column;
    text-align: center;
    margin-top: 1rem;
  }
  
  .header-title {
    font-size: 1.8rem;
  }

  /* --- 2. Filter & Search Controls --- */
  
  .filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
  }
  
  .filters a {
    flex: 1 1 auto; 
    text-align: center;
    margin: 0;
  }

  .search-row {
    flex-direction: column;
    width: 100%;
  }
  
  /* FIX: We match the specific selector used above (.search-row .search-input) 
     so this override actually works!
  */
  .search-row .search-input {
    width: 100%; 
  }

  .search-btn, .adv-search-btn {
    width: 100%; 
    margin-top: 5px;
  }

  .date-filter-bar form {
    flex-direction: column;
    width: 100%;
  }
  
  .date-filter-bar input[type="datetime-local"] {
    width: 100%;
    box-sizing: border-box;
  }
  
  .filter-btn {
    width: 100%;
    margin-top: 10px;
    padding: 10px;
  }

  /* --- 3. The Main Record "Card" Layout --- */
  
  .record {
    flex-direction: column;
    position: relative;
    padding-top: 50px;
  }

  .record .left:first-child {
    position: absolute;
    top: 10px;
    left: 10px;
    width: auto;
    z-index: 10;
  }
  .select_record {
    transform: scale(1.5);
  }

  .left {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    margin-bottom: 1rem;
  }
  
  .left img {
    max-height: 300px;
    width: auto;
    max-width: 100%;
  }

  .right {
    padding-left: 0;
  }

  /* --- 4. Inputs & Forms --- */
  
  textarea, 
  select, 
  input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    font-size: 16px; 
  }

  .right button {
    width: 100%;
    padding: 10px;
    margin-top: 8px;
  }

  /* --- 5. Bulk Update Bar --- */
  
  .bulk-header {
    display: block; 
  }

  .bulk-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }
  
  .bulk-controls label {
    grid-column: span 2;
    margin-top: 5px;
    font-weight: bold;
  }
  
  .bulk-controls select {
    grid-column: span 2;
  }
  
  #bulk_apply_btn, #bulk_map_btn, #bulk_pdf_btn {
    grid-column: span 2;
    margin: 10px 0 0 0;
    padding: 12px;
  }
}
