/* ─── TerraPlots Plugin Styles ─── */

/* Login overlay */
#tp-login-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.72);
  align-items: center;
  justify-content: center;
}

/* Login panel */
#tp-login-panel {
  position: relative;
  background: #2D3E50;
  border-radius: 12px;
  padding: 32px 30px 28px;
  width: 340px;
  max-width: 92vw;
  color: #fff;
  font-family: Arial, sans-serif;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

#tp-login-panel h3 {
  margin: 0 0 22px;
  font-size: 17px;
  font-weight: bold;
}

#tp-login-panel label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  color: #aaa;
}

#tp-login-panel input[type=text],
#tp-login-panel input[type=password] {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 11px;
  border-radius: 6px;
  border: 1px solid #445;
  background: #1a2738;
  color: #fff;
  font-size: 14px;
  margin-bottom: 14px;
  outline: none;
}

#tp-login-panel input:focus {
  border-color: #3a9e5f;
}

#tp-login-status {
  min-height: 18px;
  margin-bottom: 14px;
  font-size: 13px;
  color: #aaa;
}

#tp-login-status.error {
  color: #ff6b6b;
}

#tp-login-btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: #3a9e5f;
  color: #fff;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  font-family: Arial, sans-serif;
}

#tp-login-btn:hover {
  background: #2e8050;
}

/* Close button */
#tp-login-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

#tp-login-close:hover {
  color: #fff;
}

/* User badge (shown when logged in) */
#tp-user-badge {
  display: none;
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 1000;
  align-items: center;
  gap: 8px;
  background: rgba(45, 62, 80, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 6px 12px;
  font-family: Arial, sans-serif;
  font-size: 13px;
  color: #fff;
}

#tp-user-name {
  font-weight: bold;
}

#tp-logout-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  color: #ccc;
  font-size: 12px;
  padding: 2px 8px;
  cursor: pointer;
  font-family: Arial, sans-serif;
}

#tp-logout-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Admin visual indicator */
body.tp-admin #tp-user-badge {
  border-color: #3a9e5f;
}

body.tp-admin #tp-user-name::after {
  content: ' \2713';
  color: #3a9e5f;
  font-size: 11px;
}

/* ─── Ficha / Sidebar Panel ─── */

#tp-ficha-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9998;
  align-items: center;
  justify-content: flex-start;
  pointer-events: none;
}

#tp-ficha-panel {
  pointer-events: auto;
  position: relative;
  background: rgba(51, 51, 51, 0.95);
  border: 3px solid #FFFFFF;
  width: 300px;
  margin-left: 10px;
  color: #fff;
  font-family: Arial, sans-serif;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

#tp-ficha-panel.tp-slide-in {
  animation: tp-slide-in 0.4s ease-out forwards;
}

#tp-ficha-panel.tp-slide-out {
  animation: tp-slide-out 0.35s ease-in forwards;
}

@keyframes tp-slide-in {
  from { transform: translateX(-320px); opacity: 0; }
  to   { transform: translateX(0);      opacity: 1; }
}

@keyframes tp-slide-out {
  from { transform: translateX(0);      opacity: 1; }
  to   { transform: translateX(-320px); opacity: 0; }
}

#tp-ficha-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 22px;
  cursor: pointer;
  z-index: 1;
  line-height: 1;
  padding: 0;
}

#tp-ficha-close:hover {
  color: #fff;
}

#tp-ficha-content {
  padding: 20px 20px 15px;
  min-height: 200px;
}

#tp-ficha-content h2 {
  color: #FFFFFF;
  font-family: Arial, sans-serif;
  font-weight: normal;
  font-size: 18px;
  text-align: left;
  margin: 0 0 10px 10px;
}

#tp-ficha-content p {
  color: #FFFFFF;
  font-family: Arial, sans-serif;
  font-weight: normal;
  font-size: 15px;
  text-align: left;
  margin: 5px 0 5px 10px;
}

#tp-ficha-buttons {
  display: flex;
  gap: 8px;
  padding: 12px 15px;
  background: rgba(51, 51, 51, 0.95);
  border-top: 3px solid #FFFFFF;
}

