/* ===== PCForge — общий файл стилей ===== */

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1f2630;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #9aa7b4;
  --accent: #38bdf8;
  --accent-2: #a78bfa;
  --ok: #4ade80;
  --warn: #fbbf24;
  --error: #f87171;
  --radius: 12px;
  --max-width: 1200px;
}

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

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-2);
}

:focus-visible {
  outline: 3px solid var(--accent-2);
  outline-offset: 2px;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 0.6em;
}

h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
}

h2 {
  font-size: clamp(1.3rem, 3vw, 1.7rem);
}

h3 {
  font-size: 1.1rem;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--accent);
  color: var(--bg);
  padding: 8px 12px;
  border-radius: 6px;
  z-index: 10;
}

.skip-link:focus {
  left: 8px;
}

/* ----- Шапка ----- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.site-header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.logo img {
  width: 170px;
}

.main-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.main-nav a {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.main-nav a:hover {
  background: var(--surface-2);
  color: var(--accent);
}

.main-nav a[aria-current="page"] {
  background: var(--surface-2);
  color: var(--accent);
}

.build-counter {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

/* ----- Основная часть ----- */
main {
  flex: 1;
  padding: 32px 0 48px;
}

section + section {
  margin-top: 48px;
}

.lead {
  color: var(--muted);
  font-size: 1.1rem;
  max-width: 60ch;
}

.breadcrumbs ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.breadcrumbs li + li::before {
  content: "›";
  margin-right: 6px;
}

/* ----- Кнопки ----- */
.btn {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: var(--bg);
}

.btn-outline {
  background: transparent;
  color: var(--accent);
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.9rem;
}

.btn-danger {
  background: transparent;
  border-color: var(--error);
  color: var(--error);
}

.btn-danger:hover {
  background: var(--error);
  border-color: var(--error);
}

/* ----- Главная: первый экран ----- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  align-items: center;
  gap: 32px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  padding: 0;
  margin: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--accent-2);
  color: var(--bg);
  font-weight: 700;
}

/* ----- Карточки товаров ----- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 6px;
  padding: 14px 16px 16px;
}

.card-category {
  color: var(--accent-2);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card h3 {
  margin: 0;
  font-size: 1rem;
}

.card h3 a {
  color: var(--text);
  text-decoration: none;
}

.card h3 a:hover {
  color: var(--accent);
}

.card-specs {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}

.price {
  font-size: 1.15rem;
  font-weight: 700;
  white-space: nowrap;
}

/* ----- Каталог ----- */
.catalog-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: start;
}

.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.filters fieldset {
  border: 0;
  margin: 0 0 16px;
  padding: 0;
}

.filters legend {
  font-weight: 600;
  margin-bottom: 6px;
}

.check-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.price-range {
  display: flex;
  gap: 8px;
}

.catalog-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.catalog-empty {
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

/* ----- Формы ----- */
label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}

.check-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

input[type="checkbox"] {
  width: auto;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.form-field {
  margin-bottom: 14px;
}

.form-field.has-error input,
.form-field.has-error textarea,
.form-field.has-error select {
  border-color: var(--error);
}

.field-error {
  display: block;
  min-height: 1.2em;
  margin-top: 4px;
  color: var(--error);
  font-size: 0.9rem;
}

.field-hint {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.form-result {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--ok);
  color: var(--ok);
}

.form-result.is-error {
  border-color: var(--error);
  color: var(--error);
}

/* ----- Страница товара ----- */
.product {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.product-image {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.product-buy {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin: 16px 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.product-buy .price {
  font-size: 1.6rem;
}

.currency-box {
  color: var(--muted);
  font-size: 0.95rem;
}

.spec-table {
  width: 100%;
  border-collapse: collapse;
}

.spec-table th,
.spec-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.spec-table th {
  width: 45%;
  color: var(--muted);
  font-weight: 400;
}

details {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}

summary {
  cursor: pointer;
  font-weight: 600;
}

/* ----- Страница «Моя сборка» ----- */
.build-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

.build-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

.build-table th,
.build-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.build-table thead th {
  background: var(--surface-2);
}

.build-table .empty-slot {
  color: var(--muted);
}

.build-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: sticky;
  top: 90px;
}

.build-summary dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  margin: 0 0 16px;
}

.build-summary dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

.build-total {
  font-size: 1.5rem;
}

.checks {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.checks li {
  padding: 8px 10px;
  border-radius: 8px;
  border-left: 4px solid var(--ok);
  background: var(--surface-2);
  font-size: 0.92rem;
}

.checks li.is-warn {
  border-left-color: var(--warn);
}

.checks li.is-error {
  border-left-color: var(--error);
}

.status-loading {
  color: var(--muted);
}

.status-loading::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  vertical-align: -2px;
  border: 2px solid var(--muted);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.status-error {
  color: var(--error);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ----- Контакты ----- */
.contacts-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

.contact-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.contact-info dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 16px;
  margin: 0;
}

.contact-info dt {
  color: var(--muted);
}

.contact-info dd {
  margin: 0;
}

.slogan {
  margin-top: 16px;
  font-size: 1.2rem;
  font-style: italic;
  color: var(--accent);
}

/* ----- Личный кабинет ----- */
.auth-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.saved-builds {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.saved-builds li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.saved-builds .build-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.saved-builds ul {
  margin: 8px 0;
  padding-left: 20px;
  color: var(--muted);
}

/* ----- Страница 404 ----- */
.error-page {
  text-align: center;
  padding: 40px 0;
}

.error-code {
  font-size: 6rem;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
}

/* ----- Подвал ----- */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding-top: 20px;
  padding-bottom: 20px;
}

.site-footer address {
  font-style: normal;
}

/* ----- Адаптивность ----- */
@media (max-width: 900px) {
  .catalog-layout,
  .build-layout,
  .product,
  .hero,
  .contacts-layout,
  .auth-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .build-summary {
    position: static;
  }
}

@media (max-width: 600px) {
  main {
    padding-top: 20px;
  }

  .logo img {
    width: 140px;
  }

  .main-nav {
    width: 100%;
  }

  .main-nav ul {
    gap: 2px;
  }

  .main-nav a {
    padding: 6px 8px;
    font-size: 0.95rem;
  }

  .build-table thead {
    display: none;
  }

  .build-table,
  .build-table tbody,
  .build-table tr,
  .build-table td,
  .build-table th {
    display: block;
    width: 100%;
  }

  .build-table tr {
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
  }

  .build-table th,
  .build-table td {
    border: 0;
    padding: 4px 12px;
  }

  .contact-info dl {
    grid-template-columns: 1fr;
  }
}

/* ----- Вспомогательные классы ----- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.h3 {
  font-size: 1.1rem;
}

.build-summary form {
  margin-top: 20px;
}
