/* Lab 4: стилі + теми + модалка */

/* ===== Змінні теми ===== */
:root{
  --bg: #f2f2f4;
  --page: #ffffff;
  --text: #111111;
  --muted: #444444;
  --border: #d9d9df;
  --soft: #ededf2;
  --accent: #1f3c88;
  --thead: #f4f4f8;
}

body.theme-dark{
  --bg: #0f1115;
  --page: #171a21;
  --text: #f1f2f4;
  --muted: #c0c4cc;
  --border: #2b2f3a;
  --soft: #242a36;
  --accent: #7aa2ff;
  --thead: #1f2430;
}

/* ===== Box model базово ===== */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text);
  line-height: 1.45;
}

/* контейнер */
.page {
  max-width: 960px;
  margin: 24px auto;
  background: var(--page);
  border: 1px solid var(--border);
  padding: 28px;
}

/* ===== Header (Flexbox) ===== */
.header {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.header-left { flex: 1.2; }
.header-right { flex: 0.8; }

#main-title {
  margin: 0;
  font-size: 44px;
  line-height: 0.95;
}

.contact-line { margin: 6px 0; }

.divider {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 18px 0;
}

/* ===== Основний макет (Flexbox 2 колонки) ===== */
.layout {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}

.col-left { flex: 1.25; }
.col-right { flex: 0.95; }

.block { margin-bottom: 18px; }

.title {
  margin: 0 0 10px;
  font-size: 20px;
}

.item { padding: 10px 0; }
.item + .item { border-top: 1px solid var(--soft); }

.item-title { margin: 0 0 4px; font-size: 16px; }
.item-meta { margin: 0 0 8px; font-size: 13px; color: var(--muted); }

.small-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.icon {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* списки */
.list { margin: 6px 0 0; padding-left: 18px; }

/* таблиця */
.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
}

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

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

/* ===== Селектор атрибутів + псевдоклас ===== */
a[href] {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}
a:hover { text-decoration: underline; }

.small { font-size: 13px; color: var(--muted); }
.footer { font-size: 13px; color: var(--muted); }
.footer-text { margin: 0 0 10px; }

/* ===== Коментарі ===== */
.comments { margin: 8px 0 0; padding-left: 18px; }
.comments li { margin: 8px 0; }
.comment-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: transparent;
}
.comment-name { font-weight: 700; }
.comment-email { color: var(--muted); font-size: 13px; }

/* ===== localStorage dump у футері ===== */
.storage { margin-top: 10px; }
.storage summary { cursor: pointer; font-weight: 700; }
.storage-dump {
  margin: 10px 0 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  overflow: auto;
  max-height: 220px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ===== Перемикач теми ===== */
.theme {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-text { font-size: 13px; color: var(--muted); }

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}

.switch input { display: none; }

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 20px;
  transition: 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background: var(--page);
  border-radius: 50%;
  transition: 0.2s;
  border: 1px solid var(--soft);
}

.switch input:checked + .slider {
  background: var(--accent);
}
.switch input:checked + .slider::before {
  transform: translateX(22px);
}

/* ===== Модальне вікно ===== */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 50;
}

.modal.is-open { display: block; }

.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
}

.modal__content {
  position: relative;
  width: min(520px, calc(100% - 28px));
  margin: 10vh auto;
  background: var(--page);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}

.modal__title { margin: 0 0 8px; font-size: 20px; }

.modal__close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
}

.field { display: block; margin: 10px 0; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

.field input,
.field textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
}

.btn {
  border: 1px solid var(--border);
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
}

/* адаптив */
@media (max-width: 700px) {
  .header, .layout { flex-direction: column; }
  #main-title { font-size: 36px; }
  .page { margin: 0; border: none; padding: 18px; }
}