/* ──────────────────────────────── Global Layout ──────────────────────────────── */
body {
  font-family: Arial, sans-serif;
  background-color: #2a2a2a;
  color: white;
  margin: 0;
  padding: 20px;
}

.container {
  max-width: 800px;
  margin: auto;
}

h1 {
  text-align: center;
}

.index-page span {
  background-color: #dc3545;
  color: white;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-right: 8px;
  font-size: 14px;
  font-weight: bold;
  text-shadow: 1px 1px 3px #000;
}

/* ──────────────────────── Theme Support ──────────────────────── */

body.light-mode {
  background-color: #f4f4f4;
  color: #222;
}

body.light-mode input,
body.light-mode select,
body.light-mode textarea {
  background-color: #fff;
  color: #000;
  border: 1px solid #ccc;
}

body.light-mode nav {
  background-color: #ffffff;
}

body.light-mode .nav-bar a,
body.light-mode .nav-bar button:not(.nav-toggle) {
  background-color: #007bff;  /* keep blue for contrast */
  color: white;
}

body.light-mode .nav-bar a:hover,
body.light-mode .nav-bar button:not(.nav-toggle):hover {
  background-color: #0056b3;
}

body.light-mode .settings-section,
body.light-mode .upload-box,
body.light-mode .grid-item,
body.light-mode form,
body.light-mode table,
body.light-mode dialog.details {
  background-color: #ffffff;
  color: #000;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

/* body.light-mode table th {
  background-color: #f0f0f0;
} */

body.light-mode table tr:hover {
  background-color: #eaeaea;
}



/* ──────────────────────────────── Form Elements ──────────────────────────────── */
.form-group {
  margin-bottom: 15px;
}

input, select {
  background-color: #3c3c3c;
  color: white;
  border: 1px solid #777;
  width: 100%;
  padding: 10px;
  font-size: 1rem;
  margin-top: 5px;
  border-radius: 8px;
}

textarea {
  background-color: #3c3c3c;
  color: white;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 10px;
  width: 100%;
  resize: vertical;
}

label {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  margin-bottom: 5px;
  text-align: center;
}

/* ──────────────────────────────── Buttons ──────────────────────────────── */
.btn {
  background: #007BFF;
  color: white;
  border: none;
  cursor: pointer;
  border-radius: 5px;
  display: inline-block;
  padding: 10px 15px;
  margin-top: 10px;
  text-decoration: none;
  width: 100%;
  font-size: 1rem;
}

.btn:hover {
  background: #0056b3;
}

.download-btn {
  background: #777;
  width: 50%;
}

/* ──────────────────────────────── Search Table Styling ──────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  background-color: #3c3c3c;
  color: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 0 10px rgba(0,0,0,0.4);
  overflow-x: auto;
}

table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: #007bff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  border-radius: 5px;
}

body.light-mode table thead th {
  background-color: #007bff;
  color: white;
}


.table-container {
  overflow-x: auto;
  margin-top: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
  overflow-y: auto;
  max-height: 70vh;
}

/* Add sort arrow visuals to sortable headers */
th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}

thead th.sortable:nth-child(1) {
  border-top-left-radius: 5px;
  border-bottom-left-radius: 5px;
}

thead th.sortable:nth-child(15){
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
}

th.sortable::after {
  content: " ⇅"; /* Default appearance */
  font-size: 0.8rem;
  color: #aaa;
  margin-left: 4px;
}

th.sortable.sorted-asc::after {
  content: " ▲";
  color: #fff;
}

th.sortable.sorted-desc::after {
  content: " ▼";
  color: #fff;
}

.column-filter {
  width: 90%;
  padding: 4px 6px;
  font-size: 0.85rem;
  margin-top: 4px;
  border-radius: 4px;
  border: 1px solid #777;
  background-color: #2a2a2a;
  color: white;
}

/* Allow the table to expand beyond container width but keep padding */
.table-outer-wrapper {
  width: 100vw;
  overflow-x: auto;
  padding: 0 2rem;
  margin: 2rem 0;
  box-sizing: border-box;
}

/* Let table stretch but stay styled */
.table-container.wider {
  min-width: 1400px; /* or larger if needed */
  background-color: #3c3c3c;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0,0,0,0.4);
  padding: 1rem;
  overflow-x: auto;
}

/* Light mode override */
body.light-mode .table-container.wider {
  background-color: #fcfcfc;
}

.column-filter::placeholder {
  color: #aaa;
  font-style: italic;
}

body.light-mode .column-filter::placeholder {
  color: #888;
}

body.light-mode .column-filter {
  background-color: #fff;
  color: black;
  border: 1px solid #ccc;
}

body.light-mode th.sortable.sorted-asc::after,
body.light-mode th.sortable.sorted-desc::after {
  color: #222;
}

table tbody tr:nth-child(even) {
  background-color: #1f1f1f;
}

table tbody tr:nth-child(odd) {
  background-color: #2a2a2a;
}

