@import url(./../main.css);
@import url(./../layouts/dashboard-layout.css);
@import url(./../components/sidebar.css);
@import url(./../components/tables.css);
@import url(./../components/buttons.css);
@import url(./../components/modals.css);
@import url(./../components/tabs.css);

/* Add Sensor Data admin action container (currently unused) */
#sensorDataAdminActions {
  margin-left: auto; /* pushes it to the far right */
}

#sensorDataAdminActions .btn {
  padding: 0.6rem 1.1rem;
  border-radius: 10px;
}

#sensorDataPagination {
  display: flex;
  flex-direction: column;
}

/* Remove layout gradient for sensor-data module pages - override legacy/layout.css */
html body.dashboard-page,
body.dashboard-page,
html body.dashboard-page * {
}

html,
body {
  height: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Move the action buttons to the right-most side of the tabs */
.tabs-actions {
  margin-left: auto;
}

.sensor-data-controls {
  margin-top: 40px;
}

/* Chrome, Edge, Safari */
#edit-node-modal-content::-webkit-scrollbar,
#addNodeModal::-webkit-scrollbar {
  width: 6px; /* thin vertical scrollbar */
}

#edit-node-modal-content::-webkit-scrollbar-track,
#addNodeModal::-webkit-scrollbar-track {
  background: transparent; /* clean background */
  margin: 8px 0; /* makes it look slightly shorter */
}

#edit-node-modal-content::-webkit-scrollbar-thumb,
#addNodeModal::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.25); /* soft modern gray */
  border-radius: 20px; /* rounded */
  transition: background 0.2s ease;
}

#edit-node-modal-content::-webkit-scrollbar-thumb:hover,
#addNodeModal::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.4);
}

/* Firefox */

#edit-node-modal-content,
#addNodeModal {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
}

#location-edit-modal-content {
  width: 31.25rem;
  height: 80%;
}

#sensor-filter-modal-content {
  width: 31.25rem;
}

#success-logo {
  width: 30%;
  margin: 0 auto 1.875rem;
}

#success-logo + h4 {
  font-weight: bolder;
  font-size: x-large;
  margin-bottom: 10px;
}

#toggleSensorDataFilterBtn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;

  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  font-weight: bold;

  background: #6b9368;
  border: none;
  border-radius: 6px;

  color: white;
  box-shadow: 0 4px 12px rgba(107, 147, 104, 0.25);
  transition: all 0.2s ease;
}

/* Hover */
#toggleSensorDataFilterBtn:hover {
  background: #4f7c59;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 124, 89, 0.3);
}

/* Active */
#toggleSensorDataFilterBtn:active {
  transform: translateY(0);
  box-shadow: 0 3px 8px rgba(79, 124, 89, 0.25);
}

/* Ensure body itself has no gradient */
html body.dashboard-page {
  background: var(--color-background) !important;
  background-image: none !important;
}

/* Tables and cards should have white background */
.sensor-data-table table,
.sensor-data-table thead,
.sensor-data-table tbody,
.sensor-data-table tr,
.sensor-data-table td,
.sensor-data-table th {
  background: #ffffff !important;
}

.sensor-data-table {
  background: #ffffff !important;
  border-radius: 12px;
  box-shadow: var(--shadow-xl);
}

/* Cards in sensor-data section */
.sensor-data-section .card,
.sensor-data-section .stat-card {
  background: #ffffff !important;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.sensor-data-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: center;
}

.search-container {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.search-input {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.5rem;

  border: 1px solid #e5e7eb;
  border-radius: 10px;

  background: #f9fafb;
  font-size: 0.9rem;

  transition: all 0.2s ease;
}

/* Focus */
.search-input:focus {
  outline: none;
  border-color: #6b9368;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(107, 147, 104, 0.18);
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
}

.filter-badge {
  background: #667eea;
  color: white;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.75rem;
  margin-left: 0.5rem;
}

/* ===== Modern Inline Filter Panel ===== */
.filter-panel-inline {
  background: #ffffff;
  padding: 1.5rem;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  margin-bottom: 1.5rem;
}

/* Grid Layout */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.2rem;
  align-items: end;
}

