/* === Shared tool-modal === */
/* Базовые стили для .tool-modal-overlay / .tool-modal — используются
   инструментами (staff, foam, uprazhnenia, tests, stopwatch_history,
   ptv). Тул-специфичные расширения живут в css/tools/<tool>.css. */
.tool-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.tool-modal-overlay--visible {
  opacity: 1;
  pointer-events: auto;
}

.tool-modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 90%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--color-on-surface);
}
.tool-modal--sm { max-width: 520px; }
.tool-modal--md { max-width: 720px; }
.tool-modal--lg { max-width: 960px; }

.tool-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px 10px 20px;
  background: color-mix(in srgb, var(--color-primary) 20%, var(--color-surface));
  flex-shrink: 0;
}

.tool-modal__title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--color-on-surface);
}

.tool-modal__close {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-on-surface-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.tool-modal__close:hover {
  background: var(--color-hover);
  color: var(--color-on-surface);
}
.tool-modal__close svg {
  width: 18px;
  height: 18px;
}

.tool-modal__body {
  padding: 20px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.tool-modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

/* === pcAlert / pcConfirm — Promise-based замена нативных alert()/confirm(). */
.pc-dialog {
  width: 100%;
  max-width: 440px;
}

/* Заголовок всегда в аппбаре, одной строкой с троеточием если не влезает. */
.pc-dialog__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}

.pc-dialog__body {
  padding: 16px 20px;
}

.pc-dialog__line {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--color-on-surface);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.pc-dialog__line:last-child { margin-bottom: 0; }
.pc-dialog__line:empty { display: none; }

/* Произвольный HTML в теле — используется, например, для карточки слоя
   в подтверждении загрузки. */
.pc-dialog__extra {
  margin-top: 8px;
}
.pc-dialog__extra:first-child {
  margin-top: 0;
}

/* Список пар ключ-значение для расширенной информации. */
.pc-dialog__kv {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  row-gap: 6px;
  font-size: 13px;
}
.pc-dialog__kv dt {
  color: var(--color-on-surface-secondary);
  font-weight: 500;
}
.pc-dialog__kv dd {
  margin: 0;
  color: var(--color-on-surface);
  word-break: break-word;
}

.pc-dialog__footer {
  padding: 10px 16px 14px;
}

/* Красная primary-кнопка для destructive-действий (pcConfirm с danger:true). */
.pc-dialog__btn--danger {
  background: #D32F2F !important;
  color: #fff !important;
}
.pc-dialog__btn--danger:hover {
  background: #B71C1C !important;
}


/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay--visible {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 24px;
  max-width: 480px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content__title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.modal-content__text {
  font-size: 14px;
  color: var(--color-on-surface-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
}

.modal-content__close {
  display: inline-block;
  padding: 8px 24px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-family);
}


/* === Settings Modal Popup === */
.modal-overlay {
  transition: opacity 0.25s ease;
}

.modal-content--settings {
  max-width: 440px;
  padding: 0;
  overflow: hidden;
}

.modal-content__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 10px 20px;
  background: color-mix(in srgb, var(--color-primary) 20%, var(--color-surface));
}

.modal-content__title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.modal-content__close-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-on-surface-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.modal-content__close-btn:hover {
  background: var(--color-hover);
  color: var(--color-on-surface);
}
.modal-content__close-btn svg {
  display: block;
  width: 18px;
  height: 18px;
}

.modal-content__body {
  padding: 20px 24px 24px;
  max-height: 70vh;
  overflow-y: auto;
}

/* === Info Modal (Поддержка / Сообщество / Скачать) === */
#info-modal-overlay .modal-content__body {
  padding: 16px 20px 20px;
}


/* === Profile modal === */
.profile-modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 0;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: var(--color-on-surface);
}

.profile-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px 10px 20px;
  background: color-mix(in srgb, var(--color-primary) 20%, var(--color-surface));
  flex-shrink: 0;
}

.profile-modal__title {
  font-size: 16px;
  font-weight: 600;
}

