* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, sans-serif;
  margin: 0;
  padding: 20px;
  background: #f8fafc;
  min-height: 100vh;
  color: #333;
}

.login-container {
  max-width: 320px;
  margin: 80px auto;
  padding: 24px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.login-container h2 {
  text-align: center;
  margin-bottom: 1rem;
}

.error {
  color: #e00;
  margin-top: 1rem;
  text-align: center;
}

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

h1 {
  text-align: center;
  color: white;
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 2rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.panels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  align-items: stretch; /* Changed to stretch for equal heights */
}

.panel {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  position: relative; /* Allow panels to layer above each other */
}

.panel h2 {
  margin: 0 0 20px 0;
  color: #2d3748;
  font-size: 1.5rem;
  font-weight: 600;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 8px;
  flex-shrink: 0;
}

/* Make panel content fill remaining space */
.panel > div:last-child {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

/* Override pagination layout to row */
#messages-panel > .pagination {
  display: flex;
  flex-direction: row;
}

.form-group {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"],
textarea {
  flex: 1;
  min-width: 120px;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: #f8fafc;
  font-family: inherit;
  resize: vertical;
}

/* Style the client selector dropdown */
.client-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
  margin-bottom: 24px;
  padding: 16px 24px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.client-selector select {
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-width: 180px;
  max-width: 280px;
}

.client-selector select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  background: white;
}

/* Style add/delete actions as text */
.client-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.client-actions .text-button {
  background: none;
  border: none;
  padding: 0;
  color: #4a5568;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.client-actions .text-button.delete {
  color: #e53e3e;
}

.client-actions .text-button:disabled {
  background: none;
  color: #cbd5e0;
  cursor: not-allowed;
}

.client-actions .text-button:hover {
  background: none;
  box-shadow: none;
}

.ws-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="file"]:focus,
textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  background: white;
}

input[type="file"] {
  padding: 10px 16px;
  cursor: pointer;
}

button {
  padding: 12px 20px;
  background: #4a5568;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

/* Cupertino-style switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  margin-left: 8px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #e2e8f0;
  transition: 0.4s;
  border-radius: 12px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

input:checked + .slider {
  background-color: #34c759;
}

input:checked + .slider:before {
  transform: translateX(20px);
}

button:hover {
  background: #5a6678;
  box-shadow: 0 4px 12px rgba(74, 85, 104, 0.4);
}

button:disabled {
  background: #cbd5e0;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-danger {
  background: linear-gradient(135deg, #fc8181 0%, #f56565 100%);
  padding: 6px 12px;
  font-size: 12px;
  margin-left: 8px;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
  box-shadow: 0 4px 12px rgba(245, 101, 101, 0.4);
}

#whitelist {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 300px;
  overflow-y: auto;
  flex-grow: 1;
}

#whitelist li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: #f8fafc;
  border-radius: 8px;
  border-left: 4px solid #4a5568;
  font-family: "Monaco", "Menlo", monospace;
  font-size: 14px;
}

#whitelist li:hover {
  background: #edf2f7;
}

#media-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 300px;
  overflow-y: auto;
}

#media-list li {
  margin-bottom: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  background: white;
  border-radius: 8px;
  /* Allow dropdown menus inside table rows to be fully visible */
  overflow: visible;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

th {
  background: #4a5568;
  color: white;
  padding: 16px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 12px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 14px;
  text-align: left;
}

#messages td.text {
  white-space: pre-wrap;
}

/* Actions column alignment */
.actions-cell {
  text-align: left !important;
  position: relative;
}

/* 3-dot dropdown menu styles */
.actions-dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 14px;
  color: #4a5568;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
}

.dropdown-toggle:hover {
  background: #e2e8f0;
  border-color: #cbd5e0;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.dropdown-toggle:active {
  transform: translateY(0);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  min-width: 160px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 14px;
  color: #4a5568;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:first-child {
  border-radius: 7px 7px 0 0;
}

.dropdown-item:last-child {
  border-radius: 0 0 7px 7px;
}

.dropdown-item:only-child {
  border-radius: 7px;
}

