/* Reefmon-inspired dashboard styling */
:root {
  --header-bg: #0a4d68;
  --header-teal: #0d5c7a;
  --page-bg: #eef1f4;
  --panel-bg: #ffffff;
  --text: #1a1a1a;
  --border-gradient: linear-gradient(135deg, #6b4c9a, #2e6eb5);
  --btn-border: #5a6fd6;
  --link: #0d5c7a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--page-bg);
  color: var(--text);
}

.site-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 2rem;
  background: linear-gradient(180deg, var(--header-teal), var(--header-bg));
  color: #fff;
}

.header-logo {
  height: 48px;
  width: auto;
}

.header-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  flex: 1;
}

.header-logout {
  margin-left: auto;
  color: #fff;
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 6px;
}

.header-logout:hover {
  background: rgba(255, 255, 255, 0.12);
}

.login-content {
  display: flex;
  justify-content: center;
  padding-top: 3rem;
}

.login-panel {
  width: 100%;
  max-width: 400px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 500;
}

.login-form input {
  padding: 0.5rem 0.65rem;
  border: 1px solid #c5ccd3;
  border-radius: 6px;
  font-size: 1rem;
}

.login-error {
  margin: 0 0 1rem;
  padding: 0.65rem 0.75rem;
  background: #fde8eb;
  border: 1px solid #e57373;
  border-radius: 6px;
  color: #b00020;
}

.content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 2rem 3rem;
}

.panel {
  background: var(--panel-bg);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.panel h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--header-bg);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="date"],
select,
textarea {
  padding: 0.55rem 0.75rem;
  border: 1px solid #c5ccd3;
  border-radius: 8px;
  font-size: 0.95rem;
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--btn-border);
  outline-offset: 1px;
}

.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.button-row.centre {
  justify-content: center;
}

.btn {
  padding: 0.55rem 1.25rem;
  border-radius: 999px;
  background: #fff;
  border: 2px solid transparent;
  background-image: linear-gradient(#fff, #fff), var(--border-gradient);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}

.btn:hover {
  background-image: linear-gradient(#f5f8ff, #f5f8ff), var(--border-gradient);
}

.btn-danger {
  color: #fff;
  background: #c0392b;
  background-image: none;
  border-color: #a93226;
}

.btn-danger:hover {
  background: #a93226;
  background-image: none;
}

.btn-upload {
  cursor: pointer;
  margin: 0;
}

.btn-upload input[type="file"] {
  display: none;
}

.reef-bulk-actions {
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.btn-primary {
  font-size: 1rem;
  padding: 0.65rem 2rem;
}

.suggestions {
  border: 1px solid #c5ccd3;
  border-radius: 8px;
  background: #fff;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 0.5rem;
}

.suggestions.hidden {
  display: none;
}

.suggestion-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

.suggestion-item:hover {
  background: #e8f0f8;
}

.preview-row {
  margin-top: 0.75rem;
}

.preview-img {
  max-height: 120px;
  border-radius: 8px;
  border: 1px solid #ddd;
}

.preview-img.hidden {
  display: none;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th,
td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid #e2e6ea;
  text-align: left;
}

th {
  background: #f4f6f8;
  font-weight: 600;
}

tr:hover td {
  background: #f9fbfd;
}

/* Reef picker — whole row clickable, green tick when selected */
#reefs_table tr.reef-row {
  cursor: pointer;
}

#reefs_table tr.reef-row:hover td {
  background: #f0f7f2;
}

#reefs_table tr.reef-row-picked td {
  background: #e8f5e9;
}

#reefs_table tr.reef-row-picked:hover td {
  background: #dff0e1;
}

#reefs_table tr.reef-row-picked.reef-row-selected td {
  background: #e0f0e8;
}

.reef-pick-cell {
  width: 2.75rem;
  text-align: center;
  vertical-align: middle;
}

.reef-pick-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.reef-pick-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border: 2px solid #9eb0c0;
  border-radius: 5px;
  background: #fff;
  vertical-align: middle;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.reef-pick-tick {
  width: 0.95rem;
  height: 0.95rem;
  fill: #fff;
  opacity: 0;
  transform: scale(0.5);
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
}

#reefs_table tr.reef-row-picked .reef-pick-box {
  background: linear-gradient(145deg, #43a047, #2e7d32);
  border-color: #2e7d32;
  box-shadow: 0 1px 3px rgba(46, 125, 50, 0.35);
}

#reefs_table tr.reef-row-picked .reef-pick-tick {
  opacity: 1;
  transform: scale(1);
}