/* Filter Group */
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Labels */
.filter-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Inputs & Selects */
.filter-input {
  height: 40px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  padding: 0 0.9rem;
  font-size: 0.9rem;
  background: #f9fafb;
  transition: all 0.2s ease;
}

.filter-input:focus {
  outline: none;
  border-color: #4f7c59;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(79, 124, 89, 0.18);
}

.table-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  overflow: hidden;
}

.pagination-wrapper {
  padding: 1rem;
}

.sensor-data-controls .btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tabs-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
}

#scrollToTopBtn {
  transition:
    opacity 0.3s,
    transform 0.3s;
}

#scrollToTopBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

#sensorDataTableView {
  margin-top: 1rem;
}

/* Prevent tabs from wrapping when filter badge appears */
#nodeTabs {
  flex-wrap: nowrap !important;
  min-width: 0;
}

#nodeTabs .tab {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Ensure action buttons container doesn't cause wrapping */
.tabs-actions {
  flex-shrink: 0;
  white-space: nowrap;
}

/* Container for tabs and actions */
#nodeTabs.parent {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Step-based Add Node Modal Styles */
.modal-step {
  animation: fadeIn 0.3s ease-in;
}

/* Force main area to behave correctly inside grid */
.dashboard-page main {
  min-width: 0;
  overflow-x: hidden; /* prevent grid expansion */
}

/* Make only the table scroll */
.table-scroll-wrapper {
  width: 100%;
  overflow-x: auto;
  display: block;
  height: auto;
  max-height: none;
}

.table-scroll-wrapper table {
  height: auto;
  min-width: 1100px;
}

@media (max-width: 768px) {
  .search-input {
    width: 87%;
  }

  .sensor-data-controls:has(#sensorDataAdminActions[style*="block"])
    .search-input {
    width: 82%;
  }

  .filter-panel-inline {
    padding: 1rem;
    border-radius: 10px;
  }

  .filter-grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }

  .filter-group label {
    font-size: 0.7rem;
    margin-bottom: 4px;
  }

  .filter-input {
    height: 36px;
    font-size: 0.85rem;
  }

  #clearSensorFiltersBtn {
    font-size: 0.8rem;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.node-type-selector {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  border: 2px solid #ddd;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
}

.node-type-selector:hover {
  border-color: #667eea;
  background: #f0f4ff;
}

.node-type-selector.active {
  border-color: #667eea;
  background: #667eea;
  color: white;
}

.node-type-selector svg {
  margin-bottom: 0.5rem;
  color: inherit;
}

.sensor-data-table table {
  margin-bottom: var(--space-050);
}

.dashboard-page .container {
  align-items: start;
}

/* ===== Pagination Wrapper ===== */
.pagination-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
}

.pagination-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(10 / 16 * 1rem);
}

/* Page Info */
.page-info {
  font-size: 0.85rem;
  font-weight: 500;
  color: #6b7280;
}

.page-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
}

.pagination-wrapper {
  background: white;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  overflow: hidden;
  padding: 1rem;
}