body.light-mode table tbody tr:nth-child(even) {
  background-color: #f4f4f4;
}

body.light-mode table tbody tr:nth-child(odd) {
  background-color: #ffffff;
}

table tbody tr:hover {
  background-color: #444;
  cursor: pointer;
}

body.light-mode table tr:hover {
  background-color: #eaeaea;
}

table thead {
  background-color: #007bff;
  color: white;
}

body.light-mode table thead {
  background-color: #007bff;
  color: white;
}

table th, table td {
  padding: 12px 15px;
  text-align: center;
  border-bottom: 1px solid #555;
}

table th {
  background-color: #007bff;
  font-weight: bold;
}

.ng-cell {
  background-color: #dc3545;
  color: white;
  font-weight: bold;
}


/* ──────────────────────────────── Grid Download Section ──────────────────────────────── */
.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.grid-item {
  background-color: #113c38;
  padding: 1.5rem;
  border-radius: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  text-align: center;
  transition: transform 0.2s ease-in-out;
}

.grid-item:hover {
  transform: translateY(-5px);
}

.grid-item input {
  margin-top: 10px;
  padding: 0.5rem;
  width: 80%;
}

.grid-item button,
.grid-item a {
  margin-top: 10px;
  display: inline-block;
  width: 80%;
  padding: 0.6rem;
  text-decoration: none;
  color: white;
  background-color: #007bff;
  border: none;
  border-radius: 8px;
  transition: background-color 0.2s;
}

.grid-item button:hover,
.grid-item a:hover {
  background-color: #0056b3;
}

.grid-item .danger {
  background-color: #dc3545;
}

.grid-item .danger:hover {
  background-color: #a71d2a;
}

.back-link {
  margin-top: 2rem;
  display: block;
  text-align: center;
}

/* ──────────────────────────────── Upload Box ──────────────────────────────── */
.upload-box {
  background-color: #113c38;
  color: white;
  margin-top: 3rem;
  padding: 2rem;
  border-radius: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.upload-box input[type="file"] {
  margin-top: 1rem;
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid #888;
  width: 80%;
  background-color: #3c3c3c;
  color: white;
}

.upload-box .btn {
  margin-top: 1rem;
  background-color: #1abc9c;
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  font-weight: bold;
  border-radius: 8px;
  transition: background-color 0.3s ease;
}

.upload-box .btn:hover {
  background-color: #148f77;
}

.custom-file-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.file-label {
  background-color: #1abc9c;
  color: white;
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.file-label:hover {
  background-color: #0e6655;
}

.custom-file-upload input[type="file"] {
  display: none;
}

.file-name {
  font-size: 0.9rem;
  color: #ccc;
  text-align: center;
}


/* ──────────────────────────────── Navigation Bar ──────────────────────────────── */

nav {
  position: sticky;
  top: 0;
  z-index: 1000; /* Make sure it stays above other content */
  background-color: #2a2a2a;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Default (desktop) layout */
.nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #2a2a2a;
  padding: 0.75rem;
  gap: 1rem;
  border-radius: 5px;
}

.nav-links {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  width: 100%;
}

.nav-bar a,
.nav-bar button:not(.nav-toggle) {
  flex: 1;
  text-align: center;
  padding: 0.75rem 1rem;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 0.5rem;
  text-decoration: none;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s ease-in-out;
}

.nav-bar a:hover,
.nav-bar button:not(.nav-toggle):hover {
  background-color: #0056b3;
}

/* Toggle button (shown only on mobile) */
.nav-toggle {
  display: none;
  background-color: #007bff;
  color: white;
  border: none;
  padding: 0.75rem 1rem;
  width: 100%;
  font-size: 1.1rem;
  font-weight: bold;
  border-radius: 0.5rem;
  cursor: pointer;
  margin-bottom: 0.5rem;
}

/* ──────────────────────────────── Images ──────────────────────────────── */
img {
  display: block;
  margin: 10px auto;
  border-radius: 5%;
  max-width: 100%;
}

/* ──────────────────────────────── Login Specific Enhancements ──────────────────────────────── */
form {
  margin-top: 2rem;
  background-color: #1f1f1f;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 0 10px rgba(0,0,0,0.6);
}

h1 {
  margin-bottom: 1rem;
  font-size: 2rem;
}

input[type="checkbox"] {
  accent-color: #007BFF;
}

/* ──────────────────────────── MODAL RESET ──────────────────────────── */
dialog.details {
  width: 90%;
  max-width: 900px;
  border: none;
  border-radius: 10px;
  padding: 0;
  background-color: #2a2a2a;
  color: white;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.7);
  touch-action: pan-y;
  overscroll-behavior: contain;
}


#history_pop_title_bar {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #555;
  margin-bottom: 1.5rem;
}

#history_pop_title_bar span{
  padding-left: .25rem;
  padding-top: .25rem;
}