#reefs_table tr.reef-row:focus-visible {
  outline: 2px solid var(--btn-border, #1565c0);
  outline-offset: -2px;
}

.status-area {
  margin-top: 1rem;
  padding: 1rem;
  background: #f4f8fb;
  border-radius: 8px;
  border-left: 4px solid var(--header-bg);
}

.status-area.hidden {
  display: none;
}

#warnings_list li {
  color: #8a5a00;
}

#email_results .fail {
  color: #b00020;
}

#email_results .ok {
  color: #0a6b3a;
}

.download-link {
  font-weight: 600;
  color: var(--link);
}

.hidden {
  display: none !important;
}

.add-panel {
  margin-top: 1rem;
  padding: 0.75rem 0 0;
  border-top: 1px solid #e2e6ea;
}

.add-panel summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--link);
  margin-bottom: 0.75rem;
}

.hint {
  font-weight: 400;
  font-size: 0.85rem;
  color: #555;
  margin: 0;
}

.span-2 {
  grid-column: 1 / -1;
}

.inline-status {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
}

.inline-status.ok {
  color: #0a6b3a;
}

.inline-status.fail {
  color: #b00020;
}

.photo-crop-panel {
  margin-top: 1rem;
  padding: 1rem;
  background: #f4f8fb;
  border-radius: 8px;
  border: 1px solid #c5ccd3;
}

.photo-crop-panel .hint {
  margin-bottom: 0.75rem;
}

.photo-crop-mount {
  display: inline-block;
}

.photo-crop-viewport {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  border: 2px solid var(--header-bg);
  background: #0a4d68;
  cursor: grab;
  touch-action: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.photo-crop-viewport.dragging {
  cursor: grabbing;
}

.photo-crop-image {
  position: absolute;
  top: 0;
  left: 0;
  user-select: none;
  pointer-events: none;
}

.crop-zoom-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.75rem;
  max-width: 280px;
  font-size: 0.9rem;
  font-weight: 500;
}

.crop-zoom-label input[type="range"] {
  width: 100%;
}

.section-intro {
  margin: 0 0 1rem;
}

.steps-list {
  margin: 0 0 1rem 1.25rem;
  padding: 0;
  font-size: 0.9rem;
  color: #444;
  line-height: 1.6;
}

.add-leader-fields {
  margin-bottom: 0.5rem;
}

.maps-results {
  margin-top: 1.25rem;
}

.maps-cards {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.map-card {
  padding: 1rem 1.25rem;
  background: #f4f8fb;
  border: 1px solid #c5ccd3;
  border-radius: 8px;
}

.map-card-title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  color: var(--header-bg);
}

.map-reef-list {
  margin: 0 0 0.75rem;
}

.photo-crop-viewport {
  position: relative;
}

.photo-crop-scene {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  transform-origin: 0 0;
}

.photo-crop-scene .photo-crop-image {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
}

.map-pins-layer {
  position: absolute;
  inset: 0;
  left: 0;
  top: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 2;
}

.map-pin {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #ff9800;
  border: 2px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: translate(-50%, -100%) rotate(-45deg);
  transform-origin: center bottom;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.map-inset-frame-overlay {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  box-sizing: border-box;
  border: 3px solid #ff9800;
  background: rgba(0, 0, 0, 0.45);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85);
}

.map-inset-frame-overlay::before {
  content: "Inset map";
  position: absolute;
  left: 0;
  top: 0;
  padding: 3px 6px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.2;
  color: #1a1a1a;
  background: #ff9800;
}

.subsection-title {
  margin: 1.25rem 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--header-bg);
}

.leaders-table-wrap {
  margin-bottom: 0.5rem;
}

.leaders-table .col-thumb {
  width: 52px;
}

.leaders-table .col-actions {
  width: 88px;
  text-align: right;
  white-space: nowrap;
}

.leader-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #ddd;
  vertical-align: middle;
  background: #e8f0f8;
}

.leader-thumb.placeholder {
  display: inline-block;
}

.leaders-empty-row td {
  color: #666;
  font-style: italic;
}

.leader-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.35rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid #c5ccd3;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  color: var(--header-bg);
}

.icon-btn:hover {
  background: #e8f0f8;
  border-color: var(--btn-border);
}

.icon-btn.danger:hover {
  background: #fde8eb;
  border-color: #c62828;
  color: #b00020;
}

.icon-btn svg {
  width: 1.1rem;
  height: 1.1rem;
  pointer-events: none;
}

tr.leader-row-selected td {
  background: #e8f4fc;
}

#reefs_table tr.reef-row-selected:not(.reef-row-picked) td {
  background: #e8f4fc;
}