.pagination-center {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

/* Pagination Buttons */
.btn-page,
.btn-start,
.btn-end {
  min-width: 80px;
  height: 36px;
  padding: 0 1rem;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

/* Hover */
.btn-page:hover:not(:disabled) {
  border-color: #6b9368;
  color: #4f7c59;
  background: #f3f7f3;
}

/* Active Click */
.btn-page:active:not(:disabled) {
  transform: translateY(1px);
}

/* Disabled State */
.btn-page:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Actions bar containing filter and export */
.actions-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

/* Secondary button style if not present in components */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  background: #4b5563;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  transform: translateY(-1px);
  background: #374151;
}

/* Utility to hide panels (replaces inline display toggles) */
.is-hidden {
  display: none !important;
}

.filter-clear-row {
  grid-column: 1 / -1;
  margin-top: 15px;
  display: flex;
  justify-content: flex-end;
}
.clear-filters-link {
  background: none;
  border: none;
  color: #667eea;
  cursor: pointer;
  text-decoration: underline;
  font-size: 0.9rem;
}

/* Hide admin actions by default when not used */
.admin-actions.is-hidden {
  display: none !important;
}

/* Download button hidden until export ready */
.download-btn {
  display: none;
}

/* Scroll to top button styling moved here */
#scrollToTopBtn.scroll-to-top {
  display: none;
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #667eea;
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

/* Export modal specific styles */

/* ===== Modern Export Modal ===== */
.export-modal-content {
  max-width: 500px;
  width: 100%;
  padding: 2rem;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  animation: fadeInUp 0.25s ease;
}

.export-modal-content h3 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.export-modal-content p {
  font-size: 0.9rem;
  color: #6b7280;
  margin-bottom: 1.5rem;
}

.export-format-group {
  display: flex;
  background: #f3f4f6;
  border-radius: 12px;
  padding: 6px;
  gap: 6px;
}

.export-format-group label {
  flex: 1;
  text-align: center;
  padding: 0.6rem 0;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #6b7280;
  background: transparent;
}

.export-format-group input[type="radio"] {
  display: none;
}

/* Selected state */
.export-format-group label:has(input:checked) {
  background: #6b9368;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(107, 147, 104, 0.25);
}

.export-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 2rem;
}

.export-actions .btn-primary {
  padding: 0.65rem 1.4rem;
  border-radius: 10px;
  font-weight: 600;
  background: #6b9368;
  border: none;
  box-shadow: 0 6px 18px rgba(107, 147, 104, 0.25);
  transition: all 0.2s ease;
}

.export-actions .btn-primary:hover {
  transform: translateY(-2px);
  background: #4f7c59;
}

.export-actions .btn-light {
  background: #f3f4f6;
  border: none;
  color: #374151;
  font-weight: 500;
  border-radius: 10px;
}

/* ===== EXPORT PROGRESS MODAL ===== */
.export-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem 0.5rem;
  gap: 1.25rem;
}

.export-status.ready .status-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: #111827;
}

.export-status .status-text {
  font-size: 1.6rem;
  font-weight: 600;
  color: #374151;
}

/* Spinner */
.export-status .spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid rgba(0, 0, 0, 0.08);
  border-top-color: #6b9368;
  animation: spin 0.8s linear infinite;
}

.ready-download-title {
  font-size: 1.3rem;
  font-weight: 700;

  margin-bottom: 1rem;
}
/* ready check image: hidden until export ready */
.status-ready {
  display: none;
  width: 72px;
  height: 72px;
}

.export-download-buttons {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.download-btn {
  padding: 0.7rem 1.6rem;
  border-radius: 12px;
  font-weight: 600;
  background: #6b9368;
  color: white;
  border: none;
  box-shadow: 0 8px 20px rgba(107, 147, 104, 0.25);
  transition: all 0.2s ease;
}

.download-btn:hover {
  transform: translateY(-2px);
  background: #4f7c59;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Modal base (simple, lightweight overrides in case components/modals.css not loaded) */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.modal-hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-content {
  gap: 10px;
  position: relative;
  z-index: 2;
}

/* When modal is visible, show export status area toggles via JS */
.modal .export-status.show {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

.export-download-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
}

#closeExportProgressBtn {
  padding: 0.7rem 1.2rem;
  border-radius: 12px;
  background: #f3f4f6;
  border: none;
  color: #374151;
  font-weight: 500;
}

@media (max-width: 430px) {
  .btn-page,
  .btn-start,
  .btn-end {
    min-width: 25px;
  }
}