.tp-ficha-btn {
  flex: 1;
  padding: 10px 5px;
  background: transparent;
  border: 2px solid transparent;
  color: #fff;
  font-family: Arial, sans-serif;
  font-size: 14px;
  cursor: pointer;
  text-align: center;
  border-radius: 3px;
  transition: border-color 0.2s, background 0.2s;
}

.tp-ficha-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: #FFFFFF;
}

.tp-ficha-btn-edit {
  border-color: #3a9e5f;
  color: #3a9e5f;
}

.tp-ficha-btn-edit:hover {
  background: rgba(58, 158, 95, 0.15);
  border-color: #3a9e5f;
  color: #fff;
}

/* ─── Admin Panel ─── */

#tp-admin-overlay {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100%;
  z-index: 9000;
  pointer-events: none;
}

#tp-admin-panel {
  pointer-events: auto;
  position: relative;
  width: 100%;
  height: 100%;
  background: rgba(30, 40, 55, 0.97);
  border-left: 2px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-family: Arial, sans-serif;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
}

#tp-admin-panel.tp-admin-slide-in {
  animation: tp-admin-slide-in 0.35s ease-out forwards;
}

#tp-admin-panel.tp-admin-slide-out {
  animation: tp-admin-slide-out 0.3s ease-in forwards;
}

@keyframes tp-admin-slide-in {
  from { transform: translateX(320px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

@keyframes tp-admin-slide-out {
  from { transform: translateX(0);     opacity: 1; }
  to   { transform: translateX(320px); opacity: 0; }
}

#tp-admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

#tp-admin-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: bold;
}

#tp-admin-close {
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

#tp-admin-close:hover {
  color: #fff;
}

#tp-admin-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
}

/* Toggle button */
#tp-admin-toggle {
  display: block;
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 8999;
  width: 36px;
  height: 36px;
  background: rgba(30, 40, 55, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-right: none;
  border-radius: 6px 0 0 6px;
  color: #ccc;
  font-size: 18px;
  cursor: pointer;
  line-height: 36px;
  text-align: center;
  padding: 0;
}

#tp-admin-toggle:hover {
  background: rgba(30, 40, 55, 1);
  color: #fff;
}

/* Create button */
.tp-admin-btn-create {
  display: block;
  width: 100%;
  padding: 10px;
  margin-bottom: 12px;
  background: #3a9e5f;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  font-family: Arial, sans-serif;
}

.tp-admin-btn-create:hover {
  background: #2e8050;
}

/* Plot list */
.tp-admin-plot-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tp-admin-plot-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s;
}

.tp-admin-plot-item:hover {
  background: rgba(255, 255, 255, 0.12);
}

.tp-admin-plot-name {
  font-size: 13px;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  margin-right: 8px;
}

.tp-admin-plot-status {
  font-size: 10px;
  font-weight: bold;
  padding: 2px 7px;
  border-radius: 3px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.tp-admin-empty {
  color: #777;
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
}

/* ─── Admin Form ─── */

.tp-admin-form {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tp-admin-form h4 {
  margin: 6px 0 12px;
  font-size: 15px;
  font-weight: bold;
}

.tp-admin-form label {
  display: block;
  font-size: 11px;
  color: #999;
  margin-top: 8px;
  margin-bottom: 3px;
}

.tp-admin-form input[type=text],
.tp-admin-form input[type=number],
.tp-admin-form select {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border-radius: 5px;
  border: 1px solid #3a4555;
  background: #1a2738;
  color: #fff;
  font-size: 13px;
  outline: none;
  font-family: Arial, sans-serif;
}

.tp-admin-form input:focus,
.tp-admin-form select:focus {
  border-color: #3a9e5f;
}

.tp-admin-form select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.tp-admin-back {
  align-self: flex-start;
  background: transparent;
  border: none;
  color: #999;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  margin-bottom: 4px;
  font-family: Arial, sans-serif;
}

.tp-admin-back:hover {
  color: #fff;
}

/* Coordinate entries */
.tp-admin-coord-entry {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
}

.tp-admin-coord-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.tp-admin-coord-entry-title {
  font-size: 11px;
  font-weight: bold;
  color: #bbb;
}

.tp-admin-coord-entry-remove {
  background: transparent;
  border: none;
  color: #666;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.tp-admin-coord-entry-remove:hover {
  color: #ff6b6b;
}

.tp-admin-coord-row {
  display: flex;
  gap: 6px;
}

.tp-admin-coord-field {
  flex: 1;
}

.tp-admin-coord-field label {
  font-size: 10px;
  color: #777;
  margin-top: 0;
}

.tp-admin-btn-coord {
  display: block;
  width: 100%;
  padding: 6px;
  margin-top: 6px;
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: #888;
  font-size: 11px;
  cursor: pointer;
  font-family: Arial, sans-serif;
  transition: border-color 0.2s, color 0.2s;
}

.tp-admin-btn-coord:hover {
  border-color: #3a9e5f;
  color: #3a9e5f;
}

.tp-admin-btn-add-coord {
  display: block;
  width: 100%;
  padding: 8px;
  margin-top: 4px;
  background: transparent;
  border: 1px dashed rgba(58, 158, 95, 0.4);
  border-radius: 5px;
  color: #3a9e5f;
  font-size: 12px;
  cursor: pointer;
  font-family: Arial, sans-serif;
  transition: background 0.2s;
}

.tp-admin-btn-add-coord:hover {
  background: rgba(58, 158, 95, 0.1);
}

/* Status message */
#tp-edit-status-msg {
  min-height: 18px;
  margin-top: 10px;
  font-size: 12px;
  color: #aaa;
}

#tp-edit-status-msg.tp-admin-error {
  color: #ff6b6b;
}

