/* ============================================================
   МОДАЛКИ, КОНТЕКСТНОЕ МЕНЮ, ПОПАПЫ, ПОДТВЕРЖДЕНИЯ
   ============================================================ */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 3000;
  padding: 20px;
}
.modal.show { display: flex; }

.modal-box {
  background: var(--bg-secondary);
  color: var(--text);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-box h3 { margin-bottom: 4px; }
.modal-box input,
.modal-box textarea,
.modal-box select {
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  outline: none;
  font-family: inherit;
}
.modal-box textarea { min-height: 150px; resize: vertical; }
.modal-box button {
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  font-size: 15px;
}
.modal-box button.secondary {
  background: var(--bg-tertiary);
  color: var(--text);
}
.modal-box button.danger { background: var(--danger); }
.modal-box button.ok { background: var(--ok); }

.modal-actions {
  display: flex;
  gap: 8px;
}
.modal-actions button { flex: 1; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}
.checkbox-row input { width: 20px; height: 20px; }

/* ============================================================
   СЕТКА ТЕМ
   ============================================================ */

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 4px 0;
}
.theme-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: var(--bg-tertiary);
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.1s;
}
.theme-card:active { transform: scale(0.97); }
.theme-card.active { border-color: var(--accent); }
.theme-preview {
  height: 60px;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
}
.theme-preview-accent {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
}
.theme-name {
  font-size: 12px;
  color: var(--text);
  text-align: center;
  font-weight: 500;
}

/* ============================================================
   КОНТЕКСТНОЕ МЕНЮ СООБЩЕНИЯ
   ============================================================ */

#msgMenu {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  display: none;
  flex-direction: column;
  min-width: 220px;
  z-index: 4000;
  overflow: hidden;
}
#msgMenu.show { display: flex; }
#msgMenu .menu-item {
  padding: 14px 18px;
  cursor: pointer;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
#msgMenu .menu-item:last-child { border-bottom: none; }
#msgMenu .menu-item:active { background: var(--bg-tertiary); }
#msgMenu .menu-item.danger { color: var(--danger); }
#msgMenu .menu-item.star { color: var(--star); }

/* ============================================================
   ПОПАП ФОРМУЛЯРА
   ============================================================ */

#formularPopup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 5000;
  padding: 16px;
}
#formularPopup.show { display: flex; }
#formularPopup .popup-box {
  background: var(--bg-secondary);
  color: var(--text);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#formularPopup .popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#formularPopup .popup-section {
  background: var(--accent);
  color: #fff;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
}
#formularPopup .popup-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}
#formularPopup .popup-title {
  font-size: 18px;
  font-weight: bold;
}
#formularPopup .popup-text {
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}
#formularPopup .popup-photos {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 250px;
  overflow-y: auto;
}
#formularPopup .popup-photos img {
  width: 100%;
  border-radius: 8px;
}
#formularPopup .popup-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
#formularPopup .popup-actions button {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
}
#formularPopup .btn-read { background: var(--ok); color: #fff; }
#formularPopup .btn-later {
  background: var(--bg-tertiary);
  color: var(--text);
}

/* ============================================================
   ПОДТВЕРЖДЕНИЕ
   ============================================================ */

.confirm-box {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 6000;
  padding: 20px;
}
.confirm-box.show { display: flex; }
.confirm-box .box {
  background: var(--bg-secondary);
  color: var(--text);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.confirm-box .box h3 { margin-bottom: 4px; }
.confirm-box .box .actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.confirm-box .box .actions button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
}
.confirm-box .box .actions .yes { background: var(--danger); color: #fff; }
.confirm-box .box .actions .no {
  background: var(--bg-tertiary);
  color: var(--text);
}