/* =========================================================
   Krake Factory UI â€” shared styles (board/records/form/labels)
   ========================================================= */

/* ---------- Design tokens ---------- */
:root{
  --bg: #f4f5fb;
  --card: #ffffff;
  --muted: #6b7280;
  --text: #111827;
  --border: #d5d7e2;

  --primary: #2f6feb;
  --primary-700: #2555b8;

  --danger: #c62828;
  --success: #2e7d32;

  --shadow: 0 2px 10px rgba(0,0,0,0.06);
  --radius: 10px;
}

/* ---------- Global layout & typography ---------- */
*{ box-sizing: border-box; }
html, body{ height: 100%; }

body{
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.35;
}

a{ color: var(--primary); text-decoration: none; }
a:hover{ text-decoration: underline; }

h1, h2, h3{
  margin: 0 0 0.6rem;
  font-weight: 700;
  color: var(--text);
}

h1{ font-size: 1.6rem; }
h2{ font-size: 1.25rem; }
h3{ font-size: 1rem; }

/* ---------- Top navigation ---------- */
.top-nav{
  max-width: 960px;
  margin: 0 auto 1rem;
  padding: 0.75rem 0.75rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-start;
}

.nav-btn{
  display: inline-block;
  padding: 0.42rem 0.95rem;
  border-radius: 999px;
  border: 1px solid #c4c7d4;
  background: #f5f6ff;
  font-size: 0.85rem;
  font-weight: 650;
  color: #2f3c6e;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.1s ease;
}

.nav-btn:hover{
  background: #e0e3ff;
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0,0,0,0.08);
  text-decoration: none;
}

/* Active nav button: supports both .active class and aria-current */
.nav-btn.active,
.nav-btn[aria-current="page"]{
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  cursor: default;
  box-shadow: none;
  pointer-events: none;
  text-decoration: none;
}

.nav-btn:active{ transform: translateY(0); }

/* ---------- Shared containers (cards) ---------- */
.board-container,
.records-container,
.labels-container{
  max-width: 960px;
  margin: 0 auto 2rem;
  padding: 1.5rem 2rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Allow wide tables to scroll on small screens */
.records-container{ overflow-x: auto; }

.records-header,
.labels-header{ margin-bottom: 1rem; }

.dim{
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---------- Inputs ---------- */
label{
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: #111827;
}

input[type="text"],
input[type="date"],
input[type="number"],
input[type="url"],
input[type="file"],
select,
textarea{
  width: 100%;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  border: 1px solid #c4c7d4;
  font-size: 0.92rem;
  background: #ffffff;
  color: var(--text);
}

textarea{
  min-height: 3.2rem;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus{
  outline: 3px solid rgba(47,111,235,0.18);
  outline-offset: 1px;
  border-color: rgba(47,111,235,0.7);
}

/* ---------- Buttons ---------- */
button,
.btn-primary,
.btn-secondary{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.05rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.95rem;
  font-weight: 650;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.1s ease, border-color 0.15s ease;
}

.btn-primary,
button[type="submit"],
#search-btn,
#reloadBtn{
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 4px rgba(47,111,235,0.35);
}

.btn-primary:hover,
button[type="submit"]:hover,
#search-btn:hover,
#reloadBtn:hover{
  background: var(--primary-700);
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(37,85,184,0.35);
}

.btn-secondary,
#exportCsvBtn{
  background: #ffffff;
  color: #1f2a44;
  border-color: #c4c7d4;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

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

button:active,
.btn-primary:active,
.btn-secondary:active{
  transform: translateY(0);
}

/* ---------- Status messages ---------- */
#status,
.status-msg{
  margin-top: 0.75rem;
  font-size: 0.92rem;
}

#status:empty{ display: none; }

.status-msg{ margin-left: 0.25rem; color: #394263; }
.status-msg.success{ color: var(--success); }
.status-msg.error{ color: var(--danger); }

/* Optional: if you ever add classes on #status */
#status.success{
  background: #e6f6ec;
  border: 1px solid #83c39c;
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  color: #14532d;
  text-align: center;
}

#status.error{
  background: #fde8e8;
  border: 1px solid #f19999;
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  color: #7f1d1d;
  text-align: center;
}

/* ---------- Factory form (test register) ---------- */
#testForm fieldset{
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem 1.15rem;
  margin: 0 0 1.25rem;
  background: #fafbff;
}

#testForm legend{
  padding: 0 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: #394263;
}

#testForm fieldset{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem 1rem;
}

#testForm textarea{ min-height: 4.25rem; }

.button-row{
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ---------- Board view (board.html) ---------- */
.search-row{
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.search-row input[type="text"]{ min-width: 220px; }

.board-card{
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-top: 0.75rem;
}

.board-meta-grid{
  margin-top: 0.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.35rem 1rem;
  font-size: 0.92rem;
}

.tests-list{ margin-top: 1rem; }

.test-item{
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
  margin-bottom: 0.75rem;
}

.test-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  background: #f8fafc;
  cursor: pointer;
  font-size: 0.9rem;
}

.test-header:hover{ background: #eef2ff; }

.test-body{
  display: none;
  padding: 0.85rem 0.9rem 1rem;
  border-top: 1px solid var(--border);
}

.test-body.open{ display: block; }

.badge{
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 750;
  border: 1px solid #c4c7d4;
  color: #334155;
  background: #ffffff;
  vertical-align: middle;
}

.badge-pass{
  background: #e6f6ec;
  border-color: #83c39c;
  color: #14532d;
}

.badge-fail{
  background: #fde8e8;
  border-color: #f19999;
  color: #7f1d1d;
}

.badge-rework{
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
}

.mini-table{
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.25rem;
  font-size: 0.9rem;
}

.mini-table th,
.mini-table td{
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #eef0f6;
  vertical-align: top;
}

.mini-table th{
  width: 46%;
  text-align: left;
  color: #334155;
  font-weight: 650;
}

/* ---------- Records (records.html) ---------- */
.records-controls{
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-top: 0.75rem;
}

.records-table{
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  margin-top: 1rem;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.records-table thead th{
  text-align: left;
  padding: 0.65rem 0.6rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  color: #334155;
}

.records-table tbody td{
  padding: 0.6rem 0.6rem;
  border-bottom: 1px solid #eef0f6;
  font-size: 0.9rem;
}

.records-table tbody tr:hover{ background: #f8fafc; }

.record-count{
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Result highlighting */
.result-pass{ color: var(--success); font-weight: 750; }
.result-fail{ color: var(--danger); font-weight: 750; }
.result-other{ color: #9a3412; font-weight: 700; }

/* ---------- Labels page (labels.html) ---------- */
.labels-form{
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.9rem 1rem;
}

.labels-dimensions{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}

.labels-form .button-row{
  grid-column: 1 / -1;
}

/* ---------- Mobile tweaks ---------- */
@media (max-width: 640px){
  .top-nav{ padding: 0.75rem 0.75rem 0; }

  .board-container,
  .records-container,
  .labels-container{
    margin: 0 0.6rem 1.25rem;
    padding: 1.15rem 1rem;
  }

  .search-row input[type="text"]{ min-width: 100%; }

  #testForm fieldset{ grid-template-columns: 1fr; }

  .records-table{ min-width: 640px; }
}