/* ====== Normalize CSS ====== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  line-height: 1.15;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
}

main {
  display: block;
}

h1 {
  font-size: 2em;
  margin: 0.67em 0;
}

p {
  margin: 1em 0;
}

abbr[title] {
  border-bottom: none;
  text-decoration: underline dotted;
}

b,
strong {
  font-weight: bolder;
}

button,
input,
optgroup,
select,
textarea {
  font-family: inherit;
  font-size: 100%;
  line-height: 1.15;
  margin: 0;
}

button,
input {
  overflow: visible;
}

button,
select {
  text-transform: none;
}

button,
[type="button"],
[type="reset"],
[type="submit"] {
  -webkit-appearance: button;
}

button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
  border-style: none;
  padding: 0;
}

button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
  outline: 1px dotted ButtonText;
}

/* ====== Variables ====== */
:root {
  --color-body-bg: #f8f9fa;
  --color-body-text: #212529;
  --color-primary: #0d6efd;
  --color-primary-hover: #0b5ed7;
  --color-danger: #dc3545;
  --color-muted: #6c757d;
  --color-border: #dee2e6;

  --radius: 0.375rem;
  --shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);

  --font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ====== Base ====== */
body.app {
  font-family: var(--font-family);
  background-color: var(--color-body-bg);
  color: var(--color-body-text);
  margin: 0;
  padding: 0;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app__container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1rem;
  flex-grow: 1;
}

/* ====== Header ====== */
.app__header {
  text-align: center;
  margin-bottom: 2rem;
}

.app__title {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.app__subtitle {
  font-size: 1.125rem;
  color: var(--color-muted);
}

/* ====== Form ====== */
.form {
  background-color: #fff;
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.form__group {
  margin-bottom: 1rem;
}

.form__label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form__required {
  color: var(--color-danger);
}

.form__input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-body-text);
  background-color: #fff;
  border: 1px solid #ced4da;
  border-radius: var(--radius);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form__input::placeholder {
  color: var(--color-muted);
}

.form__input:focus {
  border-color: #86b7fe;
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Показываем ошибку только после фокуса или попытки отправки */
.form__input:focus:invalid {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

.form__error {
  font-size: 0.875rem;
  color: var(--color-danger);
  margin-top: 0.25rem;
  display: none;
}

.form__hint {
  font-size: 0.875rem;
  color: var(--color-muted);
  margin-top: 0.25rem;
}

/* ====== Button ====== */
.form__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  font-weight: 500;
  color: #fff;
  background-color: var(--color-primary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.15s;
  position: relative;
  min-height: 48px;
}

.form__button:hover {
  background-color: var(--color-primary-hover);
}

.form__button-text {
  position: relative;
  z-index: 2;
}

.form__button-loader {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s linear infinite;
  transform: translate(-50%, -50%);
  z-index: 1;
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* ====== Results ====== */
.results {
  margin-top: 2rem;
}

.results__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.results__title {
  font-size: 1.5rem;
  font-weight: 600;
}

.results__cache-indicator {
  font-size: 0.875rem;
  color: var(--color-muted);
  background-color: #cff4fc;
  border-radius: var(--radius);
  padding: 0.25rem 0.5rem;
}

.results__card {
  background: #fff;
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  transition: all 0.3s ease;
}

.results__card:hover {
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.results__card-title {
  font-size: 1.25rem;
  margin: 0 0 1rem 0;
}

.results__content {
  font-size: 0.95rem;
}

/* ====== Error ====== */
.error__card {
  background: #fff;
  border: 1px solid var(--color-danger);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--color-danger);
}

.error__title {
  font-size: 1.25rem;
  margin: 0 0 1rem 0;
}

.error__content {
  font-size: 0.95rem;
}

/* ====== Footer ====== */
.footer {
  border-top: 1px solid var(--color-border);
  padding: 1rem;
  text-align: center;
  color: var(--color-muted);
  font-size: 0.9rem;
  background-color: #fff;
  margin-top: auto;
}
