/* ===== Base ===== */
html,
body {
  font-family: Vazirmatn, sans-serif;
  direction: rtl;
  margin: 0;
  padding: 0;
  background: #f8f8f8;
  color: #1a1a1a;
}

/* ===== Navbar ===== */
.top-nav {
  position: relative;
  /* needed so the overlay sits inside it */
  display: flex;
  justify-content: center;
  /* center the brand text horizontally */
  align-items: center;
  padding: 60px 20px;
  background-image: url('https://freight.cargo.site/t/original/i/79848d0506af19a21554263d130265a459cc806eafdf39d716d3d1287b6c0d8a/connect.gif');
  background-size: cover;
  /* gif fills the whole nav */
  background-position: center bottom;
  border-bottom: 1px solid #e0e0e0;
}

/* dark overlay so white text stays readable over the gif */
.top-nav::before {
  content: '';
  position: absolute;
  inset: 0;
  /* shorthand for top/right/bottom/left: 0 */
  background: rgba(0, 0, 0, 0.45);
}

.nav-brand {
  position: relative;
  /* sits above the ::before overlay */
  z-index: 1;
  text-decoration: none;
  color: #ffffff;
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* ===== Page wrapper ===== */
/* replaces: container mt-4 — centered, max-width, padding, top margin */
.form-wrapper {
  max-width: 900px;
  margin: 24px auto;
  padding: 0 16px;
}

/* ===== Page show/hide ===== */
.page {
  display: none;
}

#page1 {
  display: block;
}

/* ===== Headings ===== */
/* replaces: text-center */
.section-title {
  text-align: center;
  margin-bottom: 8px;
}

/* replaces: text-center mb-5 text-secondary */
.section-subtitle {
  text-align: center;
  color: #6c757d;
  margin-bottom: 32px;
}

/* ===== Color input grid ===== */
/* replaces: row + col-3 — 4 equal columns, wraps on small screens */
.input-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

/* replaces: col-3 form-group */
.input-col {
  display: flex;
  flex-direction: column;
}

/* replaces: w-100 on inputs inside columns */
.input-col .main {
  width: 100%;
  box-sizing: border-box;
}

/* ===== Text inputs (main class) ===== */
.main {
  padding: 8px 10px;
  border: 1px solid #ced4da;
  border-radius: 6px;
  font-family: Vazirmatn, sans-serif;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.main:focus {
  border-color: #0d6efd;
}

/* ===== Info/alert boxes ===== */
/* replaces: alert alert-secondary and alert alert-info */
.info-box {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.info-box--neutral {
  background: #e9ecef;
  border: 1px solid #ced4da;
  color: #495057;
}

.info-box--blue {
  background: #cfe2ff;
  border: 1px solid #b6d4fe;
  color: #084298;
}

/* small inline inputs inside the info boxes */
/* replaces: w-5 and w-20 */
.inline-input {
  width: 70px;
  padding: 4px 8px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-family: Vazirmatn, sans-serif;
  font-size: 0.95rem;
  text-align: center;
  outline: none;
}

.inline-input:focus {
  border-color: #0d6efd;
}

/* ===== Buttons ===== */
/* replaces: btn btn-primary and btn btn-danger */
.btn {
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  font-family: Vazirmatn, sans-serif;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary {
  background: #0d6efd;
  color: #ffffff;
}

.btn-primary:hover {
  background: #0b5ed7;
}

.btn-danger {
  background: #dc3545;
  color: #ffffff;
}

.btn-danger:hover {
  background: #bb2d3b;
}

.btn-insert {
  background: #198754;
  color: #ffffff;
  padding: 8px 12px;
  font-size: 1.1rem;
  line-height: 1;
}

.btn-insert:hover {
  background: #157347;
}

/* ===== Form actions (button row) ===== */
/* replaces: row text-center + col-12 text-center */
.form-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ===== Pattern table (page 2) ===== */
/* replaces: Bootstrap's .table */
.pattern-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

.pattern-table td,
.pattern-table th {
  padding: 10px 12px;
  border: 1px solid #dee2e6;
  text-align: center;
  vertical-align: middle;
}

.pattern-table tr:nth-child(even) {
  background: #f2f2f2;
}

/* row number column — narrow and centered */
.pattern-table td:first-child {
  width: 40px;
  font-weight: 600;
  color: #555;
}

/* color select — fill its cell */
.pattern-table select {
  width: 100%;
  padding: 8px 10px;
  font-family: Vazirmatn, sans-serif;
  font-size: 1rem;
  border: 1px solid #ced4da;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
  box-sizing: border-box;
}

.pattern-table select:focus {
  border-color: #0d6efd;
}

/* repeat count input — fill its cell, match select height */
.pattern-table input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  font-family: Vazirmatn, sans-serif;
  font-size: 1rem;
  border: 1px solid #ced4da;
  border-radius: 6px;
  outline: none;
  text-align: center;
  box-sizing: border-box;
}

.pattern-table input[type="number"]:focus {
  border-color: #0d6efd;
}

/* delete button cell — just wide enough for the button */
.pattern-table td:last-child {
  width: 80px;
}

.pattern-table .btn {
  width: 100%;
}

/* ===== Color select dropdowns (page 1) ===== */
.color-label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #444;
}

/* wrapper holds the swatch + the select side by side */
.color-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* the color swatch box */
.color-preview {
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid #ced4da;
  background: #e9ecef;
  flex-shrink: 0;
  transition: background 0.2s;
}

/* make the select fill remaining space */
.color-select {
  flex: 1;
  min-width: 0;
}

@media (max-width: 600px) {
  .input-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* on mobile: shrink number and delete columns, give space to select */
  .pattern-table td:first-child {
    width: 28px;
    padding: 6px 4px;
    font-size: 0.8rem;
  }

  .pattern-table td:last-child {
    width: 52px;
    padding: 6px 4px;
  }

  /* shrink the repeat count column */
  .pattern-table td:nth-child(3) {
    width: 48px;
    padding: 6px 4px;
  }

  .pattern-table input[type="number"] {
    padding: 6px 4px;
    font-size: 0.85rem;
  }

  .pattern-table select {
    padding: 6px 4px;
    font-size: 0.85rem;
  }

  .pattern-table .btn {
    padding: 6px 4px;
    font-size: 0.8rem;
  }
}

@media (max-width: 360px) {
  .input-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Simulation modal ===== */
.sim-modal-overlay {
  display: flex;
  justify-content: center;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9999;
  visibility: hidden;
  pointer-events: none;
}

.sim-modal-box {
  position: relative;
  width: 90vw;
  height: 85vh;
  background: #6b6b6b;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: stretch;
}

.sim-modal-close {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sim-modal-close:hover {
  background: rgba(0, 0, 0, 0.8);
}

#simCanvas {
  display: block;
  width: 100%;
  height: 100%;
}