.profile-modal__close {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-on-surface-secondary);
  transition: background 0.15s;
  flex-shrink: 0;
}
.profile-modal__close:hover {
  background: var(--color-hover);
}
.profile-modal__close svg {
  width: 18px;
  height: 18px;
}

.profile-modal__body {
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.profile-modal__form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.profile-modal__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-modal__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-on-surface-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.profile-modal__field input {
  height: 42px;
  padding: 0 14px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: var(--font-family);
  color: var(--color-on-surface);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.profile-modal__field input:focus {
  border-color: var(--color-primary);
  background: var(--color-surface);
}

.profile-modal__input-wrap {
  position: relative;
}
.profile-modal__input-wrap input {
  width: 100%;
  padding-right: 44px;
  box-sizing: border-box;
}
.profile-modal__eye {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--color-on-surface-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.profile-modal__eye:hover {
  background: var(--color-hover);
  color: var(--color-on-surface);
}

.profile-modal__submit {
  height: 44px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: opacity 0.15s, filter 0.15s;
  margin-top: 4px;
}
[data-theme="dark"] .profile-modal__submit {
  color: #000;
}
.profile-modal__submit:hover:not(:disabled) {
  filter: brightness(1.05);
}
.profile-modal__submit:disabled {
  opacity: 0.6;
  cursor: default;
}

.profile-modal__error {
  font-size: 13px;
  color: #D32F2F;
  line-height: 1.4;
  background: color-mix(in srgb, #D32F2F 10%, transparent);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
[data-theme="dark"] .profile-modal__error {
  color: #F28B82;
}
.profile-modal__secret {
  margin-top: 4px;
  font-size: 12px;
  color: var(--color-on-surface-secondary);
}

.profile-modal__hint {
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-on-surface-secondary);
  padding-top: 4px;
  border-top: 1px solid var(--color-border);
}

.profile-modal__sync {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--color-hover);
  cursor: pointer;
  user-select: none;
}
.profile-modal__sync input[type="checkbox"] {
  grid-row: 1 / span 2;
}
.profile-modal__sync-label {
  font-size: 14px;
  color: var(--color-on-surface);
}
.profile-modal__sync-note {
  font-size: 12px;
  color: var(--color-on-surface-secondary);
}
.profile-modal__sync--disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.profile-modal__sync--disabled input[type="checkbox"] {
  cursor: not-allowed;
}

.profile-modal__card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 0;
}

.profile-modal__avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-bg);
  flex-shrink: 0;
}
.profile-modal__avatar--fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-on-surface-secondary);
}
.profile-modal__avatar--fallback svg {
  width: 60px;
  height: 60px;
}

.profile-modal__info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.profile-modal__name {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-on-surface);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-modal__phone {
  font-size: 13px;
  color: var(--color-on-surface-secondary);
}

.profile-modal__badge {
  display: inline-block;
  margin-top: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  width: fit-content;
}
.profile-modal__badge--paid {
  background: color-mix(in srgb, #4CAF50 18%, transparent);
  color: #2E7D32;
}
[data-theme="dark"] .profile-modal__badge--paid {
  color: #81C784;
}
.profile-modal__badge--free {
  background: var(--color-hover);
  color: var(--color-on-surface-secondary);
}

.profile-modal__logout {
  height: 40px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-on-surface);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: background 0.15s;
}
.profile-modal__logout:hover {
  background: var(--color-hover);
}

.profile-modal__pay {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: color-mix(in srgb, var(--color-primary) 6%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-primary) 18%, transparent);
  border-radius: var(--radius-sm);
}

.profile-modal__pay-btn {
  height: 40px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: not-allowed;
  opacity: 0.6;
}

[data-theme="dark"] .profile-modal__pay-btn {
  color: #000;
}

.profile-modal__pay-hint {
  font-size: 12px;
  line-height: 1.45;
  color: var(--color-on-surface-secondary);
}

.profile-modal__pay-hint a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.profile-modal__pay-hint a:hover {
  text-decoration: none;
}