#tp-edit-status-msg.tp-admin-success {
  color: #3a9e5f;
}

/* Form actions */
.tp-admin-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.tp-admin-btn-save {
  flex: 1;
  padding: 9px;
  background: #3a9e5f;
  border: none;
  border-radius: 5px;
  color: #fff;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  font-family: Arial, sans-serif;
}

.tp-admin-btn-save:hover {
  background: #2e8050;
}

.tp-admin-btn-cancel {
  flex: 1;
  padding: 9px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  color: #ccc;
  font-size: 13px;
  cursor: pointer;
  font-family: Arial, sans-serif;
}

.tp-admin-btn-cancel:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.tp-admin-btn-delete {
  display: block;
  width: 100%;
  padding: 9px;
  margin-top: 16px;
  background: transparent;
  border: 1px solid rgba(255, 80, 80, 0.4);
  border-radius: 5px;
  color: #ff6b6b;
  font-size: 12px;
  cursor: pointer;
  font-family: Arial, sans-serif;
  transition: background 0.2s, color 0.2s;
}

.tp-admin-btn-delete:hover {
  background: rgba(255, 80, 80, 0.15);
  border-color: #ff6b6b;
  color: #ff8888;
}

/* ─── Coordinate Edit Mode ─── */

#tp-coord-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(30, 40, 55, 0.95);
  border-bottom: 2px solid #3a9e5f;
  font-family: Arial, sans-serif;
  font-size: 13px;
  color: #fff;
}

#tp-coord-bar span {
  flex: 1;
  text-align: center;
}

.tp-coord-confirm {
  padding: 6px 16px;
  background: #3a9e5f;
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  font-family: Arial, sans-serif;
}

.tp-coord-confirm:hover {
  background: #2e8050;
}

.tp-coord-cancel {
  padding: 6px 16px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  color: #ccc;
  font-size: 12px;
  cursor: pointer;
  font-family: Arial, sans-serif;
}

.tp-coord-cancel:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

body.tp-coord-edit-mode {
  cursor: crosshair !important;
}

/* ─── Mobile responsive ─── */

@media (max-width: 768px) {
  #tp-ficha-panel {
    width: 200px;
    margin-left: 5px;
  }

  #tp-ficha-content {
    min-height: 140px;
    padding: 15px;
  }

  #tp-ficha-content h2 {
    font-size: 15px;
  }

  #tp-ficha-content p {
    font-size: 13px;
  }

  #tp-admin-overlay {
    width: 260px;
  }

  @keyframes tp-admin-slide-in {
    from { transform: translateX(260px); opacity: 0; }
    to   { transform: translateX(0);     opacity: 1; }
  }

  @keyframes tp-admin-slide-out {
    from { transform: translateX(0);     opacity: 1; }
    to   { transform: translateX(260px); opacity: 0; }
  }

  #tp-coord-bar {
    flex-wrap: wrap;
    font-size: 12px;
    gap: 8px;
    padding: 8px 12px;
  }
}
