/* styles.css */

/* =========================
   Theme + Typography
   ========================= */
:root{
  --bg: #121212;
  --panel: #1a1a1a;
  --panel2: #1e1e1e;
  --border: #2b2b2b;

  --text: #ffffff;
  --muted: #cfcfcf;

  --font: Arial, sans-serif;

  /* Typography scale */
  --fs-body: 15px;
  --fs-label: 13px;
  --fs-h1: 34px;
  --fs-h2: 18px;
  --fs-section: 22px;
  --fs-subsection: 16px;

  --fw-regular: 400;
  --fw-medium: 600;
  --fw-bold: 800;

  /* Inputs */
  --input-bg: #ffffff;
  --input-text: #111;
  --input-border: #3a3a3a;

  /* Buttons */
  --btn: #1db954;
  --btn-hover: #1aa34a;
  --danger: #ff4d4d;
  --danger-hover: #d93434;

  /* Traffic */
  --green: #00c853;
  --yellow: #ffeb3b;
  --orange: #ff9800;
  --red: #ff1744;
}

* { box-sizing: border-box; }

body{
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  margin: 0;
  min-height: 100vh;
}

/* Contenedor principal */
.container{
  text-align: center;
  padding: 20px;
  width: 95%;
  max-width: 1100px;
  margin: 0 auto 18px auto;
}

/* Headings consistency */
h1{
  margin: 18px 0 8px 0;
  font-size: var(--fs-h1);
  font-weight: var(--fw-bold);
  letter-spacing: 0.6px;
}

h2{
  margin: 10px 0 18px 0;
  font-size: var(--fs-h2);
  font-weight: var(--fw-medium);
  color: #eaeaea;
}

h3{
  margin: 0;
  font-size: var(--fs-subsection);
  font-weight: var(--fw-bold);
}

/* Section titles that are plain H2 in HTML */
.main-title { font-size: var(--fs-h1); font-weight: var(--fw-bold); }
.subtitle { font-size: var(--fs-h2); font-weight: var(--fw-medium); }

/* Labels must ALWAYS be smaller than inputs */
label{
  display: block;
  margin: 0 0 4px 0;
  font-size: var(--fs-label);
  font-weight: var(--fw-medium);
  color: var(--muted);
}

/* =========================
   Buttons
   ========================= */
.btn{
  background: var(--btn);
  color: #fff;
  border: none;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: var(--fw-medium);
  border-radius: 6px;
  transition: background-color 0.2s ease;
}
.btn:hover{ background: var(--btn-hover); }

.btn-ghost{
  background: transparent;
  border: 1px solid #444;
  color: #ddd;
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 8px;
}
.btn-ghost:hover{ border-color: #777; color: #fff; }

.btn-small{
  padding: 6px 10px;
  font-size: 13px;
}

/* =========================
   Logo + Logout
   ========================= */
.logo{
  width: 200px;
  margin: 12px auto 4px auto;
  display: block;
}

.logout-container{
  text-align: right;
  margin: 10px 20px;
  position: absolute;
  top: 0;
  right: 0;
}

.btn-logout{
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: var(--fw-medium);
}
.btn-logout:hover{ background: #ff1a1a; }

/* =========================
   Inputs (ALL white)
   ========================= */
select,
input[type="number"],
input[type="date"]{
  width: 100%;
  padding: 7px 10px;
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--input-text);
  box-sizing: border-box;
}

input[type="number"]{ text-align: center; }

/* =========================
   Routes grid
   ========================= */
.grid{
  width: 100%;
  margin-top: 10px;
}

.grid-row.route-row{
  display: grid;
  grid-template-columns:
    minmax(0, 1.05fr)
    minmax(0, 1.05fr)
    minmax(0, 0.95fr)
    110px
    70px
    42px;
  gap: 10px;
  align-items: end;
  margin-bottom: 8px;
}

/* allow shrink so delete stays in same row */
.grid-row.route-row > div{ min-width: 0; }
.grid-row.route-row select,
.grid-row.route-row input[type="number"]{ min-width: 0; }

/* route labels slightly tighter */
.grid-row.route-row label{
  font-size: var(--fs-label);
  margin-bottom: 4px;
}

.route-last-col{
  display: flex;
  justify-content: center;
  align-items: end;
}

.btn-delete{
  background: var(--danger);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-weight: var(--fw-bold);
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-delete:hover{ background: var(--danger-hover); }

.routes-block {
  width: 100%;
}

.route-header,
.route-row {
  display: grid;
  grid-template-columns: 1.4fr 1.4fr 1.3fr 0.9fr 0.6fr 44px;
  gap: 10px;
  align-items: center;
}

.route-header {
  margin-bottom: 8px;
  font-weight: 700;
  color: #d9d9d9;
  text-align: center;
}

.route-row {
  margin-bottom: 12px;
}

.route-row select,
.route-row input[type="number"] {
  width: 100%;
  box-sizing: border-box;
}

.route-last-col {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* =========================
   Receivers block
   ========================= */
#receivers-section{
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.receivers-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.receivers-header h3{
  font-size: var(--fs-subsection);
  font-weight: var(--fw-bold);
}

.receivers-actions{
  display: flex;
  gap: 10px;
}

#receivers-grid{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.receiver-chip{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid #2f2f2f;
  background: #141414;
  color: #fff;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: var(--fw-medium);
}

.receiver-chip input[type="checkbox"]{
  width: 16px;
  height: 16px;
}

/* =========================
   Static machines (Pala/Perfo must be top-left)
   ========================= */
#static-machines-wrapper{
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 30px;
  margin-top: 18px;
  flex-wrap: wrap;
}

/* Left panel: no space-between (that pushed the select to the middle) */
#static-machines-controls{
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
  min-width: 260px;
}

