/* ============================================================
   RadioParts — CSS
   Theme: Industrial Electronics / Dark PCB
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&family=Exo+2:wght@300;400;600;700;900&display=swap');

:root {
  --bg:        #0d1117;
  --bg2:       #161b22;
  --bg3:       #21262d;
  --border:    #30363d;
  --border2:   #444c56;
  --text:      #e6edf3;
  --text2:     #8b949e;
  --text3:     #6e7681;
  --accent:    #58a6ff;
  --accent2:   #1f6feb;
  --green:     #3fb950;
  --orange:    #d29922;
  --red:       #f85149;
  --purple:    #bc8cff;
  --yellow:    #e3b341;
 --mono: 'JetBrains Mono', monospace;
  --sans:      'Exo 2', sans-serif;
  --radius:    6px;
  --radius2:   12px;
  --shadow:    0 2px 16px rgba(0,0,0,.5);
  --glow:      0 0 20px rgba(88,166,255,.15);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* PCB grid background */
  background-image:
    linear-gradient(rgba(88,166,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(88,166,255,.03) 1px, transparent 1px);
  background-size: 32px 32px;
}

a { color: var(--accent); text-decoration: none; transition: color .2s; }
a:hover { color: #fff; }

img { max-width: 100%; display: block; }

/* ── HEADER ────────────────────────────────── */
.site-header {
  background: rgba(13,17,23,.95);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.logo {
  font-family: var(--mono);
  font-size: 1.25rem;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: .05em;
  display: flex;
  align-items: center;
  gap: .4rem;
  white-space: nowrap;
}
.logo:hover { color: #fff; }
.logo-icon { font-size: 1.4rem; }

.main-nav {
  display: flex;
  gap: .25rem;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }
.nav-cat {
  color: var(--text2);
  font-size: .82rem;
  padding: .3rem .65rem;
  border-radius: var(--radius);
  white-space: nowrap;
  transition: all .2s;
}
.nav-cat:hover { color: var(--text); background: var(--bg3); }
.nav-cat.active { color: var(--accent); background: rgba(88,166,255,.1); }

.user-nav {
  display: flex;
  align-items: center;
  gap: .5rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.user-nav a {
  color: var(--text2);
  font-size: .85rem;
  padding: .3rem .7rem;
  border-radius: var(--radius);
  transition: all .2s;
}
.user-nav a:hover { color: var(--text); background: var(--bg3); }
.user-nav a[href="/add.php"] {
  background: var(--accent2);
  color: #fff;
  font-weight: 600;
}
.user-nav a[href="/add.php"]:hover { background: var(--accent); }
.nav-user {
  font-family: var(--mono);
  color: var(--green);
  font-size: .8rem;
  padding: .2rem .5rem;
  background: rgba(63,185,80,.1);
  border-radius: var(--radius);
}
.burger { display: none; background: none; border: 1px solid var(--border); color: var(--text); padding: .3rem .6rem; border-radius: var(--radius); cursor: pointer; }

/* ── FLASH ─────────────────────────────────── */
.flash-container { position: fixed; top: 68px; right: 1rem; z-index: 200; display: flex; flex-direction: column; gap: .5rem; }
.alert {
  padding: .75rem 2.5rem .75rem 1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  position: relative;
  max-width: 400px;
  animation: slideIn .3s ease;
}
.alert-success { background: rgba(63,185,80,.15); border: 1px solid var(--green); color: var(--green); }
.alert-error   { background: rgba(248,81,73,.15);  border: 1px solid var(--red);   color: var(--red); }
.alert-info    { background: rgba(88,166,255,.15); border: 1px solid var(--accent); color: var(--accent); }
.alert-close { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); background: none; border: none; color: inherit; cursor: pointer; font-size: 1.1rem; line-height: 1; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ── LAYOUT ─────────────────────────────────── */
.main-content { max-width: 1400px; margin: 0 auto; padding: 1.5rem; flex: 1; width: 100%; }
.site-footer { border-top: 1px solid var(--border); padding: 1rem 1.5rem; text-align: center; }
.footer-inner { max-width: 1400px; margin: 0 auto; display: flex; justify-content: space-between; color: var(--text3); font-size: .82rem; }

/* ── PAGE TITLE ─────────────────────────────── */
.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.page-title .badge {
  font-size: .75rem;
  font-family: var(--mono);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: .15rem .5rem;
  border-radius: 20px;
}

/* ── CARDS GRID ─────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  overflow: hidden;
  transition: all .25s;
  display: flex;
  flex-direction: column;
}
.card:hover {
  border-color: var(--accent);
  box-shadow: var(--glow);
  transform: translateY(-2px);
}
.card-img {
  width: 100%;
  height: 140px;
  object-fit: contain;
  background: var(--bg3);
  padding: .5rem;
}
.card-img-placeholder {
  width: 100%;
  height: 140px;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--border2);
}
.card-body { padding: 1rem; flex: 1; display: flex; flex-direction: column; gap: .5rem; }
.card-part { font-family: var(--mono); font-size: 1rem; color: var(--accent); font-weight: 700; }
.card-cat {
  font-size: .72rem;
  padding: .15rem .5rem;
  border-radius: 20px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  width: fit-content;
}
.card-desc { font-size: .85rem; color: var(--text2); flex: 1; }
.card-meta { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: .5rem; border-top: 1px solid var(--border); }
.card-qty { font-family: var(--mono); font-size: .85rem; }
.card-qty strong { color: var(--green); }
.card-owner { font-size: .75rem; color: var(--text3); }
.card-location { font-size: .75rem; color: var(--orange); font-family: var(--mono); }
.card-actions { display: flex; gap: .4rem; padding: .75rem 1rem; border-top: 1px solid var(--border); background: rgba(0,0,0,.2); }
.card-actions a, .card-actions button {
  font-size: .78rem;
  padding: .25rem .6rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: none;
  color: var(--text2);
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
}
.card-actions a:hover, .card-actions button:hover { border-color: var(--accent); color: var(--accent); background: rgba(88,166,255,.08); }
.card-actions .btn-delete:hover { border-color: var(--red); color: var(--red); background: rgba(248,81,73,.08); }

/* ── SPECS TABLE ────────────────────────────── */
.specs-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.specs-table tr { border-bottom: 1px solid var(--border); }
.specs-table td { padding: .35rem .6rem; }
.specs-table td:first-child { color: var(--text2); width: 40%; font-family: var(--mono); font-size: .8rem; }
.specs-table td:last-child { color: var(--text); font-weight: 500; }

/* ── FILTERS / TOOLBAR ──────────────────────── */
.toolbar {
  display: flex;
  gap: .75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
}
.search-box input {
  width: 100%;
  padding: .5rem 1rem .5rem 2.5rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: .9rem;
  transition: border .2s;
}
.search-box input:focus { outline: none; border-color: var(--accent); }
.search-box::before {
  content: '🔍';
  position: absolute;
  left: .7rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: .85rem;
}
select.filter-select {
  padding: .5rem .75rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  cursor: pointer;
}
select.filter-select:focus { outline: none; border-color: var(--accent); }

/* ── CATEGORY CARDS (home) ─────────────────── */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.cat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  padding: 1.5rem 1.25rem;
  text-align: center;
  transition: all .25s;
  cursor: pointer;
  display: block;
  color: var(--text);
}
.cat-card:hover { border-color: var(--accent); box-shadow: var(--glow); transform: translateY(-2px); color: var(--text); }
.cat-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.cat-name { font-weight: 700; font-size: 1rem; }
.cat-count { font-size: .8rem; color: var(--text2); margin-top: .25rem; font-family: var(--mono); }

/* ── FORMS ──────────────────────────────────── */
.form-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  padding: 2rem;
  max-width: 700px;
}
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: .85rem;
  color: var(--text2);
  margin-bottom: .4rem;
  font-weight: 600;
}
.form-group input[type=text],
.form-group input[type=email],
.form-group input[type=password],
.form-group input[type=number],
.form-group input[type=url],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: .6rem .9rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: .9rem;
  transition: border .2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { outline: none; border-color: var(--accent); }
.form-group textarea { min-height: 90px; resize: vertical; }
.form-hint { font-size: .78rem; color: var(--text3); margin-top: .3rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* Specs editor */
.specs-editor { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.spec-row { display: flex; gap: 0; }
.spec-row input {
  flex: 1;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: .45rem .7rem;
  background: var(--bg3);
  color: var(--text);
  font-size: .85rem;
}
.spec-row input:first-child { border-right: 1px solid var(--border); font-family: var(--mono); color: var(--text2); }
.spec-row:last-child input { border-bottom: none; }
.spec-row .btn-remove-spec {
  width: 36px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
  color: var(--text3);
  cursor: pointer;
  font-size: 1rem;
  transition: all .2s;
}
.spec-row:last-child .btn-remove-spec { border-bottom: none; }
.spec-row .btn-remove-spec:hover { color: var(--red); background: rgba(248,81,73,.08); }

/* ── BUTTONS ────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.2rem;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  border: 1px solid transparent;
  text-decoration: none;
}
.btn-primary { background: var(--accent2); color: #fff; border-color: var(--accent2); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-secondary { background: var(--bg3); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: rgba(248,81,73,.1); color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: rgba(248,81,73,.2); color: #fff; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }

/* ── AUTH PAGES ─────────────────────────────── */
.auth-wrap {
  max-width: 440px;
  margin: 4rem auto;
}
.auth-logo {
  text-align: center;
  font-family: var(--mono);
  font-size: 1.8rem;
  color: var(--accent);
  margin-bottom: 2rem;
}
.auth-logo span { color: var(--text3); }

/* ── DETAIL PAGE ────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: auto 1fr; gap: 2rem; }
.detail-image {
  width: 220px;
  height: 220px;
  object-fit: contain;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  padding: 1rem;
}
.detail-placeholder {
  width: 220px;
  height: 220px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  color: var(--border2);
}
.detail-part { font-family: var(--mono); font-size: 2rem; color: var(--accent); margin-bottom: .25rem; }
.detail-mfr { color: var(--text2); font-size: .9rem; margin-bottom: 1rem; }
.detail-section { margin-bottom: 1.5rem; }
.detail-section h3 { font-size: .9rem; color: var(--text2); text-transform: uppercase; letter-spacing: .08em; margin-bottom: .75rem; border-bottom: 1px solid var(--border); padding-bottom: .4rem; }

/* ── IMPORT PAGE ────────────────────────────── */
.import-area {
  border: 2px dashed var(--border2);
  border-radius: var(--radius2);
  padding: 3rem;
  text-align: center;
  transition: all .3s;
  cursor: pointer;
}
.import-area:hover, .import-area.dragover {
  border-color: var(--accent);
  background: rgba(88,166,255,.05);
}
.import-area .import-icon { font-size: 3rem; margin-bottom: 1rem; }
.import-area p { color: var(--text2); margin-bottom: .5rem; }
.import-area small { color: var(--text3); font-size: .8rem; }

/* ── STATS BAR ──────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.stat-num { font-family: var(--mono); font-size: 1.4rem; color: var(--accent); font-weight: 700; }
.stat-label { font-size: .8rem; color: var(--text2); }

/* ── TABLE ──────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.data-table thead th {
  background: var(--bg3);
  color: var(--text2);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .6rem .9rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-weight: 600;
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.data-table tbody tr:hover { background: rgba(88,166,255,.04); }
.data-table td { padding: .65rem .9rem; }
.data-table .mono { font-family: var(--mono); color: var(--accent); font-size: .85rem; }
.data-table .qty-badge {
  background: rgba(63,185,80,.12);
  color: var(--green);
  font-family: var(--mono);
  padding: .1rem .45rem;
  border-radius: 20px;
  font-size: .8rem;
}

/* ── PAGINATION ─────────────────────────────── */
.pagination { display: flex; gap: .4rem; margin-top: 1.5rem; justify-content: center; }
.pagination a, .pagination span {
  padding: .4rem .75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: .85rem;
  color: var(--text2);
  background: var(--bg2);
  transition: all .2s;
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { border-color: var(--accent); color: var(--accent); background: rgba(88,166,255,.1); }

/* ── TABS ──────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.tab {
  padding: .6rem 1.2rem;
  font-size: .88rem;
  color: var(--text2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── EMPTY STATE ────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text2);
}
.empty-state .icon { font-size: 4rem; margin-bottom: 1rem; opacity: .5; }
.empty-state h3 { font-size: 1.2rem; color: var(--text); margin-bottom: .5rem; }

/* ── RESPONSIVE ─────────────────────────────── */
@media (max-width: 768px) {
  .main-nav { display: none; }
  .burger { display: block; }
  .main-nav.open { display: flex; flex-direction: column; position: absolute; top: 58px; left: 0; right: 0; background: var(--bg); border-bottom: 1px solid var(--border); padding: 1rem; z-index: 99; }
  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-image, .detail-placeholder { width: 100%; }
  .form-row { grid-template-columns: 1fr; }
  .header-inner { gap: .75rem; }
  .user-nav a:not([href="/add.php"]) { display: none; }
}

/* ── AUTOCOMPLETE ───────────────────────────── */
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 240px;
  overflow-y: auto;
  z-index: 50;
}
.autocomplete-list li {
  list-style: none;
  padding: .5rem .9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .75rem;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.autocomplete-list li:hover, .autocomplete-list li.selected { background: rgba(88,166,255,.1); }
.autocomplete-list .ac-part { font-family: var(--mono); color: var(--accent); font-size: .88rem; }
.autocomplete-list .ac-mfr { font-size: .78rem; color: var(--text2); }
.autocomplete-wrap { position: relative; }