#history_pop_title_bar p {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
}


#close_properties {
  font-size: 1.5rem;
  font-weight: bold;
  color: #e74c3c;
  cursor: pointer;
  background: none;
  border: none;
  user-select: none;
  pointer-events: auto;
  z-index: 10;
}

#click-shield {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  background: transparent;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

#click-shield.active {
  pointer-events: all;
}

/* Modal content layout */
#history_container {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 2rem;
  align-items: flex-start;
  justify-content: space-between;
}

/* Left column: data */
#info-block {
  flex: 1 1 300px;
}

#info-block ul {
  list-style: none;
  padding: .5 rem;
  margin: 0;
}

#info-block li {
  margin-bottom: 1rem;
  font-size: 1rem;
  line-height: 1.5;
}

/* Right column: image preview */
#custom_images {
  flex: 1 1 400px;
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#custom_images img {
  max-width: 100%;
  max-height: 250px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid #555;
}


/* ──────────────────────────────── Toggle Images Button ──────────────────────────────── */
#toggleImagesBtn {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px auto;
  padding: 8px 12px;
  font-size: 0.9rem;
  border: none;
  background-color: #11806a; /* darker complementary teal */
  color: white;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

#toggleImagesBtn:hover {
  background-color: #0e6655;
}

#toggleImagesBtn svg {
  fill: currentColor;
}

/*______________________Flash Block_____________________________*/
.flash-container {
  margin-bottom: 1rem;
}

.flash {
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: bold;
  text-align: center;
  margin: 1rem auto;
  max-width: 700px;
  opacity: 1;
}

.flash.success {
  background-color: #28a745;
  color: white;
}

.flash.error {
  background-color: #dc3545;
  color: white;
}

/* ──────────────── Responsive Patch Additions ──────────────── */
@media (max-width: 768px) {
  .table-container.wider {
    min-width: 1000px;
  }
}


@media (max-width: 600px) {
  html, body {
    overflow-x: hidden;
  }

  body {
    padding: 10px;
  }

  .container {
    max-width: 100%;
    width: 90%;
    padding: 0 10px;
  }

  form {
    width: 100%;
    padding: 1rem;
    box-sizing: border-box;
  }

  .form-group {
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
    box-sizing: border-box;
  }

  .form-group label,
  .form-group input,
  .form-group select,
  .form-group textarea {
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
  }

  #custom_images {
    flex: 1 1 100%;
    max-height: none;
  }

  .toggle-image {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0.5rem auto;
  }

  .login-form {
    max-width: 400px;
    margin: auto;
    width: 100%;
    padding: 1rem;
  }

  .grid-item input,
  .grid-item button,
  .grid-item a {
    width: 100% !important;
  }

  .nav-bar {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .nav-bar a,
  .nav-bar button:not(.nav-toggle) {
    flex: 1;
    text-align: center;
    padding: 0.75rem 0rem;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 0.5rem;
    text-decoration: none;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
  }

  .nav-toggle {
    display: block;
    background-color: #007bff;
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    width: 100%;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 0.5rem;
    cursor: pointer;
    margin-bottom: 0.5rem;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
  }

  .nav-links.show {
    display: flex;
  }

  #toggleImagesBtn {
    width: 100%;
    justify-content: center;
  }

  /* TABLE-SPECIFIC STYLES */
  .table-outer-wrapper {
    width: 100%;
    overflow-x: auto;
    padding: 0 10px;
    margin: 2rem 0;
  }

  .table-container.wider {
    min-width: 800px;
    padding: 0.5rem;
    margin: 0 auto;
  }

  table {
    width: 100%;
    border-radius: 0;
    box-shadow: none;
  }

  table, th, td {
    font-size: 0.85rem;
  }

  table th,
  table td {
    padding: 8px 6px;
  }

  .column-filter {
    width: 100%;
    font-size: 0.75rem;
  }

  .btn {
    padding: 8px 12px;
    font-size: 0.9rem;
  }

  /* Dialog Box */
  dialog.details {
    width: 85%;
    padding: 1rem;
    max-height: 90vh;
    overflow-y: auto;
  }

  #history_container {
    flex-direction: column;
    gap: 1rem;
  }

  #info-block,
  #custom_images {
    flex: 1 1 100%;
  }

  #custom_images img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
  }

  #history_pop_title_bar {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
  }

  #history_pop_title_bar p {
    font-size: 1.1rem;
    text-align: center;
    width: 100%;
  }

  dialog.details::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    background: #ccc;
    border-radius: 2px;
    margin: 0 auto 10px auto;
  }

  .modal-inner {
  background-color: inherit;
  color: inherit;
  padding: 1rem;
  border-radius: 10px;
  max-height: 90vh;
  overflow-y: auto;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  }

}


/* Optional: reduce button padding on very small screens */
@media (max-width: 400px) {
  .btn {
    padding: 8px 12px;
    font-size: 0.9rem;
  }
}