/* Make this select WHITE like the others */
#static-machines-controls select{
  background: var(--input-bg);
  color: var(--input-text);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  padding: 7px 10px;
  width: 100%;
}

#selected-points{
  margin-top: 6px;
  text-align: left;
  font-size: 13px;
  color: var(--muted);
}

#selected-points button{
  margin-left: 6px;
  background: #333;
  border: none;
  color: #eee;
  cursor: pointer;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
}

/* Map */
#mine-map-container{
  position: relative;
  display: inline-block;
  border: 2px solid #444;
  border-radius: 8px;
  overflow: hidden;
}

#mine-map{
  width: 600px;
  height: auto;
  cursor: crosshair;
}

/* Markers */
.marker{
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1px solid #fff;
  pointer-events: none;
  z-index: 10;
  transform-origin: center;
}

.marker.pala{
  background: orange;
  border-radius: 50%;
}

.marker.perfo{
  background: red;
  transform: rotate(45deg);
  border-radius: 2px;
}

/* Legend icons */
.legend-icon{
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  vertical-align: middle;
}

.legend-icon.pala{
  background: orange;
  border-radius: 50%;
  border: 1px solid #fff;
}

.legend-icon.perfo{
  background: red;
  transform: rotate(45deg);
  border: 1px solid #fff;
  border-radius: 2px;
}

/* =========================
   Env conditions
   ========================= */
#env-conditions{
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 20px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.env-field{
  display: flex;
  flex-direction: column;
  width: 160px;
  text-align: left;
}

.env-field-button{
  display: flex;
  align-items: flex-end;
}

/* =========================
   Spinner
   ========================= */
#spinner{
  display: none;
  text-align: center;
  margin-top: 15px;
}

.css-spinner{
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top: 4px solid white;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  animation: spin 1s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes spin{
  0%{ transform: rotate(0deg); }
  100%{ transform: rotate(360deg); }
}

#simulando-text{
  display: inline-block;
  vertical-align: middle;
  font-weight: var(--fw-medium);
  color: #ffffff;
  font-size: 14px;
  white-space: nowrap;
  position: relative;
}

#simulando-text::after{
  content: "...";
  position: absolute;
  left: 100%;
  width: 1.5em;
  overflow: hidden;
  animation: dotsSlide 1.4s steps(4, end) infinite;
  text-align: left;
}

@keyframes dotsSlide{
  0%{ width: 0em; }
  25%{ width: 0.5em; }
  50%{ width: 1em; }
  75%,100%{ width: 1.5em; }
}

/* =========================
   Results
   ========================= */
.result-box{
  margin-top: 24px;
  padding: 20px 18px;
  text-align: center;
  border-radius: 12px;
}

.results-title{
  margin-top: 18px;
  text-align: center;
  font-weight: var(--fw-bold);
  font-size: 28px;
}

.results-table{
  margin-top: 14px;
  width: 100%;
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.20);
}

.results-row{
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.results-row:first-child{ border-top: none; }

.results-name{
  font-weight: var(--fw-bold);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-size: 16px;
}

.results-val{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: var(--fw-bold);
  font-size: 18px;
  white-space: nowrap;
}

.results-db{
  font-variant-numeric: tabular-nums;
  font-weight: var(--fw-bold);
}

.traffic-dot{
  width: 14px;
  height: 14px;
  border-radius: 999px;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.35) inset;
  border: 1px solid rgba(255,255,255,0.18);
}

.traffic-dot.green{ background: var(--green); }
.traffic-dot.yellow{ background: var(--yellow); }
.traffic-dot.orange{ background: var(--orange); }
.traffic-dot.red{ background: var(--red); }

/* =========================
   (Optional) If you still use output-box somewhere
   ========================= */
.output-box{
  margin-top: 20px;
  text-align: left;
  background: var(--panel2);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid #333;
  white-space: pre-wrap;
  font-family: monospace;
  font-size: 13px;
}