.dropdown-item:hover {
  background: #f8fafc;
  box-shadow: none; /* Remove drop shadow on hover */
  border-radius: 7px;
}
.dropdown-item.danger {
  color: #e53e3e;
}

.dropdown-item-icon {
  font-size: 16px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Separator between dropdown items */
.dropdown-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 4px 0;
}

tr:hover {
  background: #f8fafc;
}

tr:last-child td {
  border-bottom: none;
}

.pagination {
  display: flex;           /* turn it into a flex container */
  flex-direction: row;     /* lay items out in a row (this is the default) */
  justify-content: center; /* center them, or use space-between if you want them at edges */
  align-items: center;     /* vertically center if the buttons ever differ in height */
  gap: 8px;                /* space between the two buttons */
}

.pagination button {
  padding: 8px 16px;
  font-size: 14px;
  flex: 0 0 auto; /* Don't grow, don't shrink, auto width */
  width: auto; /* Explicit auto width */
  max-width: fit-content; /* Fit content width */
}

#messages-panel .search-controls {
  margin-bottom: 12px;
}

.messages-panel {
  grid-column: 1 / -1;
}

.panel-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.panel-description {
  margin-bottom: 16px;
  color: #4a5568;
}


.table-container {
  /* Allow dropdown menus to extend outside the table container */
  overflow: visible;
  border-radius: 8px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #718096;
  font-style: italic;
}

.file-link {
  color: #4a5568;
  text-decoration: none;
  font-weight: 500;
}

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

.status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #48bb78;
  border-radius: 50%;
  margin-right: 8px;
}

/* Special styling for signal banner content */
#signal-banner .banner-content {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-grow: 1;
  gap: 16px;
}

.signal-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.big-number {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
}

@media (max-width: 768px) {
  body {
    padding: 16px;
  }

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

  .panels {
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: start; /* Reset to start for mobile */
  }


  .panel {
    padding: 20px;
  }

  .form-group {
    flex-direction: column;
  }

  input[type="text"],
  input[type="password"],
  input[type="number"],
  input[type="file"],
  textarea {
    min-width: auto;
  }

  table {
    font-size: 12px;
  }

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

.loading {
  opacity: 0.6;
  pointer-events: none;
}

.success-message {
  background: #c6f6d5;
  color: #22543d;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  border-left: 4px solid #48bb78;
}

.error-message {
  background: #fed7d7;
  color: #742a2a;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  border-left: 4px solid #f56565;
}

/* Container for all snackbars */
#snackbar-container {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: 10000;
  pointer-events: none;
}

/* Base snackbar */
.snackbar {
  min-width: 200px;
  max-width: 320px;
  padding: 12px 16px;
  border-radius: 8px;
  background: white;
  color: #2d3748;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  font-size: 0.9rem;
  text-align: left;
  pointer-events: all;
  animation: slideIn 0.3s ease-out, fadeOut 0.3s ease-in 2.7s forwards;
}

/* Variants */
.snackbar.success { border-left: 4px solid #34c759; }
.snackbar.error   { border-left: 4px solid #f56565; }

/* Animations */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* Spinner graphic */
.spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: middle;
  animation: spin 0.6s linear infinite;
  margin-right: 0.5em;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#messages th.media,
#messages td.media {
  min-width: 120px;
}

/* Modal Dialog System */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(74, 85, 104, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background: #f8fafc;
  border-radius: 12px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(74, 85, 104, 0.2);
  transform: scale(0.9) translateY(-20px);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-dialog {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 20px 24px 0;
  border-bottom: none;
}

.modal-header h3 {
  margin: 0;
  color: #2d3748;
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-body {
  padding: 16px 24px 24px;
}

.modal-body p {
  margin: 0 0 16px 0;
  color: #4a5568;
  line-height: 1.5;
}

.modal-body input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: #f8fafc;
}

.modal-body input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  background: white;
}

.modal-footer {
  padding: 0 24px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.modal-footer button {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover {
  background: #5a67d8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
  background: #e2e8f0;
  color: #4a5568;
}

.btn-secondary:hover {
  background: #cbd5e0;
  transform: translateY(-1px);
